All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-07-25 11:17 kernel test robot
  2021-07-26  3:43   ` kernel test robot
  0 siblings, 1 reply; 10+ messages in thread
From: kernel test robot @ 2021-07-25 11:17 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 20866 bytes --]

CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Haiyang Zhang <haiyangz@microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>

Hi Haiyang,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d8079fac168168b25677dc16c00ffaf9fb7df723
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix duplicate CPU assignments within a device
date:   6 days ago
:::::: branch date: 11 hours ago
:::::: commit date: 6 days ago
config: x86_64-randconfig-c001-20210725 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross clang-analyzer ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1601:3: note: Taking false branch
                   if (field->logical_minimum < 0) /* signed values */
                   ^
   drivers/hid/hid-core.c:1605:44: note: Passing value via 4th parameter 'n'
                           implement(hid, data, offset + n * size, size,
                                                                   ^~~~
   drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
                           implement(hid, data, offset + n * size, size,
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
           if (unlikely(n > 32)) {
                        ^
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/hid/hid-core.c:1421:2: note: Taking false branch
           if (unlikely(n > 32)) {
           ^
   drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
           } else if (n < 32) {
                      ^~~~~~
   drivers/hid/hid-core.c:1425:9: note: Taking false branch
           } else if (n < 32) {
                  ^
   drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd parameter 'n'
           __implement(report, offset, n, value);
                                       ^
   drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
           __implement(report, offset, n, value);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
           while (n - bits_to_set >= 0) {
                  ^~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1400:2: note: Loop condition is false. Execution continues on line 1411
           while (n - bits_to_set >= 0) {
           ^
   drivers/hid/hid-core.c:1411:6: note: 'n' is 32
           if (n) {
               ^
   drivers/hid/hid-core.c:1411:2: note: Taking true branch
           if (n) {
           ^
   drivers/hid/hid-core.c:1412:22: note: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'unsigned int'
                   u8 bit_mask = ((1U << n) - 1);
                                      ^  ~
   drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is never read [clang-analyzer-deadcode.DeadStores]
                   len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                   ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never read
                   len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                   ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (8 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           channel->target_cpu = target_cpu;
                               ^
   drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. Execution continues on line 619
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
           ^
   drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
           init_vp_index(newchannel);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without an initial value
           u32 target_cpu;
           ^~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                         ^~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:737:7: note: Calling 'alloc_cpumask_var'
               !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/cpumask.h:740:2: note: Returning the value 1, which participates in a condition later
           return true;
           ^~~~~~~~~~~
   drivers/hv/channel_mgmt.c:737:7: note: Returning from 'alloc_cpumask_var'
               !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c8 K. Y. Srinivasan         2012-12-01  714  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  716   * Starting with Win8, we can statically distribute the incoming
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  717   * channel interrupt load by binding a channel to VCPU.
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  719   * For pre-win8 hosts or non-performance critical channels we assign the
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  720)  * VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  722)  * Starting with win8, performance critical channels will be distributed
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  723)  * evenly among all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  724)  * we will assign the CPU based on a simple round robin scheme.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  726) static void init_vp_index(struct vmbus_channel *channel)
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn = hv_is_perf_channel(channel);
7c9ff3deeee61b Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = num_online_cpus();
25355252607ca2 Dexuan Cui               2018-09-23  730  	cpumask_var_t available_mask;
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  731  	struct cpumask *alloced_mask;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  734  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == VERSION_WS2008) ||
25355252607ca2 Dexuan Cui               2018-09-23  736  	    (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca2 Dexuan Cui               2018-09-23  737  	    !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  739  		 * Prior to win8, all channel interrupts are
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered on VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  741  		 * Also if the channel is not a performance critical
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  743) 		 * In case alloc_cpumask_var() fails, bind it to
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  744) 		 * VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  746) 		channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  748) 			hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  751  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = next_numa_node_id++;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  755) 			if (numa_node == nr_node_ids) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  756) 				next_numa_node_id = 0;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  759) 			if (cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask = &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  764  
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  765  		if (cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  766) 		    cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  768  			 * We have cycled through all the CPUs in the node;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  769  			 * reset the alloced map.
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  771  			cpumask_clear(alloced_mask);
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  773  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, alloced_mask,
7c9ff3deeee61b Haiyang Zhang            2021-07-16  775  			    cpumask_of_node(numa_node));
79fd8e706637a5 Vitaly Kuznetsov         2016-01-27  776  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = cpumask_first(available_mask);
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  778) 		cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  779  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  780  		if (channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b Haiyang Zhang            2021-07-16  781  		    i > ncpu || !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b Haiyang Zhang            2021-07-16  784  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca2 Dexuan Cui               2018-09-23  786  
25355252607ca2 Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  789  

:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29581 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
  2021-07-25 11:17 drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] kernel test robot
@ 2021-07-26  3:43   ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-07-26  3:43 UTC (permalink / raw
  To: Haiyang Zhang; +Cc: kbuild-all, LKML, Wei Liu, Michael Kelley

[-- Attachment #1: Type: text/plain, Size: 20550 bytes --]


Hi Haiyang,

First bad commit (maybe != root cause):

tree: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d8079fac168168b25677dc16c00ffaf9fb7df723
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix 
duplicate CPU assignments within a device
date:   6 days ago
:::::: branch date: 11 hours ago
:::::: commit date: 6 days ago
config: x86_64-randconfig-c001-20210725 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
reproduce (this is a W=1 build):
         wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross 
-O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # install x86_64 cross compiling tool for clang build
         # apt-get install binutils-x86-64-linux-gnu
         # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
         git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
         git fetch --no-tags linus master
         git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
clang-analyzer ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1601:3: note: Taking false branch
                    if (field->logical_minimum < 0) /* signed values */
                    ^
    drivers/hid/hid-core.c:1605:44: note: Passing value via 4th 
parameter 'n'
                            implement(hid, data, offset + n * size, size,
                                                                    ^~~~
    drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
                            implement(hid, data, offset + n * size, size,
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
            if (unlikely(n > 32)) {
                         ^
    include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
    # define unlikely(x)    __builtin_expect(!!(x), 0)
                                                ^
    drivers/hid/hid-core.c:1421:2: note: Taking false branch
            if (unlikely(n > 32)) {
            ^
    drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
            } else if (n < 32) {
                       ^~~~~~
    drivers/hid/hid-core.c:1425:9: note: Taking false branch
            } else if (n < 32) {
                   ^
    drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd 
parameter 'n'
            __implement(report, offset, n, value);
                                        ^
    drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
            __implement(report, offset, n, value);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
            while (n - bits_to_set >= 0) {
                   ^~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1400:2: note: Loop condition is false. 
Execution continues on line 1411
            while (n - bits_to_set >= 0) {
            ^
    drivers/hid/hid-core.c:1411:6: note: 'n' is 32
            if (n) {
                ^
    drivers/hid/hid-core.c:1411:2: note: Taking true branch
            if (n) {
            ^
    drivers/hid/hid-core.c:1412:22: note: The result of the left shift 
is undefined due to shifting by '32', which is greater or equal to the 
width of type 'unsigned int'
                    u8 bit_mask = ((1U << n) - 1);
                                       ^  ~
    drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is 
never read [clang-analyzer-deadcode.DeadStores]
                    len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never read
                    len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
    Suppressed 6 warnings (6 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
    Suppressed 6 warnings (6 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    7 warnings generated.
    Suppressed 7 warnings (7 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    5 warnings generated.
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    3 warnings generated.
    Suppressed 3 warnings (3 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    9 warnings generated.
    Suppressed 9 warnings (8 in non-user code, 1 with check filters).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    5 warnings generated.
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
            channel->target_cpu = target_cpu;
                                ^
    drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
            BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) 
&&   \
                                                                       ^
    drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    note: (skipping 2 expansions in backtrace; use 
-fmacro-backtrace-limit=0 to see all)
    include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
            _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
            ^
    include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
            __compiletime_assert(condition, msg, prefix, suffix)
            ^
    include/linux/compiler_types.h:308:3: note: expanded from macro 
'__compiletime_assert'
                    if (!(condition)) 
     \
                    ^
    drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. 
Exiting loop
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    note: (skipping 2 expansions in backtrace; use 
-fmacro-backtrace-limit=0 to see all)
    include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
            _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
            ^
    include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
            __compiletime_assert(condition, msg, prefix, suffix)
            ^
    include/linux/compiler_types.h:306:2: note: expanded from macro 
'__compiletime_assert'
            do { 
     \
            ^
    drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. 
Execution continues on line 619
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:2: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
            ^
    drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
            init_vp_index(newchannel);
            ^~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without 
an initial value
            u32 target_cpu;
            ^~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
                (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
                (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                          ^~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:737:7: note: Calling 'alloc_cpumask_var'
                !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    include/linux/cpumask.h:740:2: note: Returning the value 1, which 
participates in a condition later
            return true;
            ^~~~~~~~~~~
    drivers/hv/channel_mgmt.c:737:7: note: Returning from 
'alloc_cpumask_var'
                !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c8 K. Y. Srinivasan         2012-12-01  714  a119845f6e98c8 
K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  716   * Starting 
with Win8, we can statically distribute the incoming
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  717   * channel 
interrupt load by binding a channel to VCPU.
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  719   * For pre-win8 
hosts or non-performance critical channels we assign the
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  720)  * 
VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  722)  * Starting 
with win8, performance critical channels will be distributed
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  723)  * evenly among 
all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  724)  * we will 
assign the CPU based on a simple round robin scheme.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  726) static void 
init_vp_index(struct vmbus_channel *channel)
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn 
= hv_is_perf_channel(channel);
7c9ff3deeee61b Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = 
num_online_cpus();
25355252607ca2 Dexuan Cui               2018-09-23  730  	cpumask_var_t 
available_mask;
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  731  	struct cpumask 
*alloced_mask;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  734  a119845f6e98c8 
K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == 
VERSION_WS2008) ||
25355252607ca2 Dexuan Cui               2018-09-23  736  	 
(vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca2 Dexuan Cui               2018-09-23  737  	 
!alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  739  		 * Prior to 
win8, all channel interrupts are
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered 
on VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  741  		 * Also if 
the channel is not a performance critical
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, 
bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  743) 		 * In case 
alloc_cpumask_var() fails, bind it to
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  744) 		 * 
VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  746) 	 
channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  748) 		 
hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  751  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = 
next_numa_node_id++;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  755) 			if 
(numa_node == nr_node_ids) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  756) 			 
next_numa_node_id = 0;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  759) 			if 
(cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask 
= &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  764  9f01ec53458d9e 
K. Y. Srinivasan         2015-08-05  765  		if 
(cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  766) 		 
cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  768  			 * We have 
cycled through all the CPUs in the node;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  769  			 * reset the 
alloced map.
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  771  		 
cpumask_clear(alloced_mask);
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  773  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, 
alloced_mask,
7c9ff3deeee61b Haiyang Zhang            2021-07-16  775  			 
cpumask_of_node(numa_node));
79fd8e706637a5 Vitaly Kuznetsov         2016-01-27  776  8ef4c4abbbcdcd 
Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = 
cpumask_first(available_mask);
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  778) 	 
cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  779  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  780  		if 
(channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b Haiyang Zhang            2021-07-16  781  		    i > ncpu 
|| !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b Haiyang Zhang            2021-07-16  784  8ef4c4abbbcdcd 
Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca2 Dexuan Cui               2018-09-23  786  25355252607ca2 
Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  789
:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: 
Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org


[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29581 bytes --]

[-- Attachment #3: Attached Message Part --]
[-- Type: text/plain, Size: 150 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org


^ permalink raw reply	[flat|nested] 10+ messages in thread

* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-07-26  3:43   ` kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-07-26  3:43 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 20971 bytes --]


