lkml.org 
[lkml]   [2021]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] [v2] smp: fix smp_call_function_single_async prototype
On Thu, May 6, 2021 at 2:03 PM Huang, Ying <ying.huang@intel.com> wrote:
> Arnd Bergmann <arnd@kernel.org> writes:
> > On Thu, May 6, 2021 at 10:14 AM Huang, Ying <ying.huang@intel.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

\
 
 \ /
  Last update: 2021-05-06 16:34    [W:0.050 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site