kernel/context_tracking.c:126:39: sparse: sparse: incorrect type in initializer (different address spaces)

From: kernel test robot
Date: Fri Jan 12 2024 - 08:58:41 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 70d201a40823acba23899342d62bc2644051ad2e
commit: 481461f5109919babbb393d6f68002936b8e2493 linux/export.h: make <linux/export.h> independent of CONFIG_MODULES
date: 6 months ago
config: csky-buildonly-randconfig-r006-20230413 (https://download.01.org/0day-ci/archive/20240112/202401122136.5Kgy2ZR3-lkp@xxxxxxxxx/config)
compiler: csky-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20240112/202401122136.5Kgy2ZR3-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401122136.5Kgy2ZR3-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> kernel/context_tracking.c:126:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct context_tracking * @@
kernel/context_tracking.c:126:39: sparse: expected void const [noderef] __percpu *__vpp_verify
kernel/context_tracking.c:126:39: sparse: got struct context_tracking *
kernel/context_tracking.c:165:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct context_tracking * @@
kernel/context_tracking.c:165:39: sparse: expected void const [noderef] __percpu *__vpp_verify
kernel/context_tracking.c:165:39: sparse: got struct context_tracking *
kernel/context_tracking.c:206:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct context_tracking * @@
kernel/context_tracking.c:206:39: sparse: expected void const [noderef] __percpu *__vpp_verify
kernel/context_tracking.c:206:39: sparse: got struct context_tracking *
kernel/context_tracking.c:261:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got struct context_tracking * @@
kernel/context_tracking.c:261:39: sparse: expected void const [noderef] __percpu *__vpp_verify
kernel/context_tracking.c:261:39: sparse: got struct context_tracking *
kernel/context_tracking.c: note: in included file (through include/linux/mmzone.h, include/linux/topology.h, include/linux/irq.h, ...):
include/linux/page-flags.h:240:46: sparse: sparse: self-comparison always evaluates to false

vim +126 kernel/context_tracking.c

172114552701b8 Frederic Weisbecker 2022-06-08 115
172114552701b8 Frederic Weisbecker 2022-06-08 116 /*
172114552701b8 Frederic Weisbecker 2022-06-08 117 * Enter an RCU extended quiescent state, which can be either the
172114552701b8 Frederic Weisbecker 2022-06-08 118 * idle loop or adaptive-tickless usermode execution.
172114552701b8 Frederic Weisbecker 2022-06-08 119 *
172114552701b8 Frederic Weisbecker 2022-06-08 120 * We crowbar the ->dynticks_nmi_nesting field to zero to allow for
172114552701b8 Frederic Weisbecker 2022-06-08 121 * the possibility of usermode upcalls having messed up our count
172114552701b8 Frederic Weisbecker 2022-06-08 122 * of interrupt nesting level during the prior busy period.
172114552701b8 Frederic Weisbecker 2022-06-08 123 */
171476775d32a4 Frederic Weisbecker 2022-06-08 124 static void noinstr ct_kernel_exit(bool user, int offset)
172114552701b8 Frederic Weisbecker 2022-06-08 125 {
172114552701b8 Frederic Weisbecker 2022-06-08 @126 struct context_tracking *ct = this_cpu_ptr(&context_tracking);
172114552701b8 Frederic Weisbecker 2022-06-08 127
172114552701b8 Frederic Weisbecker 2022-06-08 128 WARN_ON_ONCE(ct_dynticks_nmi_nesting() != DYNTICK_IRQ_NONIDLE);
172114552701b8 Frederic Weisbecker 2022-06-08 129 WRITE_ONCE(ct->dynticks_nmi_nesting, 0);
172114552701b8 Frederic Weisbecker 2022-06-08 130 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) &&
172114552701b8 Frederic Weisbecker 2022-06-08 131 ct_dynticks_nesting() == 0);
172114552701b8 Frederic Weisbecker 2022-06-08 132 if (ct_dynticks_nesting() != 1) {
172114552701b8 Frederic Weisbecker 2022-06-08 133 // RCU will still be watching, so just do accounting and leave.
172114552701b8 Frederic Weisbecker 2022-06-08 134 ct->dynticks_nesting--;
172114552701b8 Frederic Weisbecker 2022-06-08 135 return;
172114552701b8 Frederic Weisbecker 2022-06-08 136 }
172114552701b8 Frederic Weisbecker 2022-06-08 137
172114552701b8 Frederic Weisbecker 2022-06-08 138 instrumentation_begin();
172114552701b8 Frederic Weisbecker 2022-06-08 139 lockdep_assert_irqs_disabled();
172114552701b8 Frederic Weisbecker 2022-06-08 140 trace_rcu_dyntick(TPS("Start"), ct_dynticks_nesting(), 0, ct_dynticks());
172114552701b8 Frederic Weisbecker 2022-06-08 141 WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current));
172114552701b8 Frederic Weisbecker 2022-06-08 142 rcu_preempt_deferred_qs(current);
172114552701b8 Frederic Weisbecker 2022-06-08 143
171476775d32a4 Frederic Weisbecker 2022-06-08 144 // instrumentation for the noinstr ct_kernel_exit_state()
171476775d32a4 Frederic Weisbecker 2022-06-08 145 instrument_atomic_write(&ct->state, sizeof(ct->state));
172114552701b8 Frederic Weisbecker 2022-06-08 146
172114552701b8 Frederic Weisbecker 2022-06-08 147 instrumentation_end();
172114552701b8 Frederic Weisbecker 2022-06-08 148 WRITE_ONCE(ct->dynticks_nesting, 0); /* Avoid irq-access tearing. */
172114552701b8 Frederic Weisbecker 2022-06-08 149 // RCU is watching here ...
171476775d32a4 Frederic Weisbecker 2022-06-08 150 ct_kernel_exit_state(offset);
172114552701b8 Frederic Weisbecker 2022-06-08 151 // ... but is no longer watching here.
172114552701b8 Frederic Weisbecker 2022-06-08 152 rcu_dynticks_task_enter();
172114552701b8 Frederic Weisbecker 2022-06-08 153 }
172114552701b8 Frederic Weisbecker 2022-06-08 154

:::::: The code at line 126 was first introduced by commit
:::::: 172114552701b85d5c3b1a089a73ee85d0d7786b rcu/context-tracking: Move RCU-dynticks internal functions to context_tracking

:::::: TO: Frederic Weisbecker <frederic@xxxxxxxxxx>
:::::: CC: Paul E. McKenney <paulmck@xxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki