On Mon, 13 Jan 2025, Magnus Lindholm wrote: > I've been running some more tests, this time with a smp kernel but on > a system with just one cpu, seems to me as a bit simpler scenario to > analyze. I've added some print statements to smp_call_function_single, > just to see what's really going on: > > pr_warn("smp_call_function_single: %llx %llx > size=%d\n",&csd_stack,&csd, sizeof(call_single_data_t)); > > output is seen below: > smp: smp_call_function_single: fffffc000493fc40 fffffc000493fc58 size=32 > so, the csd_stack struct is 32-bytes in size but &csd - &csd_stack = > 24. This does not make any sense? Given information supplied previously it does, see below. > When requesting csd_stack to be aligned using > __attribute__((__aligned__(x))) it seems as if the compiler does not > leave enough room above the csd_stack struct. i.e since the exact > location of csd_stack depends on the actual value of $sp it is not > known at compile time. Seems like gcc does not take this into account. > The code works fine if I remove the alignment attribute for csd_stack. > Also as previously mentioned, declaring csd_stack as "struct > ____cacheline_aligned_in_smp" makes it work, but judging from the > disassembly code, this statement has no effect on the alignment of > csd_stack, i.e csd_stack is not aligned to anything its simply just > placed on the stack, indirectly making it just 16-byte aligned instead > of the requested 32-byte alignment. > > It seems to me that, when used to align variables that reside on the > stack, __attribute__((__aligned__(x))) does not work correctly with > gcc/alpha/linux. I smell psABI breakage somewhere causing stack misalignment upframe. It has happened before here and there. It could genuinely be a GCC bug, but I suspect not. I'd rather suspect handcoded assembly or other kind of a manual stack pointer assignment or adjustment made somewhere. Can you please retrieve the value of SP in `smp_call_function_single'? Just something such as: printk("SP: %016lx\n", __builtin_frame_address(0)); should do. If it does show SP as unaligned, then we can dig in deeper. Maciej