public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
@ 2024-09-25  5:40 kernel test robot
  2024-09-30 16:10 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2024-09-25  5:40 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: oe-kbuild-all, linux-kernel, linux-snps-arc

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   684a64bf32b6e488004e0ad7f0d7e922798f65b6
commit: f2519d4d4fc4d36f2b58c5614357de9f5b4032fc ARC: Emulate one-byte cmpxchg
date:   12 days ago
config: arc-randconfig-r123-20240925 (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409251336.ToC0TvWB-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   arch/arc/kernel/smp.c:252:48: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned long [noderef] __percpu *ipi_data_ptr @@     got unsigned long * @@
   arch/arc/kernel/smp.c:252:48: sparse:     expected unsigned long [noderef] __percpu *ipi_data_ptr
   arch/arc/kernel/smp.c:252:48: sparse:     got unsigned long *
   arch/arc/kernel/smp.c:267:18: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile *v @@     got unsigned long [noderef] __percpu *__ai_ptr @@
   arch/arc/kernel/smp.c:267:18: sparse:     expected void const volatile *v
   arch/arc/kernel/smp.c:267:18: sparse:     got unsigned long [noderef] __percpu *__ai_ptr
>> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
>> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
   arch/arc/kernel/smp.c:401:72: sparse: sparse: incorrect type in argument 4 (different address spaces) @@     expected void [noderef] __percpu *percpu_dev_id @@     got int *dev @@
   arch/arc/kernel/smp.c:401:72: sparse:     expected void [noderef] __percpu *percpu_dev_id
   arch/arc/kernel/smp.c:401:72: sparse:     got int *dev
   arch/arc/kernel/smp.c:265:30: sparse: sparse: dereference of noderef expression

vim +/__percpu +267 arch/arc/kernel/smp.c

41195d236e8445 Vineet Gupta    2013-01-18  249  
ddf84433f411b6 Vineet Gupta    2013-11-25  250  static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg)
41195d236e8445 Vineet Gupta    2013-01-18  251  {
f2a4aa5646687f Vineet Gupta    2013-11-26  252  	unsigned long __percpu *ipi_data_ptr = per_cpu_ptr(&ipi_data, cpu);
d8e8c7dda11f5d Vineet Gupta    2013-11-28  253  	unsigned long old, new;
41195d236e8445 Vineet Gupta    2013-01-18  254  	unsigned long flags;
41195d236e8445 Vineet Gupta    2013-01-18  255  
f2a4aa5646687f Vineet Gupta    2013-11-26  256  	pr_debug("%d Sending msg [%d] to %d\n", smp_processor_id(), msg, cpu);
f2a4aa5646687f Vineet Gupta    2013-11-26  257  
41195d236e8445 Vineet Gupta    2013-01-18  258  	local_irq_save(flags);
41195d236e8445 Vineet Gupta    2013-01-18  259  
d8e8c7dda11f5d Vineet Gupta    2013-11-28  260  	/*
d8e8c7dda11f5d Vineet Gupta    2013-11-28  261  	 * Atomically write new msg bit (in case others are writing too),
d8e8c7dda11f5d Vineet Gupta    2013-11-28  262  	 * and read back old value
d8e8c7dda11f5d Vineet Gupta    2013-11-28  263  	 */
d8e8c7dda11f5d Vineet Gupta    2013-11-28  264  	do {
c6ed4d84a2c49d Bang Li         2022-03-19  265  		new = old = *ipi_data_ptr;
d8e8c7dda11f5d Vineet Gupta    2013-11-28  266  		new |= 1U << msg;
d8e8c7dda11f5d Vineet Gupta    2013-11-28 @267  	} while (cmpxchg(ipi_data_ptr, old, new) != old);
41195d236e8445 Vineet Gupta    2013-01-18  268  
d8e8c7dda11f5d Vineet Gupta    2013-11-28  269  	/*
d8e8c7dda11f5d Vineet Gupta    2013-11-28  270  	 * Call the platform specific IPI kick function, but avoid if possible:
d8e8c7dda11f5d Vineet Gupta    2013-11-28  271  	 * Only do so if there's no pending msg from other concurrent sender(s).
82a423053eb3cf Changcheng Deng 2021-08-14  272  	 * Otherwise, receiver will see this msg as well when it takes the
d8e8c7dda11f5d Vineet Gupta    2013-11-28  273  	 * IPI corresponding to that msg. This is true, even if it is already in
d8e8c7dda11f5d Vineet Gupta    2013-11-28  274  	 * IPI handler, because !@old means it has not yet dequeued the msg(s)
d8e8c7dda11f5d Vineet Gupta    2013-11-28  275  	 * so @new msg can be a free-loader
d8e8c7dda11f5d Vineet Gupta    2013-11-28  276  	 */
d8e8c7dda11f5d Vineet Gupta    2013-11-28  277  	if (plat_smp_ops.ipi_send && !old)
ddf84433f411b6 Vineet Gupta    2013-11-25  278  		plat_smp_ops.ipi_send(cpu);
41195d236e8445 Vineet Gupta    2013-01-18  279  
41195d236e8445 Vineet Gupta    2013-01-18  280  	local_irq_restore(flags);
41195d236e8445 Vineet Gupta    2013-01-18  281  }
41195d236e8445 Vineet Gupta    2013-01-18  282  

