* Re: [PATCH v4 net-next 09/12] testing: net-drv: add basic shaper test
[not found] ` <3b1ca110-d1e7-47c5-af31-360a233cb4aa@redhat.com>
@ 2024-08-27 14:14 ` Simon Horman
0 siblings, 0 replies; only message in thread
From: Simon Horman @ 2024-08-27 14:14 UTC (permalink / raw)
To: Paolo Abeni
Cc: kernel test robot, netdev, oe-kbuild-all, Jakub Kicinski,
Jiri Pirko, Madhu Chittim, Sridhar Samudrala, John Fastabend,
Sunil Kovvuri Goutham, Jamal Hadi Salim, Donald Hunter,
Brian Cain, linux-hexagon
Cc: Brian Cain, linux-hexagon
On Thu, Aug 22, 2024 at 09:53:22AM +0200, Paolo Abeni wrote:
>
>
> On 8/21/24 18:52, kernel test robot wrote:
> > Hi Paolo,
> >
> > kernel test robot noticed the following build warnings:
> >
> > [auto build test WARNING on net-next/main]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Paolo-Abeni/tools-ynl-lift-an-assumption-about-spec-file-name/20240820-231626
> > base: net-next/main
> > patch link: https://lore.kernel.org/r/4cf74f285fa5f07be546cb83ef96775f86aa0dbf.1724165948.git.pabeni%40redhat.com
> > patch subject: [PATCH v4 net-next 09/12] testing: net-drv: add basic shaper test
> > config: hexagon-randconfig-r112-20240821 (https://download.01.org/0day-ci/archive/20240822/202408220027.kA3pRF6J-lkp@intel.com/config)
> > compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
> > reproduce: (https://download.01.org/0day-ci/archive/20240822/202408220027.kA3pRF6J-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/202408220027.kA3pRF6J-lkp@intel.com/
> >
> > sparse warnings: (new ones prefixed by >>)
> > > > net/shaper/shaper.c:227:24: sparse: sparse: Using plain integer as NULL pointer
>
> AFAICS this warning comes directly from/is due to the hexgon cmpxchg
> implementation:
>
> #define arch_cmpxchg(ptr, old, new) \
> ({ \
> __typeof__(ptr) __ptr = (ptr); \
> __typeof__(*(ptr)) __old = (old); \
> __typeof__(*(ptr)) __new = (new); \
> __typeof__(*(ptr)) __oldval = 0; \
> ^^^^^^^ here.
FWIIW, I agree.
It seems that arch_cmpxchg, as implemented above, expects ptr to
be an integer. And indeed it is used in that way from
include/linux/atomic/atomic-arch-fallback.h:raw_atomic_cmpxchg_acquire().
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/include/linux/atomic/atomic-arch-fallback.h?id=f8fdda9e4f988c210b1e4519a28ddbf7d29b0038#n2055
As a hack, I allowed the function to handle either int or any type of
pointer. With this in place Sparse no longer flags the problem described
above in shaper.c.
Perhaps someone has a suggestion of how to fix this properly.
diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h
index bf6cf5579cf4..d8decb8fb456 100644
--- a/arch/hexagon/include/asm/cmpxchg.h
+++ b/arch/hexagon/include/asm/cmpxchg.h
@@ -51,12 +51,18 @@ __arch_xchg(unsigned long x, volatile void *ptr, int size)
* variable casting.
*/
+#define arch_cmpxchg_zero(ptr) \
+ (__typeof__(*(ptr))) \
+ _Generic(*(ptr), \
+ int: 0, \
+ default: NULL)
+
#define arch_cmpxchg(ptr, old, new) \
({ \
__typeof__(ptr) __ptr = (ptr); \
__typeof__(*(ptr)) __old = (old); \
__typeof__(*(ptr)) __new = (new); \
- __typeof__(*(ptr)) __oldval = 0; \
+ __typeof__(*(ptr)) __oldval = arch_cmpxchg_zero(ptr); \
\
asm volatile( \
"1: %0 = memw_locked(%1);\n" \
^ permalink raw reply related [flat|nested] only message in thread