:::::: 
:::::: Manual check reason: "low confidence static check warning: 
kernel/sched/fair.c:9330:6: warning: Value stored to 'icpu' during its 
initialization is never read [clang-analyzer-deadcode.DeadStores]"
:::::: 

CC: l...@lists.linux.dev
CC: kbuild-...@lists.01.org
BCC: l...@intel.com
In-Reply-To: <20220619120451.95251-8-wuyun.a...@bytedance.com>
References: <20220619120451.95251-8-wuyun.a...@bytedance.com>
TO: Abel Wu <wuyun.a...@bytedance.com>
TO: Peter Zijlstra <pet...@infradead.org>
TO: Mel Gorman <mgor...@suse.de>
TO: Vincent Guittot <vincent.guit...@linaro.org>
CC: Josh Don <josh...@google.com>
CC: Chen Yu <yu.c.c...@intel.com>
CC: Tim Chen <tim.c.c...@linux.intel.com>
CC: K Prateek Nayak <kprateek.na...@amd.com>
CC: "Gautham R . Shenoy" <gautham.she...@amd.com>
CC: linux-ker...@vger.kernel.org
CC: Abel Wu <wuyun.a...@bytedance.com>

Hi Abel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on linus/master v5.19-rc2 next-20220617]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    
https://github.com/intel-lab-lkp/linux/commits/Abel-Wu/sched-fair-improve-scan-efficiency-of-SIS/20220619-200743
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
f3dd3f674555bd9455c5ae7fafce0696bd9931b3
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: s390-randconfig-c005-20220619 
(https://download.01.org/0day-ci/archive/20220621/202206211517.bchsifsf-...@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 
af6d2a0b6825e71965f3e2701a63c239fa0ad70f)
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 s390 cross compiling tool for clang build
        # apt-get install binutils-s390x-linux-gnu
        # 
