Re: [PATCH v5 3/3] locking/mutex: Ensure forward progress of waiter-spinner

From: Peter Zijlstra
Date: Thu Aug 18 2016 - 20:59:38 EST


On Thu, Aug 18, 2016 at 11:04:40AM -0700, Jason Low wrote:
> On Thu, 2016-08-18 at 17:58 +0200, Peter Zijlstra wrote:
> > On Thu, Aug 11, 2016 at 11:01:27AM -0400, Waiman Long wrote:
> > > The following is the updated patch that should fix the build error in
> > > non-x86 platform.
> > >
> >
> > This patch was whitespace challenged, but I think I munged it properly.
> >
> > I've also stuck something based on Jason's patch on top. Please have a
> > look at:
> >
> > https://git.kernel.org/cgit/linux/kernel/git/peterz/queue.git/log/?h=locking/core
>
> Should we convert the flags back to type 'bool'?

No,

> We're using them as
> booleans and we could also leave unneeded space available in case we
> ever need to squeeze some more variable(s) in the structure.

Because sizeof(bool) is undefined, that then leaves sizeof(struct mutex)
and alignof(struct mutex) and its exact layout also undefined.

Never use bool in aggregate types.

Of course, an actual implementation needs a sizeof(bool) to translate
things, but these are defined in the architecture ABI, not in the
language. And having struct mutex change depending on whatever an
architecture ABI chooses is very bad form.