From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: dwarves@vger.kernel.org
Subject: Re: pahole treats embedded structures a holes
Date: Thu, 28 May 2026 10:39:34 -0300 [thread overview]
Message-ID: <ahhFlsCJzkxLt3M6@x1> (raw)
In-Reply-To: <20260528051152.GA27820@lst.de>
On Thu, May 28, 2026 at 07:11:52AM +0200, Christoph Hellwig wrote:
> Hi all,
>
> this is a pretty old bug as far as I can tell, but I finally tried to
> track it down and failed.
>
> When running dwarves, both the package in Debian testing and a build of
> todays git tree on Debian testing, it treats a lot of C structures
> embedded into others as holes instead of having a size for them. I
> think this generally structures defined in other header files and
> not the file containing the offending struct.
>
> E.g. if I run pahole on fs/xfs/xfs_buf.o on a current mainline kernel,
> the output for struct xfs_buf starts like this:
>
> struct xfs_buf {
> struct rhash_head b_rhash_head; /* 0 0 */
>
> /* XXX 8 bytes hole, try to pack */
>
> xfs_daddr_t b_rhash_key; /* 8 8 */
>
> struct rhash_head is a single pointer, so 8 bytes on x86-64, and
> xfs_daddr_t is also a 64-bit type, so both the 0 size and the 8
> byte hole are clearly wrong. The kernel .config is attached in case
> it matter.
Starting from using the BTF info, that becomes available thru sysfs as
soon as we load the xfs kernel module:
acme@x1:~$ ls -la /sys/kernel/btf/xfs
ls: cannot access '/sys/kernel/btf/xfs': No such file or directory
acme@x1:~$ sudo modprobe xfs
acme@x1:~$ ls -la /sys/kernel/btf/xfs
-r--r--r--. 1 root root 630917 May 28 10:33 /sys/kernel/btf/xfs
acme@x1:~$
acme@x1:~$ pahole --sizes /sys/kernel/btf/xfs | sort -nr -k2 | grep xfs | head
xfs_mount 4032 8
xfs_dquot_acct 1320 0
xfs_cil_ctx 1240 2
xfsstats 1088 0
__xfsstats 1088 0
xfs_inode 984 2
xfs_quotainfo 552 1
xfs_dquot 536 3
xfs_perag 480 4
xfs_da_state 480 1
acme@x1:~$
Now to the 'xfs_buf' struct:
acme@x1:~$ pahole /sys/kernel/btf/xfs -C xfs_buf | head
struct xfs_buf {
struct rhash_head b_rhash_head; /* 0 8 */
xfs_daddr_t b_rhash_key; /* 8 8 */
int b_length; /* 16 4 */
unsigned int b_hold; /* 20 4 */
atomic_t b_lru_ref; /* 24 4 */
xfs_buf_flags_t b_flags; /* 28 4 */
struct semaphore b_sema; /* 32 24 */
struct list_head b_lru; /* 56 16 */
/* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */
acme@x1:~$
Seems ok, expanding it:
acme@x1:~$ pahole -E /sys/kernel/btf/xfs -C xfs_buf | head
struct xfs_buf {
struct rhash_head {
struct rhash_head * next; /* 0 8 */
} b_rhash_head; /* 0 8 */
/* typedef xfs_daddr_t -> __s64 */ long long int b_rhash_key; /* 8 8 */
int b_length; /* 16 4 */
unsigned int b_hold; /* 20 4 */
/* typedef atomic_t */ struct {
int counter; /* 24 4 */
} b_lru_ref; /* 24 4 */
acme@x1:~$
Looks ok and with your description of the struct, a pointer, 8 bytes,
etc.
Now I'll try with a fresh kernel build, with a default fedora kernel
config, will take a while, but having access to a separate .o file from
the kernel build process, with just DWARF info is what we need to get to
the state you're in, that should work, lets see why you're getting the
unsatisfactory results you're getting, maybe we need further info about
compiler versions, etc, but lets see...
- Arnaldo
next prev parent reply other threads:[~2026-05-28 13:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 5:11 pahole treats embedded structures a holes Christoph Hellwig
2026-05-28 13:39 ` Arnaldo Carvalho de Melo [this message]
2026-05-28 13:58 ` Christoph Hellwig
2026-05-28 19:48 ` Arnaldo Carvalho de Melo
2026-05-29 4:02 ` Christoph Hellwig
2026-05-29 19:28 ` Arnaldo Carvalho de Melo
-- strict thread matches above, loose matches on Subject: below --
2026-06-05 19:28 Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ahhFlsCJzkxLt3M6@x1 \
--to=acme@kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=hch@lst.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.