Re: Alignment information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14/02/2025 16:34, Andrew Cooper wrote:
> Hello,
> 
> I think this is a new feature request.
> 
> I'm tracking down a UBSAN failure (only shows up on one arch, and it's
> in a list_for_each() so there's loads of container_of() going on too).
> 
> Newer versions of pahole have the overall structure alignment given the
> end, but I can't seem to persuade it to give the the alignment of each
> field.
> 
> More concretely, I'm looking at a structure which is nearly 4k in size,
> differs per arch and has an overall alignment of 128, but I can't find
> which sub-struct within it is causing such an alignment requirement.
> 
> Would it be possible to also print the alignment information in the
> comments that exist already?  i.e., instead of:
> 
> /* $offset    $size */
> 
> could we have
> 
> /* $offset    $size $align */
> 
> ?
>

hi Andrew, I might be missing something but I think "pahole -E
<struct_name>" should give what you're looking for.  This should show
any nested structs which have alignment attributes associated.  For
example with "pahole -E task_struct" I see the a few substructures
tagged with alignment attributes:

$ pahole -E task_struct|grep align
		} avg __attribute__((__aligned__(64))); /*   320    64 */
	} __attribute__((__aligned__(64))) stats
__attribute__((__aligned__(64))); /*   960   256 */
	/* Force alignment to the next boundary: */
				} regs __attribute__((__aligned__(64))); /*  6016  4096 */
		} fpu __attribute__((__aligned__(64))); /*  5888  4224 */
	} thread __attribute__((__aligned__(64))); /*  5696  4416 */
	/* forced alignments: 2, forced holes: 2, sum forced holes: 88 */

It's possible there are bugs that mean this doesn't always work
correctly of course; it would be worth trying if that helps and if you
run into any issues let us know. Thanks!

Alan




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux