Re: [PATCH v2] locking: SIX locks (shared/intent/exclusive)

From: Kent Overstreet
Date: Mon May 22 2023 - 17:52:26 EST


On Mon, May 22, 2023 at 01:53:36PM -0700, Linus Torvalds wrote:
> On Mon, May 22, 2023 at 1:13 PM Kent Overstreet
> <kent.overstreet@xxxxxxxxx> wrote:
> >
> > Uh, I think you're wrong on this one - structs with designated
> > initializers have unspecified fields initialized to 0
>
> That's definitely true for unspecified fields.
>
> But there *are* no fields. Only padding.
>
> That said, gcc does seem to always initialize the whole thing. We even
> rely on it when it comes to structures, but I'm not sure it's strictly
> standardized - and I'm particularly not sure about unions.
>
> But there are counter-examples, like this:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104607
>
> so maybe even structures aren't always initialized fully?

Yeah, I have to concede - if we can't rely on struct padding being
initialized we can't rely on union padding either.

> No, Because of *alignment* issues.
>
> An u32 is 4-byte aligned. But "set_bit()" requires "long" alignmnent,.

Ah - right...