linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	Alan Maguire <alan.maguire@oracle.com>,
	Anton Protopopov <a.s.protopopov@gmail.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	bpf <bpf@vger.kernel.org>, Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Puranjay Mohan <puranjay@kernel.org>,
	"open list:KERNEL SELFTEST FRAMEWORK"
	<linux-kselftest@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	clang-built-linux <llvm@lists.linux.dev>
Subject: Re: pahole next->master. Was: [PATCH bpf-next v1] selftests/bpf: Guard addr_space_cast code with __BPF_FEATURE_ADDR_SPACE_CAST
Date: Mon, 27 Oct 2025 12:09:07 -0300	[thread overview]
Message-ID: <aP-LE7ssid10iKw-@x1> (raw)
In-Reply-To: <aP-InycOjSO8EqcO@x1>

On Mon, Oct 27, 2025 at 11:58:43AM -0300, Arnaldo Carvalho de Melo wrote:
> On Thu, Oct 23, 2025 at 08:42:34AM -0700, Alexei Starovoitov wrote:
> > On Thu, Oct 23, 2025 at 12:50 AM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> > > thanks, but version 1.30 didn't work in my tests - even pahole's master branch fails, only the next branch works...
> > >
> 
> > > It seems that the 'old' pahole parses some kfuncs incorrectly, for example bpf_dynptr_slice().
> l
> > Alan,
>  
> > the introduction of the 'next' branch screwed up the workflow for many people.
> > Let's remove it and merge everything into master.
> > People expect master branch to be the one where active development
> > is happening and the source of truth for the latest features.
> 
> My bad, I've been away for too long, next is supposed to be with things
> for a short while, testing for a few days, for CI consumption, then move
> to master, rinse repeat.
> 
> I think we should go back to that model.

The difference is small but can explain as has changes to the btf
loader, and the reporter, as I now checked the whole thread, says that
'next' works for him, so I'll move what is in 'next' to 'master' now.

Just for reference since I had done it, my investigation is below.

- Arnaldo

⬢ [acme@toolbx pahole]$ git remote update korg
Fetching korg
⬢ [acme@toolbx pahole]$ 
⬢ [acme@toolbx pahole]$ git remote -v | grep korg
korg	https://git.kernel.org/pub/scm/devel/pahole/pahole.git (fetch)
korg	https://git.kernel.org/pub/scm/devel/pahole/pahole.git (push)
⬢ [acme@toolbx pahole]$ git diff --stat korg/master korg/next 
warning: refname 'korg/next' is ambiguous.
 .github/scripts/build-pahole.sh      | 23 +++++++++++++++++++++++
 .github/scripts/compare-functions.sh | 30 ++++++++++++++++++++++++++++++
 .github/workflows/test.yml           |  4 ++--
 .github/workflows/vmtest.yml         |  4 ++++
 CMakeLists.txt                       |  5 -----
 README                               |  4 ++++
 btf_loader.c                         | 23 ++++++++++++++++++++---
 dwarves_fprintf.c                    |  2 +-
 8 files changed, 84 insertions(+), 11 deletions(-)
⬢ [acme@toolbx pahole]$

Related to btf bitfields:

diff --git a/btf_loader.c b/btf_loader.c
index f4f9f65289b5acac..64ea68022ab04e60 100644
--- a/btf_loader.c
+++ b/btf_loader.c
@@ -645,9 +645,15 @@ static int class__fixup_btf_bitfields(const struct conf_load *conf, struct tag *
                pos->byte_size = tag__size(type, cu);
                pos->bit_size = pos->byte_size * 8;
 
-               /* if BTF data is incorrect and has size == 0, skip field,
-                * instead of crashing */
+               /* If the BTF data is incorrect and has size == 0, skip field
+                * instead of crashing. However the field can be a zero or
+                * variable-length array and we still need to infer alignment.
+                */
                if (pos->byte_size == 0) {
+                       pos->alignment = class__infer_alignment(conf,
+                                                               pos->byte_offset,
+                                                               tag__natural_alignment(type, cu),
+                                                               smallest_offset);
                        continue;
                }
 
@@ -672,7 +678,18 @@ static int class__fixup_btf_bitfields(const struct conf_load *conf, struct tag *
                                                        pos->byte_offset,
                                                        tag__natural_alignment(type, cu),
                                                        smallest_offset);
-               smallest_offset = pos->byte_offset + pos->byte_size;
+
+               /* Compute the smallest offset between this field and the next
+                * one.
+                *
+                * In case of bitfields we need to take into account the
+                * actual size being used instead of the underlying type one as
+                * it could be larger, otherwise we could miss a hole.
+                */
+               smallest_offset = pos->byte_offset;
+               smallest_offset += pos->bitfield_size ?
+                       (pos->bitfield_offset + pos->bitfield_size + 7) / 8 :
+                       pos->byte_size;
        }
 
        tag_type->alignment = class__infer_alignment(conf,

  reply	other threads:[~2025-10-27 15:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  7:18 [PATCH bpf-next v1] selftests/bpf: Guard addr_space_cast code with __BPF_FEATURE_ADDR_SPACE_CAST Jiayuan Chen
2025-10-22 15:33 ` Yonghong Song
2025-10-22 16:48   ` Alexei Starovoitov
2025-10-23  3:33   ` Jiayuan Chen
2025-10-23  3:42     ` Yonghong Song
2025-10-23  7:49       ` Jiayuan Chen
2025-10-23 15:42         ` pahole next->master. Was: " Alexei Starovoitov
2025-10-27 14:58           ` Arnaldo Carvalho de Melo
2025-10-27 15:09             ` Arnaldo Carvalho de Melo [this message]
2025-10-27 21:56               ` 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=aP-LE7ssid10iKw-@x1 \
    --to=acme@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).