[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <57ac401b-222b-4c85-b719-9e671a4617cf@app.fastmail.com>
Date: Mon, 22 Sep 2025 17:21:45 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Finn Thain" <fthain@...ux-m68k.org>,
"Geert Uytterhoeven" <geert@...ux-m68k.org>
Cc: "Peter Zijlstra" <peterz@...radead.org>, "Will Deacon" <will@...nel.org>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Boqun Feng" <boqun.feng@...il.com>, "Jonathan Corbet" <corbet@....net>,
"Mark Rutland" <mark.rutland@....com>, linux-kernel@...r.kernel.org,
Linux-Arch <linux-arch@...r.kernel.org>, linux-m68k@...r.kernel.org,
"Lance Yang" <lance.yang@...ux.dev>
Subject: Re: [RFC v2 2/3] atomic: Specify alignment for atomic_t and atomic64_t
On Mon, Sep 22, 2025, at 10:16, Finn Thain wrote:
>
> Yes, I noticed that also, after I started building with defconfigs.
> I pushed a new patch to my github repo.
>
> https://github.com/fthain/linux/tree/atomic_t
I had a look at that repository, and I think the extra
annotations you added on a lot of structures have the
same mistake that I made when looking at annotating
ABI structures for -malign-int earlier:
Adding __aligned__((sizeof(long))) to a structure definition
only changes the /outer/ alignment of the structure itself,
so e.g.
struct {
short a;
int b;
} __attribute__((aligned(sizeof(long))));
creates a structure with 4-byte alignment and 8-byte
size when building with -mno-align-int, but the padding
is added after 'b', which is still misaligned.
In order to align members the same way that -malign-int does,
each unaligned member needs a separate attribute to force
aligning it, like
struct {
short a;
int b __attribute__((aligned(sizeof(int))));
};
This is different from how __attribute__((packed)) works,
as that is always applied to each member of the struct
if you add it to the end.
Arnd
Powered by blists - more mailing lists