linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] posix_acl: Use try_cmpxchg in get_acl
@ 2022-07-14 17:38 Uros Bizjak
  0 siblings, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2022-07-14 17:38 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel; +Cc: Uros Bizjak, Alexander Viro

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old
in get_acl. x86 CMPXCHG instruction returns success in ZF flag,
so this change saves a compare after cmpxchg (and related move
instruction in front of cmpxchg).

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
---
 fs/posix_acl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 962d32468eb4..49a13fd4d3cb 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -164,7 +164,7 @@ struct posix_acl *get_acl(struct inode *inode, int type)
 	 * Cache the result, but only if our sentinel is still in place.
 	 */
 	posix_acl_dup(acl);
-	if (unlikely(cmpxchg(p, sentinel, acl) != sentinel))
+	if (unlikely(!try_cmpxchg(p, &sentinel, acl)))
 		posix_acl_release(acl);
 	return acl;
 }
-- 
2.35.3


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

* Re: [PATCH] posix_acl: Use try_cmpxchg in get_acl
       [not found] <202207162205.iBwToBEr-lkp@intel.com>
@ 2022-07-18  2:05 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-07-18  2:05 UTC (permalink / raw)
  To: Uros Bizjak, linux-fsdevel, LKML; +Cc: kbuild-all, Alexander Viro

Hi Uros,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.19-rc6 next-20220715]
[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/Uros-Bizjak/posix_acl-Use-try_cmpxchg-in-get_acl/20220715-014002
base: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
4a57a8400075bc5287c5c877702c68aeae2a033d
config: powerpc-sam440ep_defconfig 
(https://download.01.org/0day-ci/archive/20220716/202207162205.iBwToBEr-lkp@intel.com/config)
compiler: powerpc-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/8291d21630df3a57adf6d0ed8a1cded2a2700f66
         git remote add linux-review https://github.com/intel-lab-lkp/linux
         git fetch --no-tags linux-review 
Uros-Bizjak/posix_acl-Use-try_cmpxchg-in-get_acl/20220715-014002
         git checkout 8291d21630df3a57adf6d0ed8a1cded2a2700f66
         # 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=powerpc SHELL=/bin/bash

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/kernel.h:20,
                     from fs/posix_acl.c:14:
    fs/posix_acl.c: In function 'get_acl':
>> include/linux/atomic/atomic-arch-fallback.h:90:34: error: initialization of 'struct posix_acl **' from incompatible pointer type 'void **' [-Werror=incompatible-pointer-types]
       90 |         typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \
          |                                  ^
    include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
       78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
          |                                             ^
    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__); \
          |         ^~~~~~~~~~~~~~~~
    fs/posix_acl.c:167:23: note: in expansion of macro 'try_cmpxchg'
      167 |         if (unlikely(!try_cmpxchg(p, &sentinel, acl)))
          |                       ^~~~~~~~~~~
    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
-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* [PATCH] posix_acl: Use try_cmpxchg in get_acl
@ 2022-12-21 19:35 Uros Bizjak
  2022-12-23 10:47 ` Christian Brauner
  0 siblings, 1 reply; 5+ messages in thread
From: Uros Bizjak @ 2022-12-21 19:35 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: Uros Bizjak, Christian Brauner, Alexander Viro

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old
in get_acl. x86 CMPXCHG instruction returns success in ZF flag,
so this change saves a compare after cmpxchg (and related move
instruction in front of cmpxchg).

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
---
 fs/posix_acl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index d7bc81fc0840..420c689e1bec 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -174,7 +174,7 @@ static struct posix_acl *__get_acl(struct user_namespace *mnt_userns,
 	 * Cache the result, but only if our sentinel is still in place.
 	 */
 	posix_acl_dup(acl);
-	if (unlikely(cmpxchg(p, sentinel, acl) != sentinel))
+	if (unlikely(!try_cmpxchg(p, &sentinel, acl)))
 		posix_acl_release(acl);
 	return acl;
 }
-- 
2.38.1


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

* Re: [PATCH] posix_acl: Use try_cmpxchg in get_acl
  2022-12-21 19:35 Uros Bizjak
@ 2022-12-23 10:47 ` Christian Brauner
  2023-01-08 11:42   ` Christian Brauner
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Brauner @ 2022-12-23 10:47 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

On Wed, Dec 21, 2022 at 08:35:40PM +0100, Uros Bizjak wrote:
> Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old
> in get_acl. x86 CMPXCHG instruction returns success in ZF flag,
> so this change saves a compare after cmpxchg (and related move
> instruction in front of cmpxchg).
> 
> No functional change intended.
> 
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> ---

Looks ok to me. But it's not urgent so I'll circle back to this post
-rc1.

Thanks!
Christian

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

* Re: [PATCH] posix_acl: Use try_cmpxchg in get_acl
  2022-12-23 10:47 ` Christian Brauner
@ 2023-01-08 11:42   ` Christian Brauner
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2023-01-08 11:42 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: linux-fsdevel, linux-kernel, Alexander Viro

On Fri, Dec 23, 2022 at 11:47:24AM +0100, Christian Brauner wrote:
> On Wed, Dec 21, 2022 at 08:35:40PM +0100, Uros Bizjak wrote:
> > Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old
> > in get_acl. x86 CMPXCHG instruction returns success in ZF flag,
> > so this change saves a compare after cmpxchg (and related move
> > instruction in front of cmpxchg).
> > 
> > No functional change intended.
> > 
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > Cc: Christian Brauner <brauner@kernel.org>
> > Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> > ---
> 
> Looks ok to me. But it's not urgent so I'll circle back to this post
> -rc1.

Seems good to me. So if there are no objectsions, then applied, thanks!

[1/1] posix_acl: Use try_cmpxchg in get_acl
      commit: 4e1da8fe031303599e78f88e0dad9f44272e4f99

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

end of thread, other threads:[~2023-01-08 11:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202207162205.iBwToBEr-lkp@intel.com>
2022-07-18  2:05 ` [PATCH] posix_acl: Use try_cmpxchg in get_acl kernel test robot
2022-12-21 19:35 Uros Bizjak
2022-12-23 10:47 ` Christian Brauner
2023-01-08 11:42   ` Christian Brauner
  -- strict thread matches above, loose matches on Subject: below --
2022-07-14 17:38 Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).