https://github.com/intel-lab-lkp/linux/commit/32fe13cd7aa184ed349d698ebf6f420fa426dd73
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review 
Abel-Wu/sched-fair-improve-scan-efficiency-of-SIS/20220619-200743
        git checkout 32fe13cd7aa184ed349d698ebf6f420fa426dd73
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390 
clang-analyzer 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <l...@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           ^~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:9670:2: note: Calling 'update_sd_lb_stats'
           update_sd_lb_stats(env, &sds);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:9422:7: note: Assuming 'local_group' is 0
                   if (local_group) {
                       ^~~~~~~~~~~
   kernel/sched/fair.c:9422:3: note: Taking false branch
                   if (local_group) {
                   ^
   kernel/sched/fair.c:9431:3: note: Calling 'update_sg_lb_stats'
                   update_sg_lb_stats(env, sds, sg, sgs, &sg_status);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8766:16: note: Assuming 'group' is not equal to field 
'local'
           local_group = group == sds->local;
                         ^~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8769:2: note: Assuming 'i' is >= 'nr_cpu_ids'
           for_each_cpu_and(i, sched_group_span(group), env->cpus) {
           ^
   include/linux/cpumask.h:326:3: note: expanded from macro 'for_each_cpu_and'
                   (cpu) < nr_cpu_ids;)
                   ^~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8769:2: note: Loop condition is false. Execution 
continues on line 8828
           for_each_cpu_and(i, sched_group_span(group), env->cpus) {
           ^
   include/linux/cpumask.h:324:2: note: expanded from macro 'for_each_cpu_and'
           for ((cpu) = -1;                                                \
           ^
   kernel/sched/fair.c:8833:7: note: 'local_group' is 0
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
                ^~~~~~~~~~~
   kernel/sched/fair.c:8833:6: note: Left side of '&&' is true
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
               ^
   kernel/sched/fair.c:8833:22: note: Assuming the condition is true
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8833:6: note: Left side of '&&' is true
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
               ^
   kernel/sched/fair.c:8834:6: note: Assuming field 'idle' is not equal to 
CPU_NOT_IDLE
               env->idle != CPU_NOT_IDLE && sgs->sum_h_nr_running &&
               ^~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8833:6: note: Left side of '&&' is true
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
               ^
   kernel/sched/fair.c:8834:35: note: Assuming field 'sum_h_nr_running' is not 
equal to 0
               env->idle != CPU_NOT_IDLE && sgs->sum_h_nr_running &&
                                            ^~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8833:6: note: Left side of '&&' is true
           if (!local_group && env->sd->flags & SD_ASYM_PACKING &&
               ^
   kernel/sched/fair.c:8835:6: note: Calling 'sched_asym'
               sched_asym(env, sds, sgs, group)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8727:7: note: Access to field 'flags' results in a 
dereference of a null pointer (loaded from field 'local')
           if ((sds->local->flags & SD_SHARE_CPUCAPACITY) ||
                ^    ~~~~~
   kernel/sched/fair.c:8828:24: warning: Access to field 'sgc' results in a 
dereference of a null pointer (loaded from variable 'group') 
[clang-analyzer-core.NullDereference]
           sgs->group_capacity = group->sgc->capacity;
                                 ^
   kernel/sched/fair.c:9670:2: note: Calling 'update_sd_lb_stats'
           update_sd_lb_stats(env, &sds);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:9412:2: note: 'sg' initialized here
           struct sched_group *sg = env->sd->groups;
           ^~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:9422:7: note: Assuming 'local_group' is 0
                   if (local_group) {
                       ^~~~~~~~~~~
   kernel/sched/fair.c:9422:3: note: Taking false branch
                   if (local_group) {
                   ^
   kernel/sched/fair.c:9431:32: note: Passing 'sg' via 3rd parameter 'group'
                   update_sg_lb_stats(env, sds, sg, sgs, &sg_status);
                                                ^~
   kernel/sched/fair.c:9431:3: note: Calling 'update_sg_lb_stats'
                   update_sg_lb_stats(env, sds, sg, sgs, &sg_status);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8766:16: note: Assuming 'group' is equal to field 'local'
           local_group = group == sds->local;
                         ^~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8766:16: note: Assuming pointer value is null
           local_group = group == sds->local;
                         ^~~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8769:2: note: Assuming 'i' is >= 'nr_cpu_ids'
           for_each_cpu_and(i, sched_group_span(group), env->cpus) {
           ^
   include/linux/cpumask.h:326:3: note: expanded from macro 'for_each_cpu_and'
                   (cpu) < nr_cpu_ids;)
                   ^~~~~~~~~~~~~~~~~~
   kernel/sched/fair.c:8769:2: note: Loop condition is false. Execution 
continues on line 8828
           for_each_cpu_and(i, sched_group_span(group), env->cpus) {
           ^
   include/linux/cpumask.h:324:2: note: expanded from macro 'for_each_cpu_and'
           for ((cpu) = -1;                                                \
           ^
   kernel/sched/fair.c:8828:24: note: Access to field 'sgc' results in a 
dereference of a null pointer (loaded from variable 'group')
           sgs->group_capacity = group->sgc->capacity;
                                 ^~~~~
>> kernel/sched/fair.c:9330:6: warning: Value stored to 'icpu' during its 
>> initialization is never read [clang-analyzer-deadcode.DeadStores]
           int icpu = sds->idle_cpu, this = env->dst_cpu;
               ^~~~   ~~~~~~~~~~~~~
   kernel/sched/fair.c:9330:6: note: Value stored to 'icpu' during its 
initialization is never read
           int icpu = sds->idle_cpu, this = env->dst_cpu;
               ^~~~   ~~~~~~~~~~~~~
>> kernel/sched/fair.c:9352:4: warning: Value stored to 'icpu' is never read 
>> [clang-analyzer-deadcode.DeadStores]
                           icpu = this;
                           ^      ~~~~
   kernel/sched/fair.c:9352:4: note: Value stored to 'icpu' is never read
                           icpu = this;
                           ^      ~~~~
   kernel/sched/fair.c:10040:25: warning: Dereference of null pointer 
[clang-analyzer-core.NullDereference]
           struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask);
                                  ^
   include/linux/cpumask.h:761:37: note: expanded from macro 
'this_cpu_cpumask_var_ptr'
   #define this_cpu_cpumask_var_ptr(x) this_cpu_ptr(x)
                                       ^
   include/linux/percpu-defs.h:252:27: note: expanded from macro 'this_cpu_ptr'
   #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
                             ^
   include/linux/percpu-defs.h:242:2: note: expanded from macro 'raw_cpu_ptr'
           arch_raw_cpu_ptr(ptr);                                          \
           ^
   include/asm-generic/percpu.h:44:31: note: expanded from macro 
'arch_raw_cpu_ptr'
   #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
                                 ^
   include/linux/percpu-defs.h:231:2: note: expanded from macro 
'SHIFT_PERCPU_PTR'
           RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset))
           ^
   include/linux/compiler.h:170:28: note: expanded from macro 'RELOC_HIDE'
       (typeof(ptr)) (__ptr + (off)); })
                              ^
   kernel/sched/fair.c:10462:13: note: Assuming 'idle' is equal to CPU_IDLE
           int busy = idle != CPU_IDLE && !sched_idle_cpu(cpu);
                      ^~~~~~~~~~~~~~~~
   kernel/sched/fair.c:10462:30: note: Left side of '&&' is false
           int busy = idle != CPU_IDLE && !sched_idle_cpu(cpu);
                                       ^
   kernel/sched/fair.c:10472:2: note: Left side of '||' is false
           for_each_domain(cpu, sd) {
           ^
   kernel/sched/sched.h:1716:14: note: expanded from macro 'for_each_domain'
           for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \
                       ^
   kernel/sched/sched.h:1705:2: note: expanded from macro 
'rcu_dereference_check_sched_domain'
           rcu_dereference_check((p), \
           ^
   include/linux/rcupdate.h:532:2: note: expanded from macro 
'rcu_dereference_check'
           __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:21: note: expanded from macro 
'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long 
long),  \
                              ^
   include/linux/compiler_types.h:319:3: note: expanded from macro 
'__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   kernel/sched/fair.c:10472:2: note: Left side of '||' is false
           for_each_domain(cpu, sd) {
           ^
   kernel/sched/sched.h:1716:14: note: expanded from macro 'for_each_domain'
           for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \
                       ^
   kernel/sched/sched.h:1705:2: note: expanded from macro 
'rcu_dereference_check_sched_domain'
           rcu_dereference_check((p), \
           ^
   include/linux/rcupdate.h:532:2: note: expanded from macro 
'rcu_dereference_check'
           __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:21: note: expanded from macro 
'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long 
long),  \
                              ^
   include/linux/compiler_types.h:319:3: note: expanded from macro 
'__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   kernel/sched/fair.c:10472:2: note: Left side of '||' is false
           for_each_domain(cpu, sd) {
           ^
   kernel/sched/sched.h:1716:14: note: expanded from macro 'for_each_domain'
           for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \
                       ^
   kernel/sched/sched.h:1705:2: note: expanded from macro 
'rcu_dereference_check_sched_domain'
           rcu_dereference_check((p), \
           ^
   include/linux/rcupdate.h:532:2: note: expanded from macro 
'rcu_dereference_check'
           __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
           ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:21: note: expanded from macro 
'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long 
long),  \
                              ^
   include/linux/compiler_types.h:319:3: note: expanded from macro 
'__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   kernel/sched/fair.c:10472:2: note: Left side of '||' is true
           for_each_domain(cpu, sd) {

vim +/icpu +9330 kernel/sched/fair.c

57abff067a0848 Vincent Guittot 2019-10-18  9325  
ba6ee6cee1ed2f Abel Wu         2022-06-19  9326  static void 
sd_update_state(struct lb_env *env, struct sd_lb_stats *sds)
ba6ee6cee1ed2f Abel Wu         2022-06-19  9327  {
fcc108377a7cf7 Abel Wu         2022-06-19  9328         struct 
sched_domain_shared *sd_smt_shared = env->sd->shared;
fcc108377a7cf7 Abel Wu         2022-06-19  9329         enum sd_state new = 
sds->sd_state;
32fe13cd7aa184 Abel Wu         2022-06-19 @9330         int icpu = 
sds->idle_cpu, this = env->dst_cpu;
fcc108377a7cf7 Abel Wu         2022-06-19  9331  
fcc108377a7cf7 Abel Wu         2022-06-19  9332         /*
fcc108377a7cf7 Abel Wu         2022-06-19  9333          * Parallel updating 
can hardly contribute accuracy to
fcc108377a7cf7 Abel Wu         2022-06-19  9334          * the filter, besides 
it can be one of the burdens on
fcc108377a7cf7 Abel Wu         2022-06-19  9335          * cache traffic.
fcc108377a7cf7 Abel Wu         2022-06-19  9336          */
fcc108377a7cf7 Abel Wu         2022-06-19  9337         if 
(cmpxchg(&sd_smt_shared->updating, 0, 1))
fcc108377a7cf7 Abel Wu         2022-06-19  9338                 return;
fcc108377a7cf7 Abel Wu         2022-06-19  9339  
32fe13cd7aa184 Abel Wu         2022-06-19  9340         /*
32fe13cd7aa184 Abel Wu         2022-06-19  9341          * The dst_cpu is 
likely to be fed with tasks soon.
32fe13cd7aa184 Abel Wu         2022-06-19  9342          * If it is the only 
unoccupied cpu in this domain,
32fe13cd7aa184 Abel Wu         2022-06-19  9343          * we still handle it 
the same way as as_has_icpus
32fe13cd7aa184 Abel Wu         2022-06-19  9344          * but turn the SMT 
into the unstable state, rather
32fe13cd7aa184 Abel Wu         2022-06-19  9345          * than waiting to the 
end of load balancing since
32fe13cd7aa184 Abel Wu         2022-06-19  9346          * it's also important 
that update the filter as
32fe13cd7aa184 Abel Wu         2022-06-19  9347          * early as possible to 
keep it fresh.
32fe13cd7aa184 Abel Wu         2022-06-19  9348          */
32fe13cd7aa184 Abel Wu         2022-06-19  9349         if (new == sd_is_busy) {
32fe13cd7aa184 Abel Wu         2022-06-19  9350                 if 
(idle_cpu(this) || sched_idle_cpu(this)) {
32fe13cd7aa184 Abel Wu         2022-06-19  9351                         new = 
sd_may_idle;
32fe13cd7aa184 Abel Wu         2022-06-19 @9352                         icpu = 
this;
32fe13cd7aa184 Abel Wu         2022-06-19  9353                 }
32fe13cd7aa184 Abel Wu         2022-06-19  9354         }
32fe13cd7aa184 Abel Wu         2022-06-19  9355  
fcc108377a7cf7 Abel Wu         2022-06-19  9356         /*
fcc108377a7cf7 Abel Wu         2022-06-19  9357          * There is at least 
one unoccupied cpu available, so
fcc108377a7cf7 Abel Wu         2022-06-19  9358          * propagate it to the 
filter to avoid false negative
fcc108377a7cf7 Abel Wu         2022-06-19  9359          * issue which could 
result in lost tracking of some
fcc108377a7cf7 Abel Wu         2022-06-19  9360          * idle cpus thus 
throughupt downgraded.
fcc108377a7cf7 Abel Wu         2022-06-19  9361          */
fcc108377a7cf7 Abel Wu         2022-06-19  9362         if (new != sd_is_busy) {
32fe13cd7aa184 Abel Wu         2022-06-19  9363                 /*
32fe13cd7aa184 Abel Wu         2022-06-19  9364                  * The 
sd_may_idle state is taken into
32fe13cd7aa184 Abel Wu         2022-06-19  9365                  * 
consideration as well because from
32fe13cd7aa184 Abel Wu         2022-06-19  9366                  * here we 
couldn't actually know task
32fe13cd7aa184 Abel Wu         2022-06-19  9367                  * migrations 
would happen or not.
32fe13cd7aa184 Abel Wu         2022-06-19  9368                  */
fcc108377a7cf7 Abel Wu         2022-06-19  9369                 if 
(!test_idle_cpus(this))
fcc108377a7cf7 Abel Wu         2022-06-19  9370                         
set_idle_cpus(this, true);
fcc108377a7cf7 Abel Wu         2022-06-19  9371         } else {
fcc108377a7cf7 Abel Wu         2022-06-19  9372                 /*
fcc108377a7cf7 Abel Wu         2022-06-19  9373                  * Nothing 
changes so nothing to update or
fcc108377a7cf7 Abel Wu         2022-06-19  9374                  * propagate.
fcc108377a7cf7 Abel Wu         2022-06-19  9375                  */
fcc108377a7cf7 Abel Wu         2022-06-19  9376                 if 
(sd_smt_shared->state == sd_is_busy)
fcc108377a7cf7 Abel Wu         2022-06-19  9377                         goto 
out;
32fe13cd7aa184 Abel Wu         2022-06-19  9378  
32fe13cd7aa184 Abel Wu         2022-06-19  9379                 /*
32fe13cd7aa184 Abel Wu         2022-06-19  9380                  * Allow false 
positive to exist for some time
32fe13cd7aa184 Abel Wu         2022-06-19  9381                  * to make a 
tradeoff of accuracy of the filter
32fe13cd7aa184 Abel Wu         2022-06-19  9382                  * for 
relieving cache traffic.
32fe13cd7aa184 Abel Wu         2022-06-19  9383                  */
32fe13cd7aa184 Abel Wu         2022-06-19  9384                 if 
(sd_smt_shared->state == sd_has_icpus) {
32fe13cd7aa184 Abel Wu         2022-06-19  9385                         new = 
sd_may_idle;
32fe13cd7aa184 Abel Wu         2022-06-19  9386                         goto 
update;
32fe13cd7aa184 Abel Wu         2022-06-19  9387                 }
32fe13cd7aa184 Abel Wu         2022-06-19  9388  
32fe13cd7aa184 Abel Wu         2022-06-19  9389                 /*
32fe13cd7aa184 Abel Wu         2022-06-19  9390                  * If the false 
positive issue has already been
32fe13cd7aa184 Abel Wu         2022-06-19  9391                  * there for a 
while, a correction of the filter
32fe13cd7aa184 Abel Wu         2022-06-19  9392                  * is needed.
32fe13cd7aa184 Abel Wu         2022-06-19  9393                  */
fcc108377a7cf7 Abel Wu         2022-06-19  9394         }
fcc108377a7cf7 Abel Wu         2022-06-19  9395  
fcc108377a7cf7 Abel Wu         2022-06-19  9396         sd_update_icpus(this, 
sds->idle_cpu);
32fe13cd7aa184 Abel Wu         2022-06-19  9397  update:
fcc108377a7cf7 Abel Wu         2022-06-19  9398         sd_smt_shared->state = 
new;
fcc108377a7cf7 Abel Wu         2022-06-19  9399  out:
fcc108377a7cf7 Abel Wu         2022-06-19  9400         
xchg(&sd_smt_shared->updating, 0);
ba6ee6cee1ed2f Abel Wu         2022-06-19  9401  }
ba6ee6cee1ed2f Abel Wu         2022-06-19  9402  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to