mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Darren Hart <dvhart@infradead.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: mtk.manpages@gmail.com,
	Matthieu CASTET <matthieu.castet@parrot.com>,
	linux-kernel@vger.kernel.org,
	Darren Hart <dvhart@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Eric Dumazet <dada1@cosmosbay.com>
Subject: Re: futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op
Date: Thu, 23 Jun 2016 20:35:15 +0200	[thread overview]
Message-ID: <8b6775b1-efee-beec-0ba8-136183742ca3@gmail.com> (raw)
In-Reply-To: <20160623161643.GA106079@f23x64.localdomain>

Hi Darren,

On 06/23/2016 06:16 PM, Darren Hart wrote:
> On Thu, Jun 23, 2016 at 03:40:36PM +0200, Thomas Gleixner wrote:
>> On Thu, 23 Jun 2016, Michael Kerrisk (man-pages) wrote:
>>> On 06/23/2016 09:18 AM, Thomas Gleixner wrote:
>>> Once upon a time, you told me the following:
>>>
>>> On 15 May 2014 at 16:14, Thomas Gleixner <tglx@linutronix.de> wrote:
>>>> On Thu, 15 May 2014, Michael Kerrisk (man-pages) wrote:
>>>>> And that universe would love to have your documentation of
>>>>> FUTEX_WAKE_BITSET and FUTEX_WAIT_BITSET ;-),
>>>>
>>>> I give you almost the full treatment, but I leave REQUEUE_PI to Darren
>>>> and FUTEX_WAKE_OP to Jakub. :)
>>>> [...]
>>>> FUTEX_CLOCK_REALTIME
>>>>
>>>>         This option bit can be ored on the futex ops FUTEX_WAIT_BITSET
>>>>         and FUTEX_WAIT_REQUEUE_PI
>>>>
>>>>         If set the kernel treats the user space supplied timeout as
>>>>         absolute time based on CLOCK_REALTIME.
>>>>
>>>>         If not set the kernel treats the user space supplied timeout
>>>>         as relative time.
>>> Unfortunately, I should have checked the code more carefully...
>>
>> Me too :)
>
> Seems to be going around...
>
>>
>>> Looking more carefully at the code, I see understand the situation
>>> is the following:
>>>
>>> FUTEX_LOCK_PI
>>> 	Always uses CLOCK_REALTIME
>>> 	'timeout' is absolute
>>
>> Yes.
>>
>>> FUTEX_WAIT_REQUEUE_PI
>>> 	Choice of clock (CLOCK_REALTIME vs CLOCK_MONOTONIC) is
>>>         	determined by presence or absence of
>>> 		FUTEX_CLOCK_REALTIME flag
>>> 	'timeout' is absolute
>>
>> Yes
>>
>>> FUTEX_WAIT_BITSET
>>> 	Choice of clock (CLOCK_REALTIME vs CLOCK_MONOTONIC) is
>>>         	determined by presence or absence of
>>> 		FUTEX_CLOCK_REALTIME flag
>>> 	'timeout' is absolute
>>
>> Yes
>>
>>> FUTEX_WAIT
>>> 	Choice of clock (CLOCK_REALTIME vs CLOCK_MONOTONIC) is
>>>         	determined by presence or absence of
>>> 		FUTEX_CLOCK_REALTIME flag
>>> 	'timeout' is relative
>>
>> Yes.
>>
>>> I've amended the man page to describe those details.
>
> OK, that confirms my question, timeout interpretation as relative or absolute is
> based on the op code, not the CLOCK flag.
>
>>>
>>>> The flag was explicitely added to allow FUTEX_WAIT to hand in absolute time.
>>>
>>> When you say that the "flag was added", which flag do you mean? Or, did you
>>> mean: "applying Matthieu's patch will allow FUTEX_WAIT to hand in absolute
>>> time".
>>
>> I didn't express myself clearly. When Darren added the support for
>> CLOCK_REALTIME to FUTEX_WAIT I think he wanted to add absolute timeout
>> support. Anything else does not make sense.
>
> I sent that patch because reading the new man page it struck me as strange that
> FUTEX_WAIT was restricted to CLOCK_MONOTONIC and the other op codes were not,
> especially since FUTEX_WAIT is a just FUTEX_WAIT_BITSET with the mask set to
> ALL.
>
> I didn't realize the impact to relative/absolute interpretation of the timeout
> value at the time.
>
> I think it was a mistake to introduce a change that made FUTEX_WAIT interpret
> the timeout differently based on the CLOCK flag,

I'm missing something. Where does it do that? As far as I can tell FUTEX_WAIT
always interprets the clock as relative, regardless of presence/absence of
FUTEX_CLOCK_REALTIME? Am I missing something?

> while that interpretation is
> independent of the CLOCK flag for all other op codes.
>
> In my opinion, we should treat the timeout value as relative for FUTEX_WAIT
> regardless of the CLOCK used.

I realize it's historical, but it is really weird that FUTEX_WAIT interprets
time timeout (relative vs absolute) differently from all of the other
operations.
> That would require a change to the man page to eliminate the relative/absolute
> language in the FUTEX_CLOCK_REALTIME definition and explicit definitions of the
> interpretation for each op code (as Matthew explains above).
>
> Do we agree on that?

Yes.

The man page changes are already in Git. My earlier reply contained the
commit ref:
http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=8064bfa5369c6856f606004d02e48ab275e05bed

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

  parent reply	other threads:[~2016-06-23 18:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20 14:26 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) [this message]
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=8b6775b1-efee-beec-0ba8-136183742ca3@gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=dada1@cosmosbay.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=dvhart@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthieu.castet@parrot.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

all inboxes | Powered by JetHome®