Skip to contentSkip to conversation

posix_acl: Use try_cmpxchg in get_acl

PATCH In review Uros Bizjak 2 participants 3 messages Dec 21, 2022 – Jan 8, 2023 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 Christian Brauner <[email protected]>
Cc Alexander Viro <[email protected]>
---
 fs/posix_acl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/posix_acl.c +1 -1
index d7bc81fc0840..420c689e1bec 100644
@@ -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;
 }
Signature · 1 line
2.38.1
#1 lore raw
Quoted 11 lines · Uros Bizjak

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 Christian Brauner <[email protected]>
Cc Alexander Viro <[email protected]>

---

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

Thanks!
Christian

#2 lore raw
Quoted 8 lines · Christian Brauner
Quoted 7 lines · Uros Bizjak

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.

Quoted 7 lines
Quoted 4 lines
Cc Christian Brauner <[email protected]>
Cc Alexander Viro <[email protected]>

---

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