posix_acl: Use try_cmpxchg in get_acl

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>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
This commit is contained in:
Uros Bizjak 2022-12-21 20:35:40 +01:00 committed by Christian Brauner (Microsoft)
parent 1b929c02af
commit 4e1da8fe03
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -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. * Cache the result, but only if our sentinel is still in place.
*/ */
posix_acl_dup(acl); posix_acl_dup(acl);
if (unlikely(cmpxchg(p, sentinel, acl) != sentinel)) if (unlikely(!try_cmpxchg(p, &sentinel, acl)))
posix_acl_release(acl); posix_acl_release(acl);
return acl; return acl;
} }