linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
	"Peter Zijlstra" <peterz@infradead.org>
Cc: "Finn Thain" <fthain@linux-m68k.org>,
	"Will Deacon" <will@kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Mark Rutland" <mark.rutland@arm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	linux-m68k@vger.kernel.org,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [RFC v3 2/5] bpf: Explicitly align bpf_res_spin_lock
Date: Thu, 09 Oct 2025 18:01:51 +0200	[thread overview]
Message-ID: <b9ab4c28-52c8-4fa7-85cb-109ef4c0d7f4@app.fastmail.com> (raw)
In-Reply-To: <CAADnVQK1GqQKxdoM9e1Z92QK68GEjqgMnC36ooVgS1uUNiP6eg@mail.gmail.com>

On Thu, Oct 9, 2025, at 17:17, Alexei Starovoitov wrote:
> On Thu, Oct 9, 2025 at 12:02 AM Peter Zijlstra <peterz@infradead.org> wrote:
>>
>> On Wed, Oct 08, 2025 at 07:10:13PM -0700, Alexei Starovoitov wrote:
>>
>> > Are you saying 'int' on m68k is not 4 byte aligned by default,
>> > so you have to force 4 byte align?
>>
>> This; m68k has u16 alignment, just to keep life interesting I suppose
>> :-)
>
> It's not "interesting". It adds burden to the rest of the kernel
> for this architectural quirk.
> Linus put the foot down for big-endian on arm64 and riscv.
> We should do the same here.
> x86 uses -mcmodel=kernel for 64-bit and -mregparm=3 for 32-bit.
> m68k can do the same.
> They can adjust the compiler to make 'int' 4 byte aligned under some
> compiler flag. The kernel is built standalone, so it doesn't have
> to conform to native calling convention or anything else.

I agree that building the kernel with -malign-int makes a lot
of sense here, there is even a project to rebuild the entire
user space with the same flag.

However, changing either the kernel or userspace to build with
-malign-int also has its cost, since for ABI compatibility
reasons any include/uapi/*/*.h header that defines a structure
with a misaligned word needs a custom annotation in order to
still define the layout to be the same as before, and the
annotations do complicate the common headers.

See 
https://lore.kernel.org/all/534e8ff8-70cb-4b78-b0b4-f88645bd180a@app.fastmail.com/
for a list of structures that likely need to be annotated,
and the thread around it for more of the nasty details that
make this nontrivial.

       Arnd

  reply	other threads:[~2025-10-09 16:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 22:19 [RFC v3 0/5] Align atomic storage Finn Thain
2025-10-07 22:19 ` [RFC v3 2/5] bpf: Explicitly align bpf_res_spin_lock Finn Thain
2025-10-09  2:10   ` Alexei Starovoitov
2025-10-09  2:56     ` Finn Thain
2025-10-09  7:02     ` Peter Zijlstra
2025-10-09 15:17       ` Alexei Starovoitov
2025-10-09 16:01         ` Arnd Bergmann [this message]
2025-10-09 16:12           ` Alexei Starovoitov
2025-10-07 22:19 ` [RFC v3 5/5] atomic: Add option for weaker alignment check Finn Thain
2025-10-07 22:19 ` [RFC v3 3/5] atomic: Specify alignment for atomic_t and atomic64_t Finn Thain
2025-10-07 22:19 ` [RFC v3 4/5] atomic: Add alignment check to instrumented atomic operations Finn Thain
2025-10-07 22:19 ` [RFC v3 1/5] documentation: Discourage alignment assumptions Finn Thain
2025-10-14 10:23   ` David Laight
2025-10-15  7:40     ` Finn Thain
2025-10-15 13:53       ` David Laight
2025-10-16  6:53         ` Finn Thain
2025-10-16 13:30   ` Arnd Bergmann
2025-10-16 22:14     ` Finn Thain

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=b9ab4c28-52c8-4fa7-85cb-109ef4c0d7f4@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=fthain@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.lau@linux.dev \
    --cc=peterz@infradead.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=will@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).