Hi Haiyang,

First bad commit (maybe != root cause):

tree: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d8079fac168168b25677dc16c00ffaf9fb7df723
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix 
duplicate CPU assignments within a device
date:   6 days ago
:::::: branch date: 11 hours ago
:::::: commit date: 6 days ago
config: x86_64-randconfig-c001-20210725 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 
3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
reproduce (this is a W=1 build):
         wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross 
-O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # install x86_64 cross compiling tool for clang build
         # apt-get install binutils-x86-64-linux-gnu
         # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
         git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
         git fetch --no-tags linus master
         git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
         # save the attached .config to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross 
clang-analyzer ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1601:3: note: Taking false branch
                    if (field->logical_minimum < 0) /* signed values */
                    ^
    drivers/hid/hid-core.c:1605:44: note: Passing value via 4th 
parameter 'n'
                            implement(hid, data, offset + n * size, size,
                                                                    ^~~~
    drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
                            implement(hid, data, offset + n * size, size,
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
            if (unlikely(n > 32)) {
                         ^
    include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
    # define unlikely(x)    __builtin_expect(!!(x), 0)
                                                ^
    drivers/hid/hid-core.c:1421:2: note: Taking false branch
            if (unlikely(n > 32)) {
            ^
    drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
            } else if (n < 32) {
                       ^~~~~~
    drivers/hid/hid-core.c:1425:9: note: Taking false branch
            } else if (n < 32) {
                   ^
    drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd 
parameter 'n'
            __implement(report, offset, n, value);
                                        ^
    drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
            __implement(report, offset, n, value);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
            while (n - bits_to_set >= 0) {
                   ^~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1400:2: note: Loop condition is false. 
Execution continues on line 1411
            while (n - bits_to_set >= 0) {
            ^
    drivers/hid/hid-core.c:1411:6: note: 'n' is 32
            if (n) {
                ^
    drivers/hid/hid-core.c:1411:2: note: Taking true branch
            if (n) {
            ^
    drivers/hid/hid-core.c:1412:22: note: The result of the left shift 
is undefined due to shifting by '32', which is greater or equal to the 
width of type 'unsigned int'
                    u8 bit_mask = ((1U << n) - 1);
                                       ^  ~
    drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is 
never read [clang-analyzer-deadcode.DeadStores]
                    len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never read
                    len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
    Suppressed 6 warnings (6 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
    Suppressed 6 warnings (6 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    7 warnings generated.
    Suppressed 7 warnings (7 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    5 warnings generated.
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    4 warnings generated.
    Suppressed 4 warnings (4 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    3 warnings generated.
    Suppressed 3 warnings (3 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    9 warnings generated.
    Suppressed 9 warnings (8 in non-user code, 1 with check filters).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    5 warnings generated.
    Suppressed 5 warnings (5 in non-user code).
    Use -header-filter=.* to display errors from all non-system headers. 
Use -system-headers to display errors from system headers as well.
    6 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
            channel->target_cpu = target_cpu;
                                ^
    drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
            BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) 
&&   \
                                                                       ^
    drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    note: (skipping 2 expansions in backtrace; use 
-fmacro-backtrace-limit=0 to see all)
    include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
            _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
            ^
    include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
            __compiletime_assert(condition, msg, prefix, suffix)
            ^
    include/linux/compiler_types.h:308:3: note: expanded from macro 
'__compiletime_assert'
                    if (!(condition)) 
     \
                    ^
    drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. 
Exiting loop
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:13: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
                       ^
    include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
            list_entry((ptr)->next, type, member)
            ^
    include/linux/list.h:511:2: note: expanded from macro 'list_entry'
            container_of(ptr, type, member)
            ^
    note: (skipping 2 expansions in backtrace; use 
-fmacro-backtrace-limit=0 to see all)
    include/linux/compiler_types.h:328:2: note: expanded from macro 
'compiletime_assert'
            _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
            ^
    include/linux/compiler_types.h:316:2: note: expanded from macro 
'_compiletime_assert'
            __compiletime_assert(condition, msg, prefix, suffix)
            ^
    include/linux/compiler_types.h:306:2: note: expanded from macro 
'__compiletime_assert'
            do { 
     \
            ^
    drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. 
Execution continues on line 619
            list_for_each_entry(channel, &vmbus_connection.chn_list, 
listentry) {
            ^
    include/linux/list.h:628:2: note: expanded from macro 
'list_for_each_entry'
            for (pos = list_first_entry(head, typeof(*pos), member); 
     \
            ^
    drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
            init_vp_index(newchannel);
            ^~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without 
an initial value
            u32 target_cpu;
            ^~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
                (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
                (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                          ^~~~~~~~~
    drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
            if ((vmbus_proto_version == VERSION_WS2008) ||
                ^
    drivers/hv/channel_mgmt.c:737:7: note: Calling 'alloc_cpumask_var'
                !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    include/linux/cpumask.h:740:2: note: Returning the value 1, which 
participates in a condition later
            return true;
            ^~~~~~~~~~~
    drivers/hv/channel_mgmt.c:737:7: note: Returning from 
'alloc_cpumask_var'
                !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c8 K. Y. Srinivasan         2012-12-01  714  a119845f6e98c8 
K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  716   * Starting 
with Win8, we can statically distribute the incoming
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  717   * channel 
interrupt load by binding a channel to VCPU.
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  719   * For pre-win8 
hosts or non-performance critical channels we assign the
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  720)  * 
VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  722)  * Starting 
with win8, performance critical channels will be distributed
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  723)  * evenly among 
all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  724)  * we will 
assign the CPU based on a simple round robin scheme.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  726) static void 
init_vp_index(struct vmbus_channel *channel)
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn 
= hv_is_perf_channel(channel);
7c9ff3deeee61b Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = 
num_online_cpus();
25355252607ca2 Dexuan Cui               2018-09-23  730  	cpumask_var_t 
available_mask;
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  731  	struct cpumask 
*alloced_mask;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  734  a119845f6e98c8 
K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == 
VERSION_WS2008) ||
25355252607ca2 Dexuan Cui               2018-09-23  736  	 
(vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca2 Dexuan Cui               2018-09-23  737  	 
!alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  739  		 * Prior to 
win8, all channel interrupts are
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered 
on VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  741  		 * Also if 
the channel is not a performance critical
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, 
bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  743) 		 * In case 
alloc_cpumask_var() fails, bind it to
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  744) 		 * 
VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  746) 	 
channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  748) 		 
hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  751  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = 
next_numa_node_id++;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  755) 			if 
(numa_node == nr_node_ids) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  756) 			 
next_numa_node_id = 0;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  759) 			if 
(cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask 
= &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  764  9f01ec53458d9e 
K. Y. Srinivasan         2015-08-05  765  		if 
(cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  766) 		 
cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  768  			 * We have 
cycled through all the CPUs in the node;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  769  			 * reset the 
alloced map.
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  771  		 
cpumask_clear(alloced_mask);
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  773  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, 
alloced_mask,
7c9ff3deeee61b Haiyang Zhang            2021-07-16  775  			 
cpumask_of_node(numa_node));
79fd8e706637a5 Vitaly Kuznetsov         2016-01-27  776  8ef4c4abbbcdcd 
Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = 
cpumask_first(available_mask);
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  778) 	 
cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  779  7c9ff3deeee61b 
Haiyang Zhang            2021-07-16  780  		if 
(channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b Haiyang Zhang            2021-07-16  781  		    i > ncpu 
|| !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b Haiyang Zhang            2021-07-16  784  8ef4c4abbbcdcd 
Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca2 Dexuan Cui               2018-09-23  786  25355252607ca2 
Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  789
:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: 
Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org


[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 29581 bytes --]

[-- Attachment #3: AttachedMessagePart.ksh --]
[-- Type: text/plain, Size: 150 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
  2021-07-26  3:43   ` kernel test robot
  (?)
  (?)
@ 2021-07-26 16:02   ` Haiyang Zhang
  2021-07-28  8:32       ` Chen, Rong A
  -1 siblings, 1 reply; 10+ messages in thread
From: Haiyang Zhang @ 2021-07-26 16:02 UTC (permalink / raw
  To: kernel test robot; +Cc: kbuild-all@lists.01.org, LKML, Wei Liu, Michael Kelley



> -----Original Message-----
> From: kernel test robot <rong.a.chen@intel.com>
> Sent: Sunday, July 25, 2021 11:43 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: kbuild-all@lists.01.org; LKML <linux-kernel@vger.kernel.org>; Wei
> Liu <wei.liu@kernel.org>; Michael Kelley <mikelley@microsoft.com>
> Subject: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is
> garbage or undefined [clang-analyzer-core.uninitialized.Assign]
> 
> 
> Hi Haiyang,
> 
> First bad commit (maybe != root cause):
> 
> tree:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
> aXSdZV0%3D&amp;reserved=0 master
> head:   d8079fac168168b25677dc16c00ffaf9fb7df723
> commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix
> duplicate CPU assignments within a device
> date:   6 days ago
> :::::: branch date: 11 hours ago
> :::::: commit date: 6 days ago
> config: x86_64-randconfig-c001-20210725 (attached as .config)
> compiler: clang version 13.0.0
> (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
> b.com%2Fllvm%2Fllvm-
> project&amp;data=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29b
> f308d94fe78490%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585
> 035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=MKdTDUGKunqVOWEwafejDKuW0mpeN
> aP1ssqiv4SBvzQ%3D&amp;reserved=0
> 3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
> reproduce (this is a W=1 build):
>          wget
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.gi
> thubusercontent.com%2Fintel%2Flkp-
> tests%2Fmaster%2Fsbin%2Fmake.cross&amp;data=04%7C01%7Chaiyangz%40microso
> ft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf86f141af91ab2d7cd011
> db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj
> AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gu
> Hq8MagK88xMw%2F6ZxmhQExnmLoIlYLma4QR1gmUYdM%3D&amp;reserved=0
> -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # install x86_64 cross compiling tool for clang build
>          # apt-get install binutils-x86-64-linux-gnu
>          #
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fcom
> mit%2F%3Fid%3D7c9ff3deeee61b253715dcf968a6307af148c9b2&amp;data=04%7C01%
> 7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf
> 86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbG
> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
> %7C1000&amp;sdata=N24YX%2FPLzONY5gKOu1U93%2B7uK4jm%2BIQYZzfA6z8FPHo%3D&a
> mp;reserved=0
>          git remote add linus
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
> aXSdZV0%3D&amp;reserved=0
>          git fetch --no-tags linus master
>          git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
> clang-analyzer ARCH=x86_64 If you fix the issue, kindly add following
> tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 
> clang-analyzer warnings: (new ones prefixed by >>)
>                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1601:3: note: Taking false branch
>                     if (field->logical_minimum < 0) /* signed values */
>                     ^
>     drivers/hid/hid-core.c:1605:44: note: Passing value via 4th
> parameter 'n'
>                             implement(hid, data, offset + n * size, size,
>                                                                     ^~~~
>     drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
>                             implement(hid, data, offset + n * size, size,
> 
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
>             if (unlikely(n > 32)) {
>                          ^
>     include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
>     # define unlikely(x)    __builtin_expect(!!(x), 0)
>                                                 ^
>     drivers/hid/hid-core.c:1421:2: note: Taking false branch
>             if (unlikely(n > 32)) {
>             ^
>     drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
>             } else if (n < 32) {
>                        ^~~~~~
>     drivers/hid/hid-core.c:1425:9: note: Taking false branch
>             } else if (n < 32) {
>                    ^
>     drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd
> parameter 'n'
>             __implement(report, offset, n, value);
>                                         ^
>     drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
>             __implement(report, offset, n, value);
>             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
>             while (n - bits_to_set >= 0) {
>                    ^~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1400:2: note: Loop condition is false.
> Execution continues on line 1411
>             while (n - bits_to_set >= 0) {
>             ^
>     drivers/hid/hid-core.c:1411:6: note: 'n' is 32
>             if (n) {
>                 ^
>     drivers/hid/hid-core.c:1411:2: note: Taking true branch
>             if (n) {
>             ^
>     drivers/hid/hid-core.c:1412:22: note: The result of the left shift
> is undefined due to shifting by '32', which is greater or equal to the
> width of type 'unsigned int'
>                     u8 bit_mask = ((1U << n) - 1);
>                                        ^  ~
>     drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is
> never read [clang-analyzer-deadcode.DeadStores]
>                     len += sprintf(buf + len, "%shidraw%d", len ? "," :
> "",
>                     ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never
> read
>                     len += sprintf(buf + len, "%shidraw%d", len ? "," :
> "",
>                     ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
>     Suppressed 6 warnings (6 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
>     Suppressed 6 warnings (6 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     7 warnings generated.
>     Suppressed 7 warnings (7 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     5 warnings generated.
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     3 warnings generated.
>     Suppressed 3 warnings (3 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     9 warnings generated.
>     Suppressed 9 warnings (8 in non-user code, 1 with check filters).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     5 warnings generated.
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
> >> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage
> >> or undefined [clang-analyzer-core.uninitialized.Assign]
>             channel->target_cpu = target_cpu;
>                                 ^

The for-loop before the assignment is always executed, 
because ncpu = num_online_cpus() > 0:
	for (i = 1; i <= ncpu + 1; i++) {

So the variable is assigned before Line 785:
		target_cpu = cpumask_first(available_mask);

And, the following code ensures the available_mask is not empty:
		if (cpumask_weight(alloced_mask) ==
		    cpumask_weight(cpumask_of_node(numa_node))) {
			/*
			 * We have cycled through all the CPUs in the node;
			 * reset the alloced map.
			 */
			cpumask_clear(alloced_mask);
		}

So the robot warning above can be ignored.

Thanks,
- Haiyang


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
  2021-07-26  3:43   ` kernel test robot
  (?)
@ 2021-07-26 16:02   ` Haiyang Zhang
  -1 siblings, 0 replies; 10+ messages in thread
From: Haiyang Zhang @ 2021-07-26 16:02 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 11641 bytes --]



> -----Original Message-----
> From: kernel test robot <rong.a.chen@intel.com>
> Sent: Sunday, July 25, 2021 11:43 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: kbuild-all(a)lists.01.org; LKML <linux-kernel@vger.kernel.org>; Wei
> Liu <wei.liu@kernel.org>; Michael Kelley <mikelley@microsoft.com>
> Subject: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is
> garbage or undefined [clang-analyzer-core.uninitialized.Assign]
> 
> 
> Hi Haiyang,
> 
> First bad commit (maybe != root cause):
> 
> tree:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
> aXSdZV0%3D&amp;reserved=0 master
> head:   d8079fac168168b25677dc16c00ffaf9fb7df723
> commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix
> duplicate CPU assignments within a device
> date:   6 days ago
> :::::: branch date: 11 hours ago
> :::::: commit date: 6 days ago
> config: x86_64-randconfig-c001-20210725 (attached as .config)
> compiler: clang version 13.0.0
> (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
> b.com%2Fllvm%2Fllvm-
> project&amp;data=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29b
> f308d94fe78490%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585
> 035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=MKdTDUGKunqVOWEwafejDKuW0mpeN
> aP1ssqiv4SBvzQ%3D&amp;reserved=0
> 3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
> reproduce (this is a W=1 build):
>          wget
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.gi
> thubusercontent.com%2Fintel%2Flkp-
> tests%2Fmaster%2Fsbin%2Fmake.cross&amp;data=04%7C01%7Chaiyangz%40microso
> ft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf86f141af91ab2d7cd011
> db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj
> AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gu
> Hq8MagK88xMw%2F6ZxmhQExnmLoIlYLma4QR1gmUYdM%3D&amp;reserved=0
> -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # install x86_64 cross compiling tool for clang build
>          # apt-get install binutils-x86-64-linux-gnu
>          #
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fcom
> mit%2F%3Fid%3D7c9ff3deeee61b253715dcf968a6307af148c9b2&amp;data=04%7C01%
> 7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf
> 86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbG
> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
> %7C1000&amp;sdata=N24YX%2FPLzONY5gKOu1U93%2B7uK4jm%2BIQYZzfA6z8FPHo%3D&a
> mp;reserved=0
>          git remote add linus
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
> aXSdZV0%3D&amp;reserved=0
>          git fetch --no-tags linus master
>          git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
>          # save the attached .config to linux build tree
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
> clang-analyzer ARCH=x86_64 If you fix the issue, kindly add following
> tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 
> clang-analyzer warnings: (new ones prefixed by >>)
>                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1601:3: note: Taking false branch
>                     if (field->logical_minimum < 0) /* signed values */
>                     ^
>     drivers/hid/hid-core.c:1605:44: note: Passing value via 4th
> parameter 'n'
>                             implement(hid, data, offset + n * size, size,
>                                                                     ^~~~
>     drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
>                             implement(hid, data, offset + n * size, size,
> 
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
>             if (unlikely(n > 32)) {
>                          ^
>     include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
>     # define unlikely(x)    __builtin_expect(!!(x), 0)
>                                                 ^
>     drivers/hid/hid-core.c:1421:2: note: Taking false branch
>             if (unlikely(n > 32)) {
>             ^
>     drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
>             } else if (n < 32) {
>                        ^~~~~~
>     drivers/hid/hid-core.c:1425:9: note: Taking false branch
>             } else if (n < 32) {
>                    ^
>     drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd
> parameter 'n'
>             __implement(report, offset, n, value);
>                                         ^
>     drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
>             __implement(report, offset, n, value);
>             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
>             while (n - bits_to_set >= 0) {
>                    ^~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1400:2: note: Loop condition is false.
> Execution continues on line 1411
>             while (n - bits_to_set >= 0) {
>             ^
>     drivers/hid/hid-core.c:1411:6: note: 'n' is 32
>             if (n) {
>                 ^
>     drivers/hid/hid-core.c:1411:2: note: Taking true branch
>             if (n) {
>             ^
>     drivers/hid/hid-core.c:1412:22: note: The result of the left shift
> is undefined due to shifting by '32', which is greater or equal to the
> width of type 'unsigned int'
>                     u8 bit_mask = ((1U << n) - 1);
>                                        ^  ~
>     drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is
> never read [clang-analyzer-deadcode.DeadStores]
>                     len += sprintf(buf + len, "%shidraw%d", len ? "," :
> "",
>                     ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never
> read
>                     len += sprintf(buf + len, "%shidraw%d", len ? "," :
> "",
>                     ^
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
>     Suppressed 6 warnings (6 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
>     Suppressed 6 warnings (6 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     7 warnings generated.
>     Suppressed 7 warnings (7 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     5 warnings generated.
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     4 warnings generated.
>     Suppressed 4 warnings (4 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     3 warnings generated.
>     Suppressed 3 warnings (3 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     9 warnings generated.
>     Suppressed 9 warnings (8 in non-user code, 1 with check filters).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     5 warnings generated.
>     Suppressed 5 warnings (5 in non-user code).
>     Use -header-filter=.* to display errors from all non-system headers.
> Use -system-headers to display errors from system headers as well.
>     6 warnings generated.
> >> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage
> >> or undefined [clang-analyzer-core.uninitialized.Assign]
>             channel->target_cpu = target_cpu;
>                                 ^

The for-loop before the assignment is always executed, 
because ncpu = num_online_cpus() > 0:
	for (i = 1; i <= ncpu + 1; i++) {

So the variable is assigned before Line 785:
		target_cpu = cpumask_first(available_mask);

And, the following code ensures the available_mask is not empty:
		if (cpumask_weight(alloced_mask) ==
		    cpumask_weight(cpumask_of_node(numa_node))) {
			/*
			 * We have cycled through all the CPUs in the node;
			 * reset the alloced map.
			 */
			cpumask_clear(alloced_mask);
		}

So the robot warning above can be ignored.

Thanks,
- Haiyang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
  2021-07-26 16:02   ` Haiyang Zhang
@ 2021-07-28  8:32       ` Chen, Rong A
  0 siblings, 0 replies; 10+ messages in thread
From: Chen, Rong A @ 2021-07-28  8:32 UTC (permalink / raw
  To: Haiyang Zhang; +Cc: kbuild-all@lists.01.org, LKML, Wei Liu, Michael Kelley



On 7/27/2021 12:02 AM, Haiyang Zhang wrote:
> 
> 
>> -----Original Message-----
>> From: kernel test robot <rong.a.chen@intel.com>
>> Sent: Sunday, July 25, 2021 11:43 PM
>> To: Haiyang Zhang <haiyangz@microsoft.com>
>> Cc: kbuild-all@lists.01.org; LKML <linux-kernel@vger.kernel.org>; Wei
>> Liu <wei.liu@kernel.org>; Michael Kelley <mikelley@microsoft.com>
>> Subject: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is
>> garbage or undefined [clang-analyzer-core.uninitialized.Assign]
>>
>>
>> Hi Haiyang,
>>
>> First bad commit (maybe != root cause):
>>
>> tree:
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
>> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
>> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
>> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
>> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
>> aXSdZV0%3D&amp;reserved=0 master
>> head:   d8079fac168168b25677dc16c00ffaf9fb7df723
>> commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix
>> duplicate CPU assignments within a device
>> date:   6 days ago
>> :::::: branch date: 11 hours ago
>> :::::: commit date: 6 days ago
>> config: x86_64-randconfig-c001-20210725 (attached as .config)
>> compiler: clang version 13.0.0
>> (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
>> b.com%2Fllvm%2Fllvm-
>> project&amp;data=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29b
>> f308d94fe78490%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585
>> 035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
>> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=MKdTDUGKunqVOWEwafejDKuW0mpeN
>> aP1ssqiv4SBvzQ%3D&amp;reserved=0
>> 3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
>> reproduce (this is a W=1 build):
>>           wget
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.gi
>> thubusercontent.com%2Fintel%2Flkp-
>> tests%2Fmaster%2Fsbin%2Fmake.cross&amp;data=04%7C01%7Chaiyangz%40microso
>> ft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf86f141af91ab2d7cd011
>> db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj
>> AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gu
>> Hq8MagK88xMw%2F6ZxmhQExnmLoIlYLma4QR1gmUYdM%3D&amp;reserved=0
>> -O ~/bin/make.cross
>>           chmod +x ~/bin/make.cross
>>           # install x86_64 cross compiling tool for clang build
>>           # apt-get install binutils-x86-64-linux-gnu
>>           #
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fcom
>> mit%2F%3Fid%3D7c9ff3deeee61b253715dcf968a6307af148c9b2&amp;data=04%7C01%
>> 7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf
>> 86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbG
>> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
>> %7C1000&amp;sdata=N24YX%2FPLzONY5gKOu1U93%2B7uK4jm%2BIQYZzfA6z8FPHo%3D&a
>> mp;reserved=0
>>           git remote add linus
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
>> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
>> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
>> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
>> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
>> aXSdZV0%3D&amp;reserved=0
>>           git fetch --no-tags linus master
>>           git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
>>           # save the attached .config to linux build tree
>>           COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
>> clang-analyzer ARCH=x86_64 If you fix the issue, kindly add following
>> tag as appropriate
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>>
>> clang-analyzer warnings: (new ones prefixed by >>)
>>                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1601:3: note: Taking false branch
>>                      if (field->logical_minimum < 0) /* signed values */
>>                      ^
>>      drivers/hid/hid-core.c:1605:44: note: Passing value via 4th
>> parameter 'n'
>>                              implement(hid, data, offset + n * size, size,
>>                                                                      ^~~~
>>      drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
>>                              implement(hid, data, offset + n * size, size,
>>
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
>>              if (unlikely(n > 32)) {
>>                           ^
>>      include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
>>      # define unlikely(x)    __builtin_expect(!!(x), 0)
>>                                                  ^
>>      drivers/hid/hid-core.c:1421:2: note: Taking false branch
>>              if (unlikely(n > 32)) {
>>              ^
>>      drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
>>              } else if (n < 32) {
>>                         ^~~~~~
>>      drivers/hid/hid-core.c:1425:9: note: Taking false branch
>>              } else if (n < 32) {
>>                     ^
>>      drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd
>> parameter 'n'
>>              __implement(report, offset, n, value);
>>                                          ^
>>      drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
>>              __implement(report, offset, n, value);
>>              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
>>              while (n - bits_to_set >= 0) {
>>                     ^~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1400:2: note: Loop condition is false.
>> Execution continues on line 1411
>>              while (n - bits_to_set >= 0) {
>>              ^
>>      drivers/hid/hid-core.c:1411:6: note: 'n' is 32
>>              if (n) {
>>                  ^
>>      drivers/hid/hid-core.c:1411:2: note: Taking true branch
>>              if (n) {
>>              ^
>>      drivers/hid/hid-core.c:1412:22: note: The result of the left shift
>> is undefined due to shifting by '32', which is greater or equal to the
>> width of type 'unsigned int'
>>                      u8 bit_mask = ((1U << n) - 1);
>>                                         ^  ~
>>      drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is
>> never read [clang-analyzer-deadcode.DeadStores]
>>                      len += sprintf(buf + len, "%shidraw%d", len ? "," :
>> "",
>>                      ^
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never
>> read
>>                      len += sprintf(buf + len, "%shidraw%d", len ? "," :
>> "",
>>                      ^
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>      Suppressed 6 warnings (6 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>      Suppressed 6 warnings (6 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      7 warnings generated.
>>      Suppressed 7 warnings (7 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      5 warnings generated.
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      3 warnings generated.
>>      Suppressed 3 warnings (3 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      9 warnings generated.
>>      Suppressed 9 warnings (8 in non-user code, 1 with check filters).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      5 warnings generated.
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage
>>>> or undefined [clang-analyzer-core.uninitialized.Assign]
>>              channel->target_cpu = target_cpu;
>>                                  ^
> 
> The for-loop before the assignment is always executed,
> because ncpu = num_online_cpus() > 0:
> 	for (i = 1; i <= ncpu + 1; i++) {
> 
> So the variable is assigned before Line 785:
> 		target_cpu = cpumask_first(available_mask);
> 
> And, the following code ensures the available_mask is not empty:
> 		if (cpumask_weight(alloced_mask) ==
> 		    cpumask_weight(cpumask_of_node(numa_node))) {
> 			/*
> 			 * We have cycled through all the CPUs in the node;
> 			 * reset the alloced map.
> 			 */
> 			cpumask_clear(alloced_mask);
> 		}
> 
> So the robot warning above can be ignored.

Thanks for the detailed explanation, please just ignore it.

Best Regards,
Rong Chen

> 
> Thanks,
> - Haiyang
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-07-28  8:32       ` Chen, Rong A
  0 siblings, 0 replies; 10+ messages in thread
From: Chen, Rong A @ 2021-07-28  8:32 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 12144 bytes --]



On 7/27/2021 12:02 AM, Haiyang Zhang wrote:
> 
> 
>> -----Original Message-----
>> From: kernel test robot <rong.a.chen@intel.com>
>> Sent: Sunday, July 25, 2021 11:43 PM
>> To: Haiyang Zhang <haiyangz@microsoft.com>
>> Cc: kbuild-all(a)lists.01.org; LKML <linux-kernel@vger.kernel.org>; Wei
>> Liu <wei.liu@kernel.org>; Michael Kelley <mikelley@microsoft.com>
>> Subject: drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is
>> garbage or undefined [clang-analyzer-core.uninitialized.Assign]
>>
>>
>> Hi Haiyang,
>>
>> First bad commit (maybe != root cause):
>>
>> tree:
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
>> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
>> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
>> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
>> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
>> aXSdZV0%3D&amp;reserved=0 master
>> head:   d8079fac168168b25677dc16c00ffaf9fb7df723
>> commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix
>> duplicate CPU assignments within a device
>> date:   6 days ago
>> :::::: branch date: 11 hours ago
>> :::::: commit date: 6 days ago
>> config: x86_64-randconfig-c001-20210725 (attached as .config)
>> compiler: clang version 13.0.0
>> (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithu
>> b.com%2Fllvm%2Fllvm-
>> project&amp;data=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29b
>> f308d94fe78490%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585
>> 035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
>> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=MKdTDUGKunqVOWEwafejDKuW0mpeN
>> aP1ssqiv4SBvzQ%3D&amp;reserved=0
>> 3f2c1e99e44d028d5e9dd685f3c568f2661f2f68)
>> reproduce (this is a W=1 build):
>>           wget
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.gi
>> thubusercontent.com%2Fintel%2Flkp-
>> tests%2Fmaster%2Fsbin%2Fmake.cross&amp;data=04%7C01%7Chaiyangz%40microso
>> ft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf86f141af91ab2d7cd011
>> db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj
>> AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=gu
>> Hq8MagK88xMw%2F6ZxmhQExnmLoIlYLma4QR1gmUYdM%3D&amp;reserved=0
>> -O ~/bin/make.cross
>>           chmod +x ~/bin/make.cross
>>           # install x86_64 cross compiling tool for clang build
>>           # apt-get install binutils-x86-64-linux-gnu
>>           #
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fcom
>> mit%2F%3Fid%3D7c9ff3deeee61b253715dcf968a6307af148c9b2&amp;data=04%7C01%
>> 7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe78490%7C72f988bf
>> 86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnknown%7CTWFpbG
>> Zsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
>> %7C1000&amp;sdata=N24YX%2FPLzONY5gKOu1U93%2B7uK4jm%2BIQYZzfA6z8FPHo%3D&a
>> mp;reserved=0
>>           git remote add linus
>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ke
>> rnel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;d
>> ata=04%7C01%7Chaiyangz%40microsoft.com%7Cb1a7f087851b48a29bf308d94fe7849
>> 0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637628680585035821%7CUnkn
>> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLC
>> JXVCI6Mn0%3D%7C1000&amp;sdata=6LkKnX%2BXhjmhh4m%2BzJ7y0JeQcwvwHw8NZP%2Bv
>> aXSdZV0%3D&amp;reserved=0
>>           git fetch --no-tags linus master
>>           git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
>>           # save the attached .config to linux build tree
>>           COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
>> clang-analyzer ARCH=x86_64 If you fix the issue, kindly add following
>> tag as appropriate
>> Reported-by: kernel test robot <lkp@intel.com>
>>
>>
>> clang-analyzer warnings: (new ones prefixed by >>)
>>                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1601:3: note: Taking false branch
>>                      if (field->logical_minimum < 0) /* signed values */
>>                      ^
>>      drivers/hid/hid-core.c:1605:44: note: Passing value via 4th
>> parameter 'n'
>>                              implement(hid, data, offset + n * size, size,
>>                                                                      ^~~~
>>      drivers/hid/hid-core.c:1605:4: note: Calling 'implement'
>>                              implement(hid, data, offset + n * size, size,
>>
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1421:15: note: Assuming 'n' is <= 32
>>              if (unlikely(n > 32)) {
>>                           ^
>>      include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
>>      # define unlikely(x)    __builtin_expect(!!(x), 0)
>>                                                  ^
>>      drivers/hid/hid-core.c:1421:2: note: Taking false branch
>>              if (unlikely(n > 32)) {
>>              ^
>>      drivers/hid/hid-core.c:1425:13: note: Assuming 'n' is >= 32
>>              } else if (n < 32) {
>>                         ^~~~~~
>>      drivers/hid/hid-core.c:1425:9: note: Taking false branch
>>              } else if (n < 32) {
>>                     ^
>>      drivers/hid/hid-core.c:1437:30: note: Passing the value 32 via 3rd
>> parameter 'n'
>>              __implement(report, offset, n, value);
>>                                          ^
>>      drivers/hid/hid-core.c:1437:2: note: Calling '__implement'
>>              __implement(report, offset, n, value);
>>              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1400:9: note: Assuming the condition is false
>>              while (n - bits_to_set >= 0) {
>>                     ^~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1400:2: note: Loop condition is false.
>> Execution continues on line 1411
>>              while (n - bits_to_set >= 0) {
>>              ^
>>      drivers/hid/hid-core.c:1411:6: note: 'n' is 32
>>              if (n) {
>>                  ^
>>      drivers/hid/hid-core.c:1411:2: note: Taking true branch
>>              if (n) {
>>              ^
>>      drivers/hid/hid-core.c:1412:22: note: The result of the left shift
>> is undefined due to shifting by '32', which is greater or equal to the
>> width of type 'unsigned int'
>>                      u8 bit_mask = ((1U << n) - 1);
>>                                         ^  ~
>>      drivers/hid/hid-core.c:1984:3: warning: Value stored to 'len' is
>> never read [clang-analyzer-deadcode.DeadStores]
>>                      len += sprintf(buf + len, "%shidraw%d", len ? "," :
>> "",
>>                      ^
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      drivers/hid/hid-core.c:1984:3: note: Value stored to 'len' is never
>> read
>>                      len += sprintf(buf + len, "%shidraw%d", len ? "," :
>> "",
>>                      ^
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>      Suppressed 6 warnings (6 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>      Suppressed 6 warnings (6 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      7 warnings generated.
>>      Suppressed 7 warnings (7 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      5 warnings generated.
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      4 warnings generated.
>>      Suppressed 4 warnings (4 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      3 warnings generated.
>>      Suppressed 3 warnings (3 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      9 warnings generated.
>>      Suppressed 9 warnings (8 in non-user code, 1 with check filters).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      5 warnings generated.
>>      Suppressed 5 warnings (5 in non-user code).
>>      Use -header-filter=.* to display errors from all non-system headers.
>> Use -system-headers to display errors from system headers as well.
>>      6 warnings generated.
>>>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage
>>>> or undefined [clang-analyzer-core.uninitialized.Assign]
>>              channel->target_cpu = target_cpu;
>>                                  ^
> 
> The for-loop before the assignment is always executed,
> because ncpu = num_online_cpus() > 0:
> 	for (i = 1; i <= ncpu + 1; i++) {
> 
> So the variable is assigned before Line 785:
> 		target_cpu = cpumask_first(available_mask);
> 
> And, the following code ensures the available_mask is not empty:
> 		if (cpumask_weight(alloced_mask) ==
> 		    cpumask_weight(cpumask_of_node(numa_node))) {
> 			/*
> 			 * We have cycled through all the CPUs in the node;
> 			 * reset the alloced map.
> 			 */
> 			cpumask_clear(alloced_mask);
> 		}
> 
> So the robot warning above can be ignored.

Thanks for the detailed explanation, please just ignore it.

Best Regards,
Rong Chen

> 
> Thanks,
> - Haiyang
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-12-09  0:18 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-12-09  0:18 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 20964 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Haiyang Zhang <haiyangz@microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2a987e65025e2b79c6d453b78cb5985ac6e5eb26
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix duplicate CPU assignments within a device
date:   5 months ago
:::::: branch date: 25 hours ago
:::::: commit date: 5 months ago
config: x86_64-randconfig-c007-20211202 (https://download.01.org/0day-ci/archive/20211209/202112090837.muDKpeym-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b553297ef3ee4dc2119d5429adf3072e90fac38)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
   include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:2011:10: note: '?' condition is true
                   mdeg = clamp_val(mdeg, IDT_TEMP_MIN_OFFSET,
                          ^
   include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
   #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
                                  ^
   include/linux/minmax.h:124:36: note: expanded from macro 'clamp_t'
   #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
                                      ^
   include/linux/minmax.h:104:27: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ^
   include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^
   include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^
   include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^
   drivers/ntb/hw/idt/ntb_hw_idt.c:2016:2: note: Calling 'idt_write_temp'
           idt_write_temp(ndev, type, mdeg);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:1938:8: note: Calling 'idt_temp_get_fmt'
           fmt = idt_temp_get_fmt(val);
                 ^~~~~~~~~~~~~~~~~~~~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:1858:10: note: Calling 'idt_get_deg'
           return (idt_get_deg(mdegC) << 1) | (idt_get_deg_frac(mdegC) ? 1 : 0);
                   ^~~~~~~~~~~~~~~~~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:1836:2: note: Returning the value -64
           return mdegC / 1000;
           ^~~~~~~~~~~~~~~~~~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:1858:10: note: Returning from 'idt_get_deg'
           return (idt_get_deg(mdegC) << 1) | (idt_get_deg_frac(mdegC) ? 1 : 0);
                   ^~~~~~~~~~~~~~~~~~
   drivers/ntb/hw/idt/ntb_hw_idt.c:1858:29: note: The result of the left shift is undefined because the left operand is negative
           return (idt_get_deg(mdegC) << 1) | (idt_get_deg_frac(mdegC) ? 1 : 0);
                   ~~~~~~~~~~~~~~~~~~ ^
   Suppressed 8 warnings (5 in non-user code, 3 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   drivers/char/agp/amd64-agp.c:336:2: warning: Value stored to 'i' is never read [clang-analyzer-deadcode.DeadStores]
           i = 0;
           ^   ~
   drivers/char/agp/amd64-agp.c:336:2: note: Value stored to 'i' is never read
           i = 0;
           ^   ~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   drivers/char/agp/via-agp.c:133:2: warning: Value stored to 'current_size' is never read [clang-analyzer-deadcode.DeadStores]
           current_size = A_SIZE_16(agp_bridge->current_size);
           ^
   drivers/char/agp/via-agp.c:133:2: note: Value stored to 'current_size' is never read
   Suppressed 6 warnings (5 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   drivers/char/applicom.c:571:5: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
                                   ret = do_ac_read(i, buf, &st_loc, &mailbox);
                                   ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/char/applicom.c:571:5: note: Value stored to 'ret' is never read
                                   ret = do_ac_read(i, buf, &st_loc, &mailbox);
                                   ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 8 warnings (5 in non-user code, 3 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           channel->target_cpu = target_cpu;
                               ^
   drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. Execution continues on line 619
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
           ^
   drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
           init_vp_index(newchannel);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without an initial value
           u32 target_cpu;
           ^~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                         ^~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:737:6: note: Assuming the condition is false
               !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:2: note: Taking false branch
           if ((vmbus_proto_version == VERSION_WS2008) ||
           ^
   drivers/hv/channel_mgmt.c:752:14: note: Assuming the condition is false
           for (i = 1; i <= ncpu + 1; i++) {
                       ^~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c8 K. Y. Srinivasan         2012-12-01  714  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  716   * Starting with Win8, we can statically distribute the incoming
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  717   * channel interrupt load by binding a channel to VCPU.
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  719   * For pre-win8 hosts or non-performance critical channels we assign the
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  720)  * VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  722)  * Starting with win8, performance critical channels will be distributed
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  723)  * evenly among all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  724)  * we will assign the CPU based on a simple round robin scheme.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  726) static void init_vp_index(struct vmbus_channel *channel)
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn = hv_is_perf_channel(channel);
7c9ff3deeee61b Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = num_online_cpus();
25355252607ca2 Dexuan Cui               2018-09-23  730  	cpumask_var_t available_mask;
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  731  	struct cpumask *alloced_mask;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  734  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == VERSION_WS2008) ||
25355252607ca2 Dexuan Cui               2018-09-23  736  	    (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca2 Dexuan Cui               2018-09-23  737  	    !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  739  		 * Prior to win8, all channel interrupts are
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered on VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  741  		 * Also if the channel is not a performance critical
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  743) 		 * In case alloc_cpumask_var() fails, bind it to
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  744) 		 * VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  746) 		channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  748) 			hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  751  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = next_numa_node_id++;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  755) 			if (numa_node == nr_node_ids) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  756) 				next_numa_node_id = 0;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  759) 			if (cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask = &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  764  
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  765  		if (cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  766) 		    cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  768  			 * We have cycled through all the CPUs in the node;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  769  			 * reset the alloced map.
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  771  			cpumask_clear(alloced_mask);
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  773  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, alloced_mask,
7c9ff3deeee61b Haiyang Zhang            2021-07-16  775  			    cpumask_of_node(numa_node));
79fd8e706637a5 Vitaly Kuznetsov         2016-01-27  776  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = cpumask_first(available_mask);
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  778) 		cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  779  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  780  		if (channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b Haiyang Zhang            2021-07-16  781  		    i > ncpu || !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b Haiyang Zhang            2021-07-16  784  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca2 Dexuan Cui               2018-09-23  786  
25355252607ca2 Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  789  

:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-12-12 10:57 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-12-12 10:57 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 21793 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Haiyang Zhang <haiyangz@microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   a763d5a5abd65797aec3dd1bf01fe2ccbec32967
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix duplicate CPU assignments within a device
date:   5 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 5 months ago
config: x86_64-randconfig-c007-20211202 (https://download.01.org/0day-ci/archive/20211212/202112121844.0E86hxdz-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b553297ef3ee4dc2119d5429adf3072e90fac38)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   drivers/w1/slaves/w1_ds28e17.c:723:2: warning: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcat(data->adapter.name, sl->name);
           ^~~~~~
   drivers/w1/slaves/w1_ds28e17.c:723:2: note: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
           strcat(data->adapter.name, sl->name);
           ^~~~~~
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           channel->target_cpu = target_cpu;
                               ^
   drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. Execution continues on line 619
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
           ^
   drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
           init_vp_index(newchannel);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without an initial value
           u32 target_cpu;
           ^~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                         ^~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:737:6: note: Assuming the condition is false
               !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:2: note: Taking false branch
           if ((vmbus_proto_version == VERSION_WS2008) ||
           ^
   drivers/hv/channel_mgmt.c:752:14: note: Assuming the condition is false
           for (i = 1; i <= ncpu + 1; i++) {
                       ^~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c8 K. Y. Srinivasan         2012-12-01  714  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  716   * Starting with Win8, we can statically distribute the incoming
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  717   * channel interrupt load by binding a channel to VCPU.
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  719   * For pre-win8 hosts or non-performance critical channels we assign the
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  720)  * VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  722)  * Starting with win8, performance critical channels will be distributed
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  723)  * evenly among all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  724)  * we will assign the CPU based on a simple round robin scheme.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  726) static void init_vp_index(struct vmbus_channel *channel)
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn = hv_is_perf_channel(channel);
7c9ff3deeee61b Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = num_online_cpus();
25355252607ca2 Dexuan Cui               2018-09-23  730  	cpumask_var_t available_mask;
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  731  	struct cpumask *alloced_mask;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  734  
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == VERSION_WS2008) ||
25355252607ca2 Dexuan Cui               2018-09-23  736  	    (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca2 Dexuan Cui               2018-09-23  737  	    !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  739  		 * Prior to win8, all channel interrupts are
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered on VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  741  		 * Also if the channel is not a performance critical
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  743) 		 * In case alloc_cpumask_var() fails, bind it to
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  744) 		 * VMBUS_CONNECT_CPU.
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e Andrea Parri (Microsoft  2020-04-06  746) 		channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd1 Andrea Parri (Microsoft  2020-05-22  748) 			hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  751  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = next_numa_node_id++;
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  755) 			if (numa_node == nr_node_ids) {
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  756) 				next_numa_node_id = 0;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  759) 			if (cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask = &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  764  
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  765  		if (cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  766) 		    cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  768  			 * We have cycled through all the CPUs in the node;
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  769  			 * reset the alloced map.
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e K. Y. Srinivasan         2015-08-05  771  			cpumask_clear(alloced_mask);
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4 Vitaly Kuznetsov         2015-05-06  773  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, alloced_mask,
7c9ff3deeee61b Haiyang Zhang            2021-07-16  775  			    cpumask_of_node(numa_node));
79fd8e706637a5 Vitaly Kuznetsov         2016-01-27  776  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = cpumask_first(available_mask);
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06  778) 		cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2 K. Y. Srinivasan         2015-05-30  779  
7c9ff3deeee61b Haiyang Zhang            2021-07-16  780  		if (channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b Haiyang Zhang            2021-07-16  781  		    i > ncpu || !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b Haiyang Zhang            2021-07-16  784  
8ef4c4abbbcdcd Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca2 Dexuan Cui               2018-09-23  786  
25355252607ca2 Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c8 K. Y. Srinivasan         2012-12-01  789  

:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
@ 2021-12-18  5:24 kernel test robot
  0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2021-12-18  5:24 UTC (permalink / raw
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 20760 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Haiyang Zhang <haiyangz@microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   5d65f6f3df56021ec76761ea6986bc8139f537d2
commit: 7c9ff3deeee61b253715dcf968a6307af148c9b2 Drivers: hv: vmbus: Fix duplicate CPU assignments within a device
date:   5 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 5 months ago
config: x86_64-randconfig-c007-20211202 (https://download.01.org/0day-ci/archive/20211218/202112181331.jNASpDYL-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4b553297ef3ee4dc2119d5429adf3072e90fac38)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c9ff3deeee61b253715dcf968a6307af148c9b2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 7c9ff3deeee61b253715dcf968a6307af148c9b2
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
   #define max_t(type, x, y)       __careful_cmp((type)(x), (type)(y), >)
                                   ^
   note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/minmax.h:104:48: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
   include/linux/minmax.h:38:14: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:31:25: note: expanded from macro '__cmp_once'
                   typeof(x) unique_x = (x);               \
                                         ^
   drivers/hwmon/lm75.h:27:14: note: '?' condition is false
           int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
                       ^
   include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
   #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
                                  ^
   include/linux/minmax.h:124:48: note: expanded from macro 'clamp_t'
   #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
                                                  ^
   include/linux/minmax.h:112:27: note: expanded from macro 'max_t'
   #define max_t(type, x, y)       __careful_cmp((type)(x), (type)(y), >)
                                   ^
   include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^
   include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^
   include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^
   drivers/hwmon/lm75.h:27:14: note: '__UNIQUE_ID___x193' is < '__UNIQUE_ID___y194'
           int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
                       ^
   include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
   #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:124:36: note: expanded from macro 'clamp_t'
   #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:104:27: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^~~
   drivers/hwmon/lm75.h:27:14: note: '?' condition is true
           int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
                       ^
   include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
   #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
                                  ^
   include/linux/minmax.h:124:36: note: expanded from macro 'clamp_t'
   #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
                                      ^
   include/linux/minmax.h:104:27: note: expanded from macro 'min_t'
   #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
                                   ^
   include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
                   __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
                   ^
   include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
                   __cmp(unique_x, unique_y, op); })
                   ^
   include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
   #define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
                            ^
   drivers/hwmon/lm75.h:29:12: note: 'ntemp' is < 0
           ntemp += (ntemp < 0 ? -250 : 250);
                     ^~~~~
   drivers/hwmon/lm75.h:29:12: note: '?' condition is true
   drivers/hwmon/lm75.h:30:29: note: The result of the left shift is undefined because the left operand is negative
           return (u16)((ntemp / 500) << 7);
                        ~~~~~~~~~~~~~ ^
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (7 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
>> drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           channel->target_cpu = target_cpu;
                               ^
   drivers/hv/channel_mgmt.c:608:2: note: Left side of '&&' is false
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/hv/channel_mgmt.c:608:2: note: Taking false branch
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/hv/channel_mgmt.c:608:2: note: Loop condition is false. Execution continues on line 619
           list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
           ^
   include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
           for (pos = list_first_entry(head, typeof(*pos), member);        \
           ^
   drivers/hv/channel_mgmt.c:619:2: note: Calling 'init_vp_index'
           init_vp_index(newchannel);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:732:2: note: 'target_cpu' declared without an initial value
           u32 target_cpu;
           ^~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:7: note: Assuming the condition is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:7: note: Assuming the condition is false
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:736:48: note: Assuming 'perf_chn' is true
               (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
                                                         ^~~~~~~~~
   drivers/hv/channel_mgmt.c:735:6: note: Left side of '||' is false
           if ((vmbus_proto_version == VERSION_WS2008) ||
               ^
   drivers/hv/channel_mgmt.c:737:6: note: Assuming the condition is false
               !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hv/channel_mgmt.c:735:2: note: Taking false branch
           if ((vmbus_proto_version == VERSION_WS2008) ||
           ^
   drivers/hv/channel_mgmt.c:752:14: note: Assuming the condition is false
           for (i = 1; i <= ncpu + 1; i++) {
                       ^~~~~~~~~~~~~

vim +785 drivers/hv/channel_mgmt.c

a119845f6e98c89 K. Y. Srinivasan         2012-12-01  714  
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  715  /*
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  716   * Starting with Win8, we can statically distribute the incoming
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  717   * channel interrupt load by binding a channel to VCPU.
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  718   *
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  719   * For pre-win8 hosts or non-performance critical channels we assign the
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  720)  * VMBUS_CONNECT_CPU.
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  721)  *
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  722)  * Starting with win8, performance critical channels will be distributed
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  723)  * evenly among all the available NUMA nodes.  Once the node is assigned,
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  724)  * we will assign the CPU based on a simple round robin scheme.
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  725   */
afaa33da08abd10 Andrea Parri (Microsoft  2020-05-22  726) static void init_vp_index(struct vmbus_channel *channel)
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  727  {
afaa33da08abd10 Andrea Parri (Microsoft  2020-05-22  728) 	bool perf_chn = hv_is_perf_channel(channel);
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  729  	u32 i, ncpu = num_online_cpus();
25355252607ca28 Dexuan Cui               2018-09-23  730  	cpumask_var_t available_mask;
9f01ec53458d9e9 K. Y. Srinivasan         2015-08-05  731  	struct cpumask *alloced_mask;
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  732) 	u32 target_cpu;
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  733) 	int numa_node;
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  734  
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  735  	if ((vmbus_proto_version == VERSION_WS2008) ||
25355252607ca28 Dexuan Cui               2018-09-23  736  	    (vmbus_proto_version == VERSION_WIN7) || (!perf_chn) ||
25355252607ca28 Dexuan Cui               2018-09-23  737  	    !alloc_cpumask_var(&available_mask, GFP_KERNEL)) {
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  738  		/*
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  739  		 * Prior to win8, all channel interrupts are
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  740) 		 * delivered on VMBUS_CONNECT_CPU.
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  741  		 * Also if the channel is not a performance critical
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  742) 		 * channel, bind it to VMBUS_CONNECT_CPU.
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  743) 		 * In case alloc_cpumask_var() fails, bind it to
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  744) 		 * VMBUS_CONNECT_CPU.
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  745  		 */
d570aec0f2154e1 Andrea Parri (Microsoft  2020-04-06  746) 		channel->target_cpu = VMBUS_CONNECT_CPU;
afaa33da08abd10 Andrea Parri (Microsoft  2020-05-22  747) 		if (perf_chn)
afaa33da08abd10 Andrea Parri (Microsoft  2020-05-22  748) 			hv_set_alloced_cpu(VMBUS_CONNECT_CPU);
d3ba720dd58cdf6 K. Y. Srinivasan         2014-04-08  749  		return;
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  750  	}
ce59fec836a9b4d Vitaly Kuznetsov         2015-05-06  751  
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  752  	for (i = 1; i <= ncpu + 1; i++) {
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  753  		while (true) {
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  754) 			numa_node = next_numa_node_id++;
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  755) 			if (numa_node == nr_node_ids) {
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  756) 				next_numa_node_id = 0;
509879bdb30b8e1 K. Y. Srinivasan         2016-09-02  757  				continue;
509879bdb30b8e1 K. Y. Srinivasan         2016-09-02  758  			}
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  759) 			if (cpumask_empty(cpumask_of_node(numa_node)))
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  760  				continue;
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  761  			break;
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  762  		}
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  763) 		alloced_mask = &hv_context.hv_numa_map[numa_node];
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  764  
9f01ec53458d9e9 K. Y. Srinivasan         2015-08-05  765  		if (cpumask_weight(alloced_mask) ==
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  766) 		    cpumask_weight(cpumask_of_node(numa_node))) {
ce59fec836a9b4d Vitaly Kuznetsov         2015-05-06  767  			/*
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  768  			 * We have cycled through all the CPUs in the node;
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  769  			 * reset the alloced map.
ce59fec836a9b4d Vitaly Kuznetsov         2015-05-06  770  			 */
9f01ec53458d9e9 K. Y. Srinivasan         2015-08-05  771  			cpumask_clear(alloced_mask);
ce59fec836a9b4d Vitaly Kuznetsov         2015-05-06  772  		}
ce59fec836a9b4d Vitaly Kuznetsov         2015-05-06  773  
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  774  		cpumask_xor(available_mask, alloced_mask,
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  775  			    cpumask_of_node(numa_node));
79fd8e706637a5c Vitaly Kuznetsov         2016-01-27  776  
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  777) 		target_cpu = cpumask_first(available_mask);
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06  778) 		cpumask_set_cpu(target_cpu, alloced_mask);
1f656ff3fdddc2f K. Y. Srinivasan         2015-05-30  779  
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  780  		if (channel->offermsg.offer.sub_channel_index >= ncpu ||
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  781  		    i > ncpu || !hv_cpuself_used(target_cpu, channel))
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  782  			break;
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  783  	}
7c9ff3deeee61b2 Haiyang Zhang            2021-07-16  784  
8ef4c4abbbcdcd9 Andrea Parri (Microsoft  2020-04-06 @785) 	channel->target_cpu = target_cpu;
25355252607ca28 Dexuan Cui               2018-09-23  786  
25355252607ca28 Dexuan Cui               2018-09-23  787  	free_cpumask_var(available_mask);
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  788  }
a119845f6e98c89 K. Y. Srinivasan         2012-12-01  789  

:::::: The code at line 785 was first introduced by commit
:::::: 8ef4c4abbbcdcd9d4bc0fd9454df03e6dac24b73 Drivers: hv: vmbus: Remove the unused HV_LOCALIZED channel affinity logic

:::::: TO: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
:::::: CC: Wei Liu <wei.liu@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-12-18  5:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-25 11:17 drivers/hv/channel_mgmt.c:785:22: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] kernel test robot
2021-07-26  3:43 ` kernel test robot
2021-07-26  3:43   ` kernel test robot
2021-07-26 16:02   ` Haiyang Zhang
2021-07-26 16:02   ` Haiyang Zhang
2021-07-28  8:32     ` Chen, Rong A
2021-07-28  8:32       ` Chen, Rong A
  -- strict thread matches above, loose matches on Subject: below --
2021-12-09  0:18 kernel test robot
2021-12-12 10:57 kernel test robot
2021-12-18  5:24 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.