[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2d9c843f-e884-47d3-a825-6402db0a2cb8@app.fastmail.com>
Date: Tue, 01 Aug 2023 08:02:21 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Thomas Gleixner" <tglx@...utronix.de>,
"Peter Zijlstra" <peterz@...radead.org>
Cc: "Jens Axboe" <axboe@...nel.dk>, linux-kernel@...r.kernel.org,
"Ingo Molnar" <mingo@...hat.com>,
"Darren Hart" <dvhart@...radead.org>, dave@...olabs.net,
andrealmeid@...lia.com,
"Andrew Morton" <akpm@...ux-foundation.org>, urezki@...il.com,
"Christoph Hellwig" <hch@...radead.org>,
"Lorenzo Stoakes" <lstoakes@...il.com>, linux-api@...r.kernel.org,
linux-mm@...ck.org, Linux-Arch <linux-arch@...r.kernel.org>,
malteskarupke@....de
Subject: Re: [PATCH v1 02/14] futex: Extend the FUTEX2 flags
On Tue, Aug 1, 2023, at 00:43, Thomas Gleixner wrote:
> On Mon, Jul 31 2023 at 23:33, Peter Zijlstra wrote:
>> On Mon, Jul 31, 2023 at 11:14:11PM +0200, Thomas Gleixner wrote:
>>> --- a/include/uapi/linux/futex.h
>>> +++ b/include/uapi/linux/futex.h
>>> @@ -74,7 +74,12 @@
>>> struct futex_waitv {
>>> __u64 val;
>>> __u64 uaddr;
>>> - __u32 flags;
>>> + union {
>>> + __u32 flags;
>>> + __u32 size : 2,
>>> + : 5,
>>> + private : 1;
>>> + };
>>> __u32 __reserved;
>>> };
>>
>> Durr, I'm not sure I remember if that does the right thing across
>> architectures -- might just work. But I'm fairly sure this isn't the
>> only case of a field in a flags thing in our APIs. Although obviously
>> I can't find another case in a hurry :/
>
> I know, but that doesn't make these things more readable and neither an
> argument against doing it for futex2 :)
...
>
> Still that explicit bitfield does neither need comments nor does it
> leave room for interpretation.
It may be clear to the compiler, but without comments or
looking up psABI documentation I certainly wouldn't know
immediately which bits of the flags word overlay the bitfields
for a given combination of __BIG_ENDIAN/__LITTLE_ENDIAN
and __BIG_ENDIAN_BITFIELD/__LITTLE_ENDIAN_BITFIELD or
architectures with unusual struct alignment requirements
(m68k or arm-oabi).
I'd prefer to completely avoid the bitfield here. Maybe having
exclusive flags for each width would be less confusing, at the
cost of needing two more flag bits and a slightly more complicated
sanity check, or we could take an extra byte out of the __reserved
field to store the length.
Arnd
Powered by blists - more mailing lists