[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a36r9S_AYfp8Myf+3sfHvGVsBM36HmdoeVFi9BaNdS9Lg@mail.gmail.com>
Date: Thu, 6 May 2021 16:30:42 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: "Huang, Ying" <ying.huang@...el.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Jens Axboe <axboe@...nel.dk>, Jian Cai <jiancai@...gle.com>,
Guenter Roeck <linux@...ck-us.net>,
Peter Zijlstra <peterz@...radead.org>,
Borislav Petkov <bp@...e.de>,
Eric Dumazet <eric.dumazet@...il.com>,
Juergen Gross <jgross@...e.com>,
Michael Ellerman <mpe@...erman.id.au>,
Thomas Gleixner <tglx@...utronix.de>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Ingo Molnar <mingo@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
He Ying <heying24@...wei.com>,
Andrew Morton <akpm@...ux-foundation.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] [v2] smp: fix smp_call_function_single_async prototype
On Thu, May 6, 2021 at 2:03 PM Huang, Ying <ying.huang@...el.com> wrote:
> Arnd Bergmann <arnd@...nel.org> writes:
> > On Thu, May 6, 2021 at 10:14 AM Huang, Ying <ying.huang@...el.com> wrote:
> >>
> >> We cannot avoid type cast in Linux kernel, such as container_of(), is
> >> there some difference here?
> >
> > container_of() does not cause any alignment problems. Assuming the outer
> > structure is aligned correctly, then the inner structure also is.
>
> So you think that the compiler may generate different code depends on
> the data structure alignment (8 vs. 32 here)? I think that it doesn't
> on x86. Do you know it does that on any architecture? But I understand
> that this is possible at least in theory.
It probably won't generate any different code because that would be silly, but
it's also not a good idea to rely on that. In theory the compiler might e.g.
construct an offset into the structure using a bitwise-or instruction instead of
an addition if the alignment tells it that the lower bits are always zero.
Arnd
Powered by blists - more mailing lists