diff mbox series

[v4,6/7] um: swithch futex ops to cmpxchg

Message ID 20201211174559.26010-7-anton.ivanov@cambridgegreys.com
State Changes Requested
Headers show
Series [v4,1/7] um: allow the use of glibc functions instead of builtins | expand

Commit Message

Anton Ivanov Dec. 11, 2020, 5:45 p.m. UTC
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>

As a result of switching from emulated to true atomic cmpxchg
we can use cmpxchg in the corresponding um futex op.

Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
---
 arch/um/kernel/skas/uaccess.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Johannes Berg Dec. 11, 2020, 8:12 p.m. UTC | #1
Typo in the subject :)

> As a result of switching from emulated to true atomic cmpxchg
> we can use cmpxchg in the corresponding um futex op.

But this seems odd - maybe just reorder the patches so the futex code
can directly have this squashed in?

johannes
Anton Ivanov Dec. 11, 2020, 9:33 p.m. UTC | #2
On 11/12/2020 20:12, Johannes Berg wrote:
> Typo in the subject :)
>
>> As a result of switching from emulated to true atomic cmpxchg
>> we can use cmpxchg in the corresponding um futex op.
> But this seems odd - maybe just reorder the patches so the futex code
> can directly have this squashed in?

You do not want to do that if you are still using the generic cmpxchg. 
That is quite cumbersome. If we reorder the cmpxchg before the futex, 
then it can be folded in.

I will do it in v5

A.

>
> johannes
>
>
>
diff mbox series

Patch

diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index de71048b5371..858b2e16e364 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -343,7 +343,6 @@  EXPORT_SYMBOL(arch_futex_atomic_op_inuser);
  * -EAGAIN - Atomic operation was unable to complete due to contention
  * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG)
  */
-
 int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 			      u32 oldval, u32 newval)
 {
@@ -366,8 +365,7 @@  int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 
 	val = *uaddr;
 
-	if (val == oldval)
-		*uaddr = newval;
+	ret = cmpxchg(uaddr, oldval, newval);
 
 	*uval = val;
 	pagefault_enable();