[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221221193540.10078-1-ubizjak@gmail.com>
Date: Wed, 21 Dec 2022 20:35:40 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Uros Bizjak <ubizjak@...il.com>,
Christian Brauner <brauner@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>
Subject: [PATCH] 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@...il.com>
Cc: Christian Brauner <brauner@...nel.org>
Cc: Alexander Viro <viro@...iv.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
Powered by blists - more mailing lists