Re: [rcu:rcu/test 136/143] kernel/rcu/tree_plugin.h:2696:25: error: 'struct task_struct' has no member named 'on_cpu'

From: Paul E. McKenney
Date: Wed Dec 23 2020 - 13:34:33 EST


On Wed, Dec 23, 2020 at 11:28:58PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git rcu/test
> head: 4c4c8e04a7f8522de634aa062f4cd6b8b80c151b
> commit: 72351a864d02b480a5c237144033e21be816f29f [136/143] fixup! rcu/nocb: Add grace period and task state to show_rcu_nocb_state() output
> config: nds32-randconfig-r014-20201221 (attached as .config)
> compiler: nds32le-linux-gcc (GCC) 9.3.0
> 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/paulmck/linux-rcu.git/commit/?id=72351a864d02b480a5c237144033e21be816f29f
> git remote add rcu https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
> git fetch --no-tags rcu rcu/test
> git checkout 72351a864d02b480a5c237144033e21be816f29f
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/kernel.h:16,
> from kernel/rcu/tree.c:21:
> kernel/rcu/tree_plugin.h: In function 'show_rcu_nocb_gp_state':
> >> kernel/rcu/tree_plugin.h:2696:25: error: 'struct task_struct' has no member named 'on_cpu'
> 2696 | !rdp->nocb_cb_kthread->on_cpu ? "!" : "");
> | ^~
> include/linux/printk.h:373:34: note: in definition of macro 'pr_info'
> 373 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> | ^~~~~~~~~~~
> kernel/rcu/tree_plugin.h: In function 'show_rcu_nocb_state':
> kernel/rcu/tree_plugin.h:2737:25: error: 'struct task_struct' has no member named 'on_cpu'
> 2737 | !rdp->nocb_cb_kthread->on_cpu ? "!" : "");
> | ^~
> include/linux/printk.h:373:34: note: in definition of macro 'pr_info'
> 373 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
> | ^~~~~~~~~~~

Good catch, I missed the case of !SMP and rcu_nocbs CPUs, thank you!

Does the following fix this for you? (To be folded into the original
with attribution.)

Thanx, Paul

------------------------------------------------------------------------

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 2c16fa8..f97c991 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2668,6 +2668,19 @@ void rcu_bind_current_to_nocb(void)
}
EXPORT_SYMBOL_GPL(rcu_bind_current_to_nocb);

+// The ->on_cpu field is available only in CONFIG_SMP=y, so...
+#ifdef CONFIG_SMP
+static char *show_rcu_should_be_on_cpu(struct task_struct *tsp)
+{
+ return tsp && tsp->state == TASK_RUNNING && !tsp->on_cpu ? "!" : "";
+}
+#else // #ifdef CONFIG_SMP
+static char *show_rcu_should_be_on_cpu(struct task_struct *tsp)
+{
+ return "";
+}
+#endif // #else #ifdef CONFIG_SMP
+
/*
* Dump out nocb grace-period kthread state for the specified rcu_data
* structure.
@@ -2693,8 +2706,7 @@ static void show_rcu_nocb_gp_state(struct rcu_data *rdp)
rnp->grplo, rnp->grphi, READ_ONCE(rdp->nocb_gp_loops),
rdp->nocb_gp_kthread ? task_state_to_char(rdp->nocb_gp_kthread) : '.',
rdp->nocb_cb_kthread ? (int)task_cpu(rdp->nocb_gp_kthread) : -1,
- rdp->nocb_cb_kthread && rdp->nocb_cb_kthread->state == TASK_RUNNING &&
- !rdp->nocb_cb_kthread->on_cpu ? "!" : "");
+ show_rcu_should_be_on_cpu(rdp->nocb_cb_kthread));
}

/* Dump out nocb kthread state for the specified rcu_data structure. */
@@ -2734,8 +2746,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
rcu_segcblist_n_cbs(&rdp->cblist),
rdp->nocb_cb_kthread ? task_state_to_char(rdp->nocb_cb_kthread) : '.',
rdp->nocb_cb_kthread ? (int)task_cpu(rdp->nocb_gp_kthread) : -1,
- rdp->nocb_cb_kthread && rdp->nocb_cb_kthread->state == TASK_RUNNING &&
- !rdp->nocb_cb_kthread->on_cpu ? "!" : "");
+ show_rcu_should_be_on_cpu(rdp->nocb_cb_kthread));

/* It is OK for GP kthreads to have GP state. */
if (rdp->nocb_gp_rdp == rdp)