linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu CASTET <matthieu.castet@parrot.com>
To: <linux-kernel@vger.kernel.org>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	Darren Hart <dvhart@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op
Date: Mon, 20 Jun 2016 16:26:52 +0200	[thread overview]
Message-ID: <20160620162652.2c4619c3@perruche.parrot.biz> (raw)

[-- 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;
 	}

             reply	other threads:[~2016-06-20 14:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 14:26 Matthieu CASTET [this message]
2016-06-23  4:48 ` futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op 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)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160620162652.2c4619c3@perruche.parrot.biz \
    --to=matthieu.castet@parrot.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).