On Sat, Aug 30, 2025 at 03:30:11PM +0200, "Gustavo A. R. Silva" wrote: > Based on the comments above, it seems that the original code was expecting > cgrp->ancestors[0] and cgrp_ancestor_storage to share the same addres in > memory. Fortunately, it doesn't matter what the address of cgrp_ancestor_storage is. The important effect is that cgroup_root::cgrp is followed by sufficient space to store a pointer (accessed via cgroup::ancestors[0]). > However when I take a look at the pahole output, I see that these two members > are actually misaligned by 56 bytes. See below: So the root cgroup's ancestry may be saved inside the padding instead of the dedicated storage. I don't think it causes immediate issues but it'd be better not to write to these bytes. (Note that the layout depends on kernel config.) Thanks for the report Gustavo! > So, one solution for this is to use the TRAILING_OVERLAP() helper and > move these members at the end of `struct cgroup_root`. With this the > misalignment disappears (together with the 14722 warnings :) ), and now > both cgrp->ancestors[0] and cgrp_ancestor_storage share the same address > in memory. See below: I didn't know TRAILING_OVERLAP() but it sounds like the tool for such situations. Why do you move struct cgroup at the end of struct cgroup_root? (Actually, as I look at the macro's implementation, it should be --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -110,7 +110,7 @@ enum { struct { \ unsigned char __offset_to_##FAM[offsetof(TYPE, FAM)]; \ MEMBERS \ - }; \ + } __packed; \ } #endif in order to avoid similar issues, no?) Thanks, Michal