diff mbox series

[3/3] RDMA/rtrs-clt: Kill xchg_paths

Message ID 20220902101922.26273-4-guoqing.jiang@linux.dev (mailing list archive)
State Superseded
Headers show
Series misc changes for rtrs | expand

Commit Message

Guoqing Jiang Sept. 2, 2022, 10:19 a.m. UTC
Let's call try_cmpxchg directly for the same purpose.

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

kernel test robot Sept. 2, 2022, 7:15 p.m. UTC | #1
Hi Guoqing,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on rdma/for-next]
[also build test ERROR on linus/master v6.0-rc3 next-20220901]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guoqing-Jiang/misc-changes-for-rtrs/20220902-182137
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: parisc64-allmodconfig (https://download.01.org/0day-ci/archive/20220903/202209030331.GmBYWKZb-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/1cb28fde63a272543476132ec83f6eb121111fae
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Guoqing-Jiang/misc-changes-for-rtrs/20220902-182137
        git checkout 1cb28fde63a272543476132ec83f6eb121111fae
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/infiniband/ulp/rtrs/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/linux/atomic.h:80,
                    from arch/parisc/include/asm/bitops.h:13,
                    from include/linux/bitops.h:67,
                    from include/linux/log2.h:12,
                    from include/asm-generic/div64.h:55,
                    from ./arch/parisc/include/generated/asm/div64.h:1,
                    from include/linux/math.h:6,
                    from include/linux/math64.h:6,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:13,
                    from drivers/infiniband/ulp/rtrs/rtrs-clt.c:13:
   drivers/infiniband/ulp/rtrs/rtrs-clt.c: In function 'rtrs_clt_remove_path_from_arr':
>> include/linux/atomic/atomic-arch-fallback.h:90:34: error: initialization of 'struct rtrs_clt_path **' from incompatible pointer type 'struct rtrs_clt_path *' [-Werror=incompatible-pointer-types]
      90 |         typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
         |                                  ^
   include/linux/atomic/atomic-instrumented.h:1978:9: note: in expansion of macro 'arch_try_cmpxchg'
    1978 |         arch_try_cmpxchg(__ai_ptr, __ai_oldp, __VA_ARGS__); \
         |         ^~~~~~~~~~~~~~~~
   drivers/infiniband/ulp/rtrs/rtrs-clt.c:2297:21: note: in expansion of macro 'try_cmpxchg'
    2297 |                 if (try_cmpxchg((typeof(ppcpu_path))ppcpu_path, clt_path, next))
         |                     ^~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +90 include/linux/atomic/atomic-arch-fallback.h

29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  86  
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  87  #ifndef arch_try_cmpxchg
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  88  #define arch_try_cmpxchg(_ptr, _oldp, _new) \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  89  ({ \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29 @90  	typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  91  	___r = arch_cmpxchg((_ptr), ___o, (_new)); \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  92  	if (unlikely(___r != ___o)) \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  93  		*___op = ___r; \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  94  	likely(___r == ___o); \
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  95  })
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  96  #endif /* arch_try_cmpxchg */
29f006fdefe6f8 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-08-29  97
Guoqing Jiang Sept. 3, 2022, 3:54 a.m. UTC | #2
On 9/3/22 3:15 AM, kernel test robot wrote:
> Hi Guoqing,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on rdma/for-next]
> [also build test ERROR on linus/master v6.0-rc3 next-20220901]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Guoqing-Jiang/misc-changes-for-rtrs/20220902-182137
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
> config: parisc64-allmodconfig (https://download.01.org/0day-ci/archive/20220903/202209030331.GmBYWKZb-lkp@intel.com/config)
> compiler: hppa-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/1cb28fde63a272543476132ec83f6eb121111fae
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Guoqing-Jiang/misc-changes-for-rtrs/20220902-182137
>          git checkout 1cb28fde63a272543476132ec83f6eb121111fae
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/infiniband/ulp/rtrs/
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>     In file included from include/linux/atomic.h:80,
>                      from arch/parisc/include/asm/bitops.h:13,
>                      from include/linux/bitops.h:67,
>                      from include/linux/log2.h:12,
>                      from include/asm-generic/div64.h:55,
>                      from ./arch/parisc/include/generated/asm/div64.h:1,
>                      from include/linux/math.h:6,
>                      from include/linux/math64.h:6,
>                      from include/linux/time.h:6,
>                      from include/linux/stat.h:19,
>                      from include/linux/module.h:13,
>                      from drivers/infiniband/ulp/rtrs/rtrs-clt.c:13:
>     drivers/infiniband/ulp/rtrs/rtrs-clt.c: In function 'rtrs_clt_remove_path_from_arr':
>>> include/linux/atomic/atomic-arch-fallback.h:90:34: error: initialization of 'struct rtrs_clt_path **' from incompatible pointer type 'struct rtrs_clt_path *' [-Werror=incompatible-pointer-types]
>        90 |         typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
>           |                                  ^
>     include/linux/atomic/atomic-instrumented.h:1978:9: note: in expansion of macro 'arch_try_cmpxchg'
>      1978 |         arch_try_cmpxchg(__ai_ptr, __ai_oldp, __VA_ARGS__); \
>           |         ^~~~~~~~~~~~~~~~
>     drivers/infiniband/ulp/rtrs/rtrs-clt.c:2297:21: note: in expansion of macro 'try_cmpxchg'
>      2297 |                 if (try_cmpxchg((typeof(ppcpu_path))ppcpu_path, clt_path, next))
>           |                     ^~~~~~~~~~~
>     cc1: some warnings being treated as errors

My bad, thanks for the report!

Guoqing
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index c29eccdb4fd2..0661a4e69fc9 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -2220,17 +2220,6 @@  static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path)
 	}
 }
 
-static inline bool xchg_paths(struct rtrs_clt_path __rcu **rcu_ppcpu_path,
-			      struct rtrs_clt_path *clt_path,
-			      struct rtrs_clt_path *next)
-{
-	struct rtrs_clt_path **ppcpu_path;
-
-	/* Call cmpxchg() without sparse warnings */
-	ppcpu_path = (typeof(ppcpu_path))rcu_ppcpu_path;
-	return clt_path == cmpxchg(ppcpu_path, clt_path, next);
-}
-
 static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path)
 {
 	struct rtrs_clt_sess *clt = clt_path->clt;
@@ -2305,7 +2294,7 @@  static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path)
 		 * We race with IO code path, which also changes pointer,
 		 * thus we have to be careful not to overwrite it.
 		 */
-		if (xchg_paths(ppcpu_path, clt_path, next))
+		if (try_cmpxchg((typeof(ppcpu_path))ppcpu_path, clt_path, next))
 			/*
 			 * @ppcpu_path was successfully replaced with @next,
 			 * that means that someone could also pick up the