Skip to contentSkip to conversation

posix_acl: Use try_cmpxchg in get_acl

PATCH New Uros Bizjak 1 participant 1 message Jul 14, 2022 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Cc Alexander Viro <[email protected]>
---
 fs/posix_acl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/posix_acl.c +1 -1
index 962d32468eb4..49a13fd4d3cb 100644
@@ -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;
 }
Signature · 1 line
2.35.3