* [PATCH v2] smp: align struct __call_single_node to 8 bytes
@ 2026-09-23 15:43 Brian Cain
2026-09-23 22:09 ` David Laight
2026-09-24 9:34 ` Peter Zijlstra
0 siblings, 2 replies; 4+ messages in thread
From: Brian Cain @ 2026-09-23 15:43 UTC (permalink / raw)
To: linux-kernel
Cc: pierrick.bouvier, paulmck, sid.manning, peterz, linux-hexagon,
Brian Cain, Ingo Molnar, Frederic Weisbecker,
Philippe Mathieu-Daudé
Consumers walking call_single_queue cast each node to call_single_data_t
and, given that type's declared over-alignment, the compiler may load
llist.next and u_flags as one naturally aligned double word. Fields using
this type, such as task_struct::wake_entry only guarantee pointer alignment,
which faults on strict-alignment 32-bit architectures like hexagon.
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: linux-hexagon@vger.kernel.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
include/linux/smp_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/smp_types.h b/include/linux/smp_types.h
index 2e8461af8df6..5773e1fb2660 100644
--- a/include/linux/smp_types.h
+++ b/include/linux/smp_types.h
@@ -64,6 +64,6 @@ struct __call_single_node {
#ifdef CONFIG_64BIT
u16 src, dst;
#endif
-};
+} __aligned(8);
#endif /* __LINUX_SMP_TYPES_H */
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] smp: align struct __call_single_node to 8 bytes
2026-09-23 15:43 [PATCH v2] smp: align struct __call_single_node to 8 bytes Brian Cain
@ 2026-09-23 22:09 ` David Laight
2026-09-24 9:34 ` Peter Zijlstra
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2026-09-23 22:09 UTC (permalink / raw)
To: Brian Cain
Cc: linux-kernel, pierrick.bouvier, paulmck, sid.manning, peterz,
linux-hexagon, Ingo Molnar, Frederic Weisbecker,
Philippe Mathieu-Daudé
On Wed, 23 Sep 2026 08:43:07 -0700
Brian Cain <brian.cain@oss.qualcomm.com> wrote:
> Consumers walking call_single_queue cast each node to call_single_data_t
> and, given that type's declared over-alignment, the compiler may load
> llist.next and u_flags as one naturally aligned double word. Fields using
> this type, such as task_struct::wake_entry only guarantee pointer alignment,
> which faults on strict-alignment 32-bit architectures like hexagon.
I think the same could happen on arm64.
The compiler is being told the alignment is 4*sizeof(long)), but I doubt it
can ever matter that it is more than 2*sizeof(long).
The other option is to only ever use call_single_data_t to get an aligned
version of the structure and use the struct everywhere else.
The compiler won't be able to use the 'load two register' instruction, but
I doubt that will be measurable.
David
>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Paul E. McKenney <paulmck@kernel.org>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: linux-hexagon@vger.kernel.org
> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
> ---
> include/linux/smp_types.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/smp_types.h b/include/linux/smp_types.h
> index 2e8461af8df6..5773e1fb2660 100644
> --- a/include/linux/smp_types.h
> +++ b/include/linux/smp_types.h
> @@ -64,6 +64,6 @@ struct __call_single_node {
> #ifdef CONFIG_64BIT
> u16 src, dst;
> #endif
> -};
> +} __aligned(8);
>
> #endif /* __LINUX_SMP_TYPES_H */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] smp: align struct __call_single_node to 8 bytes
2026-09-23 15:43 [PATCH v2] smp: align struct __call_single_node to 8 bytes Brian Cain
2026-09-23 22:09 ` David Laight
@ 2026-09-24 9:34 ` Peter Zijlstra
2026-09-24 11:04 ` David Laight
1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2026-09-24 9:34 UTC (permalink / raw)
To: Brian Cain
Cc: linux-kernel, pierrick.bouvier, paulmck, sid.manning,
linux-hexagon, Ingo Molnar, Frederic Weisbecker,
Philippe Mathieu-Daudé
On Wed, Sep 23, 2026 at 08:43:07AM -0700, Brian Cain wrote:
> Consumers walking call_single_queue cast each node to call_single_data_t
> and, given that type's declared over-alignment, the compiler may load
> llist.next and u_flags as one naturally aligned double word. Fields using
> this type, such as task_struct::wake_entry only guarantee pointer alignment,
> which faults on strict-alignment 32-bit architectures like hexagon.
Where exactly does this happen? I'm failing with grep.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] smp: align struct __call_single_node to 8 bytes
2026-09-24 9:34 ` Peter Zijlstra
@ 2026-09-24 11:04 ` David Laight
0 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2026-09-24 11:04 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Brian Cain, linux-kernel, pierrick.bouvier, paulmck, sid.manning,
linux-hexagon, Ingo Molnar, Frederic Weisbecker,
Philippe Mathieu-Daudé
On Thu, 24 Sep 2026 11:34:50 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> On Wed, Sep 23, 2026 at 08:43:07AM -0700, Brian Cain wrote:
> > Consumers walking call_single_queue cast each node to call_single_data_t
> > and, given that type's declared over-alignment, the compiler may load
> > llist.next and u_flags as one naturally aligned double word. Fields using
> > this type, such as task_struct::wake_entry only guarantee pointer alignment,
> > which faults on strict-alignment 32-bit architectures like hexagon.
>
> Where exactly does this happen? I'm failing with grep.
>
Here for one:
void __smp_call_single_queue(int cpu, struct llist_node *node)
{
/*
* We have to check the type of the CSD before queueing it, because
* once queued it can have its flags cleared by
* flush_smp_call_function_queue()
* even if we haven't sent the smp_call IPI yet (e.g. the stopper
* executes migration_cpu_stop() on the remote CPU).
*/
if (trace_csd_queue_cpu_enabled()) {
call_single_data_t *csd;
smp_call_func_t func;
csd = container_of(node, call_single_data_t, node.llist);
func = CSD_TYPE(csd) == CSD_TYPE_TTWU ?
sched_ttwu_pending : csd->func;
trace_call__csd_queue_cpu(cpu, _RET_IP_, func, csd);
}
since the data item itself was probably created with:
#define CSD_INIT(_func, _info) \
(struct __call_single_data){ .func = (_func), .info = (_info), }
I've not looked hard enough to see what the extra alignment was trying
to achieve.
But the above function needs to use the 'less aligned' struct __call_single_data
even if some places use call_single_data_t to get a 'more aligned' structure.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 11:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 15:43 [PATCH v2] smp: align struct __call_single_node to 8 bytes Brian Cain
2026-09-23 22:09 ` David Laight
2026-09-24 9:34 ` Peter Zijlstra
2026-09-24 11:04 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®