Re: [paulmck-rcu:dev.2024.03.27b 61/69] lib/cmpxchg-emu.c:24:11: warning: no previous prototype for 'cmpxchg_emu_u8'

From: Paul E. McKenney
Date: Sun Mar 31 2024 - 14:41:02 EST


On Mon, Apr 01, 2024 at 12:06:26AM +0800, Yujie Liu wrote:
> On Fri, Mar 29, 2024 at 04:08:10PM -0700, Paul E. McKenney wrote:
> > On Sat, Mar 30, 2024 at 05:26:12AM +0800, kernel test robot wrote:
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev.2024.03.27b
> > > head: 786fab3085d764055a78edb54023420920344333
> > > commit: b48ffed4c636b96d2be7a93806870772ce34961f [61/69] csky: Emulate one-byte and two-byte cmpxchg
> > > config: csky-allnoconfig (https://download.01.org/0day-ci/archive/20240330/202403300508.Xz7XNp71-lkp@xxxxxxxxx/config)
> > > compiler: csky-linux-gcc (GCC) 13.2.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240330/202403300508.Xz7XNp71-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/202403300508.Xz7XNp71-lkp@xxxxxxxxx/
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > > >> lib/cmpxchg-emu.c:24:11: warning: no previous prototype for 'cmpxchg_emu_u8' [-Wmissing-prototypes]
> > > 24 | uintptr_t cmpxchg_emu_u8(volatile u8 *p, uintptr_t old, uintptr_t new)
> > > | ^~~~~~~~~~~~~~
> > > >> lib/cmpxchg-emu.c:51:11: warning: no previous prototype for 'cmpxchg_emu_u16' [-Wmissing-prototypes]
> > > 51 | uintptr_t cmpxchg_emu_u16(volatile u16 *p, uintptr_t old, uintptr_t new)
> > > | ^~~~~~~~~~~~~~~
> >
> > Again, good catch, and thank you for the testing! Does the patch at the
> > end of this email fix things for you?
>
> The warning is fixed by the patch at the end of the mail.
>
> Tested-by: Yujie Liu <yujie.liu@xxxxxxxxx>

Thank you! I will apply all three of your Tested-by tags on my next
rebase.

Thanx, Paul

> > > vim +/cmpxchg_emu_u8 +24 lib/cmpxchg-emu.c
> > >
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 22
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 23 /* Emulate one-byte cmpxchg() in terms of 4-byte cmpxchg. */
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 @24 uintptr_t cmpxchg_emu_u8(volatile u8 *p, uintptr_t old, uintptr_t new)
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 25 {
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 26 u32 *p32 = (u32 *)(((uintptr_t)p) & ~0x3);
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 27 int i = ((uintptr_t)p) & 0x3;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 28 union u8_32 old32;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 29 union u8_32 new32;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 30 u32 ret;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 31
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 32 old32.w = READ_ONCE(*p32);
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 33 do {
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 34 if (old32.b[i] != old)
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 35 return old32.b[i];
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 36 new32.w = old32.w;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 37 new32.b[i] = new;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 38 instrument_atomic_read_write(p, 1);
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 39 ret = data_race(cmpxchg(p32, old32.w, new32.w));
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 40 } while (ret != old32.w);
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 41 return old;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 42 }
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 43 EXPORT_SYMBOL_GPL(cmpxchg_emu_u8);
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 44
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 45 union u16_32 {
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 46 u16 h[2];
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 47 u32 w;
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 48 };
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 49
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 50 /* Emulate two-byte cmpxchg() in terms of 4-byte cmpxchg. */
> > > 0bbce967f3ecfc Paul E. McKenney 2024-03-17 @51 uintptr_t cmpxchg_emu_u16(volatile u16 *p, uintptr_t old, uintptr_t new)
> > >
> > > :::::: The code at line 24 was first introduced by commit
> > > :::::: 0bbce967f3ecfc6da1e7e8756b0d398e791b8dee lib: Add one-byte and two-byte cmpxchg() emulation functions
> > >
> > > :::::: TO: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > > :::::: CC: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > >
> > > --
> > > 0-DAY CI Kernel Test Service
> > > https://github.com/intel/lkp-tests/wiki
> >
> > commit a326496eb88936b291adea830c2e59e74ca1d373
> > Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
> > Date: Fri Mar 29 16:06:45 2024 -0700
> >
> > squash! lib: Add one-byte and two-byte cmpxchg() emulation functions
> >
> > [ paulmck: Apply kernel test robot feedback. ]
> >
> > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> >
> > diff --git a/lib/cmpxchg-emu.c b/lib/cmpxchg-emu.c
> > index abdd451767220..a88c4f3c88430 100644
> > --- a/lib/cmpxchg-emu.c
> > +++ b/lib/cmpxchg-emu.c
> > @@ -14,6 +14,7 @@
> > #include <linux/panic.h>
> > #include <linux/bug.h>
> > #include <asm-generic/rwonce.h>
> > +#include <linux/cmpxchg-emu.h>
> >
> > union u8_32 {
> > u8 b[4];
> >