Re: [PATCH] futex: Support smaller futexes of one byte or two byte size.
From: Peter Zijlstra
Date: Fri Dec 06 2019 - 12:37:19 EST
On Fri, Dec 06, 2019 at 04:31:29PM +0100, Peter Zijlstra wrote:
> > + case FUTEX_WAKE:
> > + case FUTEX_REQUEUE:
> > + /*
> > + * these instructions work with sized mutexes, but you
> > + * don't need to pass the size. we could silently
> > + * ignore the size argument, but the code won't verify
> > + * that the correct size is used, so it's preferable
> > + * to make that clear to the caller.
> > + *
> > + * for requeue the meaning would also be ambiguous: do
> > + * both of them have to be the same size or not? they
> > + * don't, and that's clearer when you just don't pass
> > + * a size argument.
> > + */
> > + return -EINVAL;
>
> Took me a while to figure out this relies on FUTEX_NONE to avoid the
> alignment tests.
And thikning more on that, I really _realy_ hate this.
You're basically saying WAKE is size-less, but that means we must
consider what it means to have a u32 WAIT on @ptr, and a u8 WAKE on
@ptr+1. If the wake really is size-less that should match.
I'd be much happier with requiring strict sizing. Because conversely,
what happens if you have a u32-WAIT at @ptr paired with a u8-WAKE at
@ptr? If we demand strict size we can say that should not match. This
does however mean we should include the size in the hash-match function.
Your Changelog did not consider these implications at all.