linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op
@ 2016-06-20 14:26 Matthieu CASTET
  2016-06-23  4:48 ` Darren Hart
  0 siblings, 1 reply; 18+ messages in thread
From: Matthieu CASTET @ 2016-06-20 14:26 UTC (permalink / raw)
  To: linux-kernel, Michael Kerrisk, Darren Hart
  Cc: Peter Zijlstra, Davidlohr Bueso, Thomas Gleixner

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

Hi,

the commit 337f13046ff03717a9e99675284a817527440a49 is saying that it
change to syscall to an equivalent to FUTEX_WAIT_BITSET |
FUTEX_CLOCK_REALTIME with a bitset of FUTEX_BITSET_MATCH_ANY.

It seems wrong to me, because in case of FUTEX_WAIT, in
"SYSCALL_DEFINE6(futex", we convert relative timeout to absolute
timeout [1].

So FUTEX_CLOCK_REALTIME | FUTEX_WAIT is expecting a relative timeout
when FUTEX_WAIT_BITSET take an absolute timeout.

To make it work you have to use something like the (untested) attached
patch.

Matthieu

[1]
        if (cmd == FUTEX_WAIT)
            t = ktime_add_safe(ktime_get(), t);

[-- Attachment #2: diff --]
[-- Type: text/x-patch, Size: 394 bytes --]

diff --git a/kernel/futex.c b/kernel/futex.c
index 33664f7..4bee915 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3230,7 +3230,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
 			return -EINVAL;
 
 		t = timespec_to_ktime(ts);
-		if (cmd == FUTEX_WAIT)
+		if (cmd == FUTEX_WAIT && !(op & FUTEX_CLOCK_REALTIME))
 			t = ktime_add_safe(ktime_get(), t);
 		tp = &t;
 	}

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-07-06 19:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20 14:26 futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op Matthieu CASTET
2016-06-23  4:48 ` Darren Hart
2016-06-23  7:18   ` Thomas Gleixner
2016-06-23 10:52     ` Michael Kerrisk (man-pages)
2016-06-23 13:40       ` Thomas Gleixner
2016-06-23 16:16         ` Darren Hart
2016-06-23 17:26           ` Thomas Gleixner
2016-06-23 18:28             ` Darren Hart
2016-06-23 18:41               ` Michael Kerrisk (man-pages)
2016-06-23 19:55                 ` Darren Hart
2016-06-23 20:31                   ` Darren Hart
     [not found]                     ` <d8bcb621-012e-f34c-4cf9-2d09aa23a43c@gmail.com>
2016-06-24  9:52                       ` Thomas Gleixner
2016-06-24 10:00                         ` Michael Kerrisk (man-pages)
2016-07-06 18:57                 ` Thomas Gleixner
2016-06-23 18:35           ` Michael Kerrisk (man-pages)
2016-06-23 19:53             ` Darren Hart
2016-06-24  8:13               ` Michael Kerrisk (man-pages)
2016-06-23 10:53   ` Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).