Re: [rcu:dev.2018.10.03a 44/73] kernel/rcu/tree.c:2704:5: warning: 'max_cpu' may be used uninitialized in this function

From: Paul E. McKenney
Date: Sat Oct 13 2018 - 19:19:11 EST


On Mon, Oct 08, 2018 at 07:25:58PM +0800, kbuild test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2018.10.03a
> head: ef44a26c84188888f97e5d7b3f8e4f8c0decd248
> commit: 813f47a94e3b61439bba90340b532f3a6319d4f5 [44/73] rcu: Print per-CPU callback counts for forward-progress failures
> config: x86_64-randconfig-x006-10081527 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
> git checkout 813f47a94e3b61439bba90340b532f3a6319d4f5
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>
> All warnings (new ones prefixed by >>):
>
> kernel/rcu/tree.c: In function 'rcu_fwd_progress_check':
> >> kernel/rcu/tree.c:2704:5: warning: 'max_cpu' may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (max_cpu >= 0)
> ^
> >> kernel/rcu/tree.c:2699:6: warning: 'max_cbs' may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (cbs <= max_cbs)
> ^

Good catch! A fix is on its way.

Thanx, Paul

> vim +/max_cpu +2704 kernel/rcu/tree.c
>
> 2670
> 2671 /*
> 2672 * Do a forward-progress check for rcutorture. This is normally invoked
> 2673 * due to an OOM event. The argument "j" gives the time period during
> 2674 * which rcutorture would like progress to have been made.
> 2675 */
> 2676 void rcu_fwd_progress_check(unsigned long j)
> 2677 {
> 2678 unsigned long cbs;
> 2679 int cpu;
> 2680 unsigned long max_cbs;
> 2681 int max_cpu;
> 2682 struct rcu_data *rdp;
> 2683
> 2684 if (rcu_gp_in_progress()) {
> 2685 show_rcu_gp_kthreads();
> 2686 } else {
> 2687 preempt_disable();
> 2688 rdp = this_cpu_ptr(&rcu_data);
> 2689 rcu_check_gp_start_stall(rdp->mynode, rdp, j);
> 2690 preempt_enable();
> 2691 }
> 2692 for_each_possible_cpu(cpu) {
> 2693 cbs = rcu_get_n_cbs_cpu(cpu);
> 2694 if (!cbs)
> 2695 continue;
> 2696 if (max_cpu < 0)
> 2697 pr_info("%s: callbacks", __func__);
> 2698 pr_cont(" %d: %lu", cpu, cbs);
> > 2699 if (cbs <= max_cbs)
> 2700 continue;
> 2701 max_cbs = cbs;
> 2702 max_cpu = cpu;
> 2703 }
> > 2704 if (max_cpu >= 0)
> 2705 pr_cont("\n");
> 2706 }
> 2707 EXPORT_SYMBOL_GPL(rcu_fwd_progress_check);
> 2708
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation