mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, mingo@redhat.com,
	dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com,
	Andrew Morton <akpm@linux-foundation.org>,
	urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com,
	Arnd Bergmann <arnd@arndb.de>,
	linux-api@vger.kernel.org, linux-mm@kvack.org,
	linux-arch@vger.kernel.org, malteskarupke@web.de
Subject: Re: [PATCH v1 02/14] futex: Extend the FUTEX2 flags
Date: Mon, 31 Jul 2023 23:33:41 +0200	[thread overview]
Message-ID: <20230731213341.GB51835@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <87a5vbn5r0.ffs@tglx>

On Mon, Jul 31, 2023 at 11:14:11PM +0200, Thomas Gleixner wrote:
> On Mon, Jul 31 2023 at 21:20, Peter Zijlstra wrote:
> > -#define FUTEX2_MASK (FUTEX2_64 | FUTEX2_PRIVATE)
> > +#define FUTEX2_MASK (FUTEX2_SIZE_MASK | FUTEX2_PRIVATE)
> 
> Along with some comment which documents that the size "flags" constitute
> a number field and not flags in the sense of binary flags.
> 
> And please name these size constants so it really becomes obvious:
> 
> #define FUTEX2_SIZE_U32		2

So you want them named:

#define FUTEX2_SIZE_U8		0x00
#define FUTEX2_SIZE_U16		0x01
#define FUTEX2_SIZE_U32		0x02
#define FUTEX2_SIZE_U64		0x03

#define FUTEX2_SIZE_MASK	0x03

Sure, can do.

> >  /**
> >   * futex_parse_waitv - Parse a waitv array from userspace
> > @@ -208,11 +208,11 @@ static int futex_parse_waitv(struct fute
> >  			return -EINVAL;
> >  
> >  		if (!IS_ENABLED(CONFIG_64BIT) || in_compat_syscall()) {
> > -			if ((aux.flags & FUTEX2_64) == FUTEX2_64)
> > +			if ((aux.flags & FUTEX2_SIZE_MASK) == FUTEX2_64)
> >  				return -EINVAL;
> >  		}
> 
> That should be part of the actual 64bit futex enablement, no?

The 'unsigned long' thing is part of the syscalls, which is why I had it
now.

>   
> > -		if ((aux.flags & FUTEX2_64) != FUTEX2_32)
> > +		if ((aux.flags & FUTEX2_SIZE_MASK) != FUTEX2_32)
> >  			return -EINVAL;
> 
> In hindsight I think it was as mistake just to have this __u32 flags
> field in the new interface. Soemthing like the incomplete below might be
> retrofittable, no?
> 
> --- 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 :/

Also, sys_futex_{wake,wait}() have this thing as a syscall argument,
surely you don't want to put this union there as well?

I'd much prefer to just keep the 'unsigned int flags' thing and perhaps
put a comment on-top of the '#define FUTEX2_*' thingies. Note that
having it a field instead of a bunch of flags makes sense, since you can
only have a single size, not a combination of sizes.



  reply	other threads:[~2023-07-31 21:34 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 10:22 [PATCH v1 00/14] futex: More futex2 bits Peter Zijlstra
2023-07-21 10:22 ` [PATCH v1 01/14] futex: Clarify FUTEX2 flags Peter Zijlstra
2023-07-31 16:08   ` Thomas Gleixner
2023-07-21 10:22 ` [PATCH v1 02/14] futex: Extend the " Peter Zijlstra
2023-07-21 15:47   ` Arnd Bergmann
2023-07-21 18:52     ` Peter Zijlstra
2023-07-31 16:11   ` Thomas Gleixner
2023-07-31 16:25     ` Peter Zijlstra
2023-07-31 17:16     ` Thomas Gleixner
2023-07-31 17:35       ` Peter Zijlstra
2023-07-31 20:52         ` Thomas Gleixner
2023-07-31 17:42     ` Thomas Gleixner
2023-07-31 19:20       ` Peter Zijlstra
2023-07-31 21:14         ` Thomas Gleixner
2023-07-31 21:33           ` Peter Zijlstra [this message]
2023-07-31 22:43             ` Thomas Gleixner
2023-07-31 22:59               ` Peter Zijlstra
2023-08-01  8:49                 ` Thomas Gleixner
2023-08-01  6:02               ` Arnd Bergmann
2023-07-21 10:22 ` [PATCH v1 03/14] futex: Flag conversion Peter Zijlstra
2023-07-31 16:21   ` Thomas Gleixner
2023-07-31 16:26     ` Peter Zijlstra
2023-07-21 10:22 ` [PATCH v1 04/14] futex: Validate futex value against futex size Peter Zijlstra
2023-07-31 17:12   ` Thomas Gleixner
2023-07-21 10:22 ` [PATCH v1 05/14] futex: Add sys_futex_wake() Peter Zijlstra
2023-07-21 15:41   ` Arnd Bergmann
2023-07-21 18:54     ` Peter Zijlstra
2023-07-21 21:23       ` Arnd Bergmann
2023-07-25  7:22   ` Geert Uytterhoeven
2023-07-21 10:22 ` [PATCH v1 06/14] futex: Add sys_futex_wait() Peter Zijlstra
2023-07-25  7:22   ` Geert Uytterhoeven
2023-07-31 16:35   ` Thomas Gleixner
2023-07-21 10:22 ` [PATCH v1 07/14] futex: Propagate flags into get_futex_key() Peter Zijlstra
2023-07-31 16:36   ` Thomas Gleixner
2023-07-21 10:22 ` [PATCH v1 08/14] futex: Add flags2 argument to futex_requeue() Peter Zijlstra
2023-07-31 16:43   ` Thomas Gleixner
2023-07-21 10:22 ` [PATCH v1 09/14] futex: Add sys_futex_requeue() Peter Zijlstra
2023-07-25  7:23   ` Geert Uytterhoeven
2023-07-31 17:19   ` Thomas Gleixner
2023-07-31 17:38     ` Peter Zijlstra
2023-07-21 10:22 ` [PATCH v1 10/14] mm: Add vmalloc_huge_node() Peter Zijlstra
2023-07-24 13:46   ` Christoph Hellwig
2023-07-21 10:22 ` [PATCH v1 11/14] futex: Implement FUTEX2_NUMA Peter Zijlstra
2023-07-21 12:16   ` Peter Zijlstra
2023-07-31 17:36   ` Thomas Gleixner
2023-07-31 18:03     ` Peter Zijlstra
2023-07-31 21:26       ` Thomas Gleixner
2024-06-12 17:07       ` Christoph Lameter (Ampere)
2024-06-12 17:23   ` Christoph Lameter (Ampere)
2024-06-12 17:44     ` Peter Zijlstra
2024-06-18 16:53       ` Christoph Lameter (Ampere)
2024-10-25  8:58     ` Peter Zijlstra
2024-10-25 19:36       ` Christoph Lameter (Ampere)
2024-10-26  7:21         ` Peter Zijlstra
2024-10-28 22:32           ` Christoph Lameter (Ampere)
2023-07-21 10:22 ` [PATCH v1 12/14] futex: Propagate flags into futex_get_value_locked() Peter Zijlstra
2023-07-21 10:22 ` [PATCH v1 13/14] futex: Enable FUTEX2_{8,16} Peter Zijlstra
2023-07-21 10:22 ` [PATCH v1 14/14] futex,selftests: Extend the futex selftests Peter Zijlstra
2023-07-21 14:42 ` [PATCH v1 00/14] futex: More futex2 bits Jens Axboe
2023-07-21 15:49 ` Arnd Bergmann

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=20230731213341.GB51835@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrealmeid@igalia.com \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=malteskarupke@web.de \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=urezki@gmail.com \
    /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®