mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: mahe.tardy@gmail.com,bpf@vger.kernel.org
Cc: qmo@kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,shuah@kernel.org,mahe.tardy@gmail.com,hi@tychen.cc,gyutae.bae@navercorp.com,sh_def@163.com,josef@toxicpanda.com,linux-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v3 1/5] libbpf: Count entry programs for bpf_gen__init()
Date: Mon,  2 Nov 2026 20:45:57 +0000 (UTC)	[thread overview]
Message-ID: <c013a7069c06d1120f89eb75e9418938b9e4e71cc81043f41f11cb06d75ca634@mail.kernel.org> (raw)
In-Reply-To: <20261102201356.5798-2-mahe.tardy@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

> libbpf: Count entry programs for bpf_gen__init()

TL;DR: Nit only: the comment in bpf_gen__init() in gen_loader.c still says
nr_progs includes subprogs, which is now stale after this change. Suggests
updating it.

> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c

[ ... ]

> @@ -9815,13 +9815,16 @@ static int bpf_object_load(struct bpf_object *obj, int extra_log_level, const ch
>  			if (prog_is_subprog(obj, &obj->programs[i]) &&
>  			    prog_has_callx(&obj->programs[i]))
>  				text_has_callx = true;
> -		for (i = 0; i < obj->nr_programs; i++)
> +		for (i = 0; i < obj->nr_programs; i++) {
> +			if (prog_is_subprog(obj, &obj->programs[i]))
> +				continue;
> +			nr_obj_progs++;
>  			if (obj->programs[i].load_strategy != BPF_PROG_LOAD_STRATEGY_DISABLED &&
> -			    !prog_is_subprog(obj, &obj->programs[i]) &&
>  			    (text_has_callx || prog_has_callx(&obj->programs[i])))
>  				nr_progs++;
> +		}
>  		bpf_gen__init(obj->gen_loader, obj->log_level | extra_log_level,
> -			      obj->nr_programs, obj->nr_maps, nr_func_ptr_maps * nr_progs);
> +			      nr_obj_progs, obj->nr_maps, nr_func_ptr_maps * nr_progs);

This isn't a bug, but the comment in bpf_gen__init() now looks stale:

tools/lib/bpf/gen_loader.c:bpf_gen__init() {
    ...
	/* nr_progs includes subprogs and progs that are not loaded */
	nr_progs = min(nr_progs, MAX_USED_PROGS);
    ...
}

With this change, the nr_progs argument no longer includes subprogs.  It is
the number of entry programs, which is the same count that
bpf_object__for_each_program() and the skeleton expose, and it still
includes entry programs that are not loaded.  The comment came from
259172bb6514 ("libbpf: Fix gen_loader assumption on number of programs."),
which the commit message cites.

None of the later patches in the series (276212ecac70, 28aa06d2c9ca,
c9412c70e104, 5b9c2e5eed2a) update it.  276212ecac70 ("libbpf: Track
generated loader link FDs") also sizes link_fds from this same nr_progs
value, so the comment now misdescribes a value that later code depends on.

Should the comment be changed to something like "nr_progs includes progs
that are not loaded, but not subprogs"?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/41519963115

  reply	other threads:[~2026-11-02 20:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 20:13 [PATCH bpf-next v3 0/5] libbpf: Support gen loader attach Mahe Tardy
2026-11-02 20:13 ` [PATCH bpf-next v3 1/5] libbpf: Count entry programs for bpf_gen__init() Mahe Tardy
2026-11-02 20:45   ` bot+bpf-ci [this message]
2026-11-02 20:13 ` [PATCH bpf-next v3 2/5] libbpf: Track generated loader link FDs Mahe Tardy
2026-11-02 20:13 ` [PATCH bpf-next v3 3/5] libbpf: Emit BPF_LINK_CREATE calls in generated loaders Mahe Tardy
2026-11-02 20:13 ` [PATCH bpf-next v3 4/5] bpftool: Add attach option for light skeleton generation Mahe Tardy
2026-11-02 20:56   ` bot+bpf-ci
2026-11-02 20:13 ` [PATCH bpf-next v3 5/5] selftests/bpf: Test gen loader attach Mahe Tardy

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=c013a7069c06d1120f89eb75e9418938b9e4e71cc81043f41f11cb06d75ca634@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=gyutae.bae@navercorp.com \
    --cc=hi@tychen.cc \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mahe.tardy@gmail.com \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=memxor@gmail.com \
    --cc=qmo@kernel.org \
    --cc=sh_def@163.com \
    --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

all inboxes | Powered by JetHome®