From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755164AbcFTOhx (ORCPT ); Mon, 20 Jun 2016 10:37:53 -0400 Received: from mail.aswsp.com ([193.34.35.150]:26284 "EHLO mail.aswsp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753720AbcFTOh2 (ORCPT ); Mon, 20 Jun 2016 10:37:28 -0400 X-Greylist: delayed 338 seconds by postgrey-1.27 at vger.kernel.org; Mon, 20 Jun 2016 10:37:28 EDT Date: Mon, 20 Jun 2016 16:26:52 +0200 From: Matthieu CASTET To: , Michael Kerrisk , Darren Hart CC: Peter Zijlstra , Davidlohr Bueso , Thomas Gleixner Subject: futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op Message-ID: <20160620162652.2c4619c3@perruche.parrot.biz> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/Xa/xnmV4Zgp12xHmq.HMZ+B" X-Originating-IP: [46.218.109.88] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --MP_/Xa/xnmV4Zgp12xHmq.HMZ+B Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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); --MP_/Xa/xnmV4Zgp12xHmq.HMZ+B Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="diff" 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; } --MP_/Xa/xnmV4Zgp12xHmq.HMZ+B--