:::::: The code at line 267 was first introduced by commit
:::::: d8e8c7dda11f5d5cf90495f2e89d917a83509bc0 ARC: [SMP] optimize IPI send and receive

:::::: TO: Vineet Gupta <vgupta@synopsys.com>
:::::: CC: Vineet Gupta <vgupta@synopsys.com>

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

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

* Re: arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
  2024-09-25  5:40 arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression kernel test robot
@ 2024-09-30 16:10 ` Paul E. McKenney
  2024-10-04 15:41   ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2024-09-30 16:10 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel, linux-snps-arc

On Wed, Sep 25, 2024 at 01:40:45PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   684a64bf32b6e488004e0ad7f0d7e922798f65b6
> commit: f2519d4d4fc4d36f2b58c5614357de9f5b4032fc ARC: Emulate one-byte cmpxchg
> date:   12 days ago
> config: arc-randconfig-r123-20240925 (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/config)
> compiler: arc-elf-gcc (GCC) 13.2.0
> reproduce: (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/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@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202409251336.ToC0TvWB-lkp@intel.com/
> 
> sparse warnings: (new ones prefixed by >>)
>    arch/arc/kernel/smp.c:252:48: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned long [noderef] __percpu *ipi_data_ptr @@     got unsigned long * @@
>    arch/arc/kernel/smp.c:252:48: sparse:     expected unsigned long [noderef] __percpu *ipi_data_ptr
>    arch/arc/kernel/smp.c:252:48: sparse:     got unsigned long *
>    arch/arc/kernel/smp.c:267:18: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile *v @@     got unsigned long [noderef] __percpu *__ai_ptr @@
>    arch/arc/kernel/smp.c:267:18: sparse:     expected void const volatile *v
>    arch/arc/kernel/smp.c:267:18: sparse:     got unsigned long [noderef] __percpu *__ai_ptr
> >> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
> >> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression

I could "fix" this using __force.  Is that a reasonable approach?

If I don't hear otherwise, I will take that approach.

							Thanx, Paul

>    arch/arc/kernel/smp.c:401:72: sparse: sparse: incorrect type in argument 4 (different address spaces) @@     expected void [noderef] __percpu *percpu_dev_id @@     got int *dev @@
>    arch/arc/kernel/smp.c:401:72: sparse:     expected void [noderef] __percpu *percpu_dev_id
>    arch/arc/kernel/smp.c:401:72: sparse:     got int *dev
>    arch/arc/kernel/smp.c:265:30: sparse: sparse: dereference of noderef expression
> 
> vim +/__percpu +267 arch/arc/kernel/smp.c
> 
> 41195d236e8445 Vineet Gupta    2013-01-18  249  
> ddf84433f411b6 Vineet Gupta    2013-11-25  250  static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg)
> 41195d236e8445 Vineet Gupta    2013-01-18  251  {
> f2a4aa5646687f Vineet Gupta    2013-11-26  252  	unsigned long __percpu *ipi_data_ptr = per_cpu_ptr(&ipi_data, cpu);
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  253  	unsigned long old, new;
> 41195d236e8445 Vineet Gupta    2013-01-18  254  	unsigned long flags;
> 41195d236e8445 Vineet Gupta    2013-01-18  255  
> f2a4aa5646687f Vineet Gupta    2013-11-26  256  	pr_debug("%d Sending msg [%d] to %d\n", smp_processor_id(), msg, cpu);
> f2a4aa5646687f Vineet Gupta    2013-11-26  257  
> 41195d236e8445 Vineet Gupta    2013-01-18  258  	local_irq_save(flags);
> 41195d236e8445 Vineet Gupta    2013-01-18  259  
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  260  	/*
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  261  	 * Atomically write new msg bit (in case others are writing too),
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  262  	 * and read back old value
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  263  	 */
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  264  	do {
> c6ed4d84a2c49d Bang Li         2022-03-19  265  		new = old = *ipi_data_ptr;
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  266  		new |= 1U << msg;
> d8e8c7dda11f5d Vineet Gupta    2013-11-28 @267  	} while (cmpxchg(ipi_data_ptr, old, new) != old);
> 41195d236e8445 Vineet Gupta    2013-01-18  268  
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  269  	/*
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  270  	 * Call the platform specific IPI kick function, but avoid if possible:
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  271  	 * Only do so if there's no pending msg from other concurrent sender(s).
> 82a423053eb3cf Changcheng Deng 2021-08-14  272  	 * Otherwise, receiver will see this msg as well when it takes the
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  273  	 * IPI corresponding to that msg. This is true, even if it is already in
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  274  	 * IPI handler, because !@old means it has not yet dequeued the msg(s)
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  275  	 * so @new msg can be a free-loader
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  276  	 */
> d8e8c7dda11f5d Vineet Gupta    2013-11-28  277  	if (plat_smp_ops.ipi_send && !old)
> ddf84433f411b6 Vineet Gupta    2013-11-25  278  		plat_smp_ops.ipi_send(cpu);
> 41195d236e8445 Vineet Gupta    2013-01-18  279  
> 41195d236e8445 Vineet Gupta    2013-01-18  280  	local_irq_restore(flags);
> 41195d236e8445 Vineet Gupta    2013-01-18  281  }
> 41195d236e8445 Vineet Gupta    2013-01-18  282  
> 
> :::::: The code at line 267 was first introduced by commit
> :::::: d8e8c7dda11f5d5cf90495f2e89d917a83509bc0 ARC: [SMP] optimize IPI send and receive
> 
> :::::: TO: Vineet Gupta <vgupta@synopsys.com>
> :::::: CC: Vineet Gupta <vgupta@synopsys.com>
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

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

* Re: arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
  2024-09-30 16:10 ` Paul E. McKenney
@ 2024-10-04 15:41   ` Paul E. McKenney
  0 siblings, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2024-10-04 15:41 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel, linux-snps-arc

On Mon, Sep 30, 2024 at 09:10:27AM -0700, Paul E. McKenney wrote:
> On Wed, Sep 25, 2024 at 01:40:45PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   684a64bf32b6e488004e0ad7f0d7e922798f65b6
> > commit: f2519d4d4fc4d36f2b58c5614357de9f5b4032fc ARC: Emulate one-byte cmpxchg
> > date:   12 days ago
> > config: arc-randconfig-r123-20240925 (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/config)
> > compiler: arc-elf-gcc (GCC) 13.2.0
> > reproduce: (https://download.01.org/0day-ci/archive/20240925/202409251336.ToC0TvWB-lkp@intel.com/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@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202409251336.ToC0TvWB-lkp@intel.com/
> > 
> > sparse warnings: (new ones prefixed by >>)
> >    arch/arc/kernel/smp.c:252:48: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned long [noderef] __percpu *ipi_data_ptr @@     got unsigned long * @@
> >    arch/arc/kernel/smp.c:252:48: sparse:     expected unsigned long [noderef] __percpu *ipi_data_ptr
> >    arch/arc/kernel/smp.c:252:48: sparse:     got unsigned long *
> >    arch/arc/kernel/smp.c:267:18: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const volatile *v @@     got unsigned long [noderef] __percpu *__ai_ptr @@
> >    arch/arc/kernel/smp.c:267:18: sparse:     expected void const volatile *v
> >    arch/arc/kernel/smp.c:267:18: sparse:     got unsigned long [noderef] __percpu *__ai_ptr
> > >> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
> > >> arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression
> 
> I could "fix" this using __force.  Is that a reasonable approach?
> 
> If I don't hear otherwise, I will take that approach.

Having not heard otherwise, does the following fix this issue for you?

							Thanx, Paul

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

diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h
index 58045c8983404..76f43db0890fc 100644
--- a/arch/arc/include/asm/cmpxchg.h
+++ b/arch/arc/include/asm/cmpxchg.h
@@ -48,7 +48,7 @@
 									\
 	switch(sizeof((_p_))) {						\
 	case 1:								\
-		_prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *)_p_, (uintptr_t)_o_, (uintptr_t)_n_);	\
+		_prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *__force)_p_, (uintptr_t)_o_, (uintptr_t)_n_);	\
 		break;							\
 	case 4:								\
 		_prev_ = __cmpxchg(_p_, _o_, _n_);			\

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

end of thread, other threads:[~2024-10-04 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25  5:40 arch/arc/kernel/smp.c:267:18: sparse: sparse: cast removes address space '__percpu' of expression kernel test robot
2024-09-30 16:10 ` Paul E. McKenney
2024-10-04 15:41   ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox