All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
	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,
	qmo@kernel.org, shuah@kernel.org, yatsenko@meta.com,
	avinash.duduskar@gmail.com, a.s.protopopov@gmail.com,
	ameryhung@gmail.com, jordan@jrife.io, rongtao@cestc.cn,
	eyal.birger@gmail.com, pulehui@huawei.com, tanjingguo@huawei.com,
	malin89@huawei.com, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, martin.lau@kernel.org,
	clm@meta.com
Subject: Re: [PATCH bpf-next 06/13] bpf: Add tracing_multi link fdinfo support for bpf progs
Date: Wed, 12 Aug 2026 12:04:32 +0800	[thread overview]
Message-ID: <11079006-dc15-4474-bd35-a8386b42d34f@linux.dev> (raw)
In-Reply-To: <f227b719d241d4cc87954725d9ddaab8377c9991c7b6b03aaef4aa5d098fcca7@mail.kernel.org>

On 10/8/26 00:20, bot+bpf-ci@kernel.org wrote:
>> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
>> index a805a5b73303f..80928401830c7 100644
>> --- a/kernel/trace/bpf_trace.c
>> +++ b/kernel/trace/bpf_trace.c
>> @@ -3759,26 +3759,46 @@ static int bpf_tracing_multi_link_fill_link_info(const struct bpf_link *link,
>>  }
>>
>>  #ifdef CONFIG_PROC_FS
>> +static const char *bpf_prog_func_name(struct bpf_prog *prog, u32 btf_id)
>> +{
>> +	const struct btf *btf = prog->aux->btf;
>> +	const struct btf_type *t;
>> +
>> +	t = btf_type_by_id(btf, btf_id);
>> +	if (!t || !btf_type_is_func(t))
>> +		return "";
>> +
>> +	return btf_name_by_offset(btf, t->name_off);
>> +}
>> +
>>  static void bpf_tracing_multi_show_fdinfo(const struct bpf_link *link,
>>  					  struct seq_file *seq)
>>  {
>>  	struct bpf_tracing_multi_link *tr_link =
>>  		container_of(link, struct bpf_tracing_multi_link, link);
>>  	bool has_cookies = !!tr_link->cookies;
>> +	bool has_progs = !!tr_link->progs;
>>
>>  	seq_printf(seq, "attach_type:\t%u\n", tr_link->link.attach_type);
>>  	seq_printf(seq, "cnt:\t%u\n", tr_link->nodes_cnt);
>>
>> -	seq_printf(seq, "%s\t %s\t %s\t %s\n", "obj-id", "btf-id", "cookie", "func");
>> +	seq_printf(seq, "%s\t %s\t %s\t %s\n", has_progs ? "prog-id" : "obj-id", "btf-id", "cookie",
>> +		   "func");
>>  	for (int i = 0; i < tr_link->nodes_cnt; i++) {
>>  		struct bpf_tracing_multi_node *mnode = &tr_link->nodes[i];
>> +		u64 cookie = has_cookies ? tr_link->cookies[i] : 0;
>>  		u32 btf_id, obj_id;
>>
>>  		bpf_trampoline_unpack_key(mnode->trampoline->key, &obj_id, &btf_id);
>> +		btf_id = has_progs ? (u32) mnode->trampoline->key : btf_id;
>                         ^^^^
> 
> This isn't a bug, but since bpf_trampoline_unpack_key() only masks off
> bit 31, which is never set for prog targets, does this re-assignment
> change anything, or could the unpacked value be used directly?
> 
> bpf_trampoline_unpack_key() already sets btf_id = key & 0x7FFFFFFF, and
> bit 31 is only set by the !tgt_prog branch of bpf_trampoline_compute_key()
> (the kernel-BTF case).
> 
> In the has_progs case the key was built as:
> 
>     ((u64)tgt_prog->aux->id << 32) | ids[i]
> 
> and ids[i] must be a valid BTF type id (<= BTF_MAX_TYPE, 0xfffff) or
> bpf_check_attach_target() would have rejected the attach, so (u32)key
> and the unpacked btf_id are always equal here.
> 

Good catch.

Will drop this line.

>> +		if (has_progs)
>> +			seq_printf(seq, "%u\t %u\t %llu\t %s\n",
>> +				   obj_id, btf_id, cookie,
>> +				   bpf_prog_func_name(tr_link->progs[i], btf_id));
>> +		else
>> +			seq_printf(seq, "%u\t %u\t %llu\t %pS\n",
>> +				   obj_id, btf_id, cookie,
>> +				   (void *) mnode->trampoline->ip);
>>
>>  		cond_resched();
>>  	}
> 
> The commit message shows the sample fdinfo output but doesn't say much
> about the implementation or why this change is needed. In particular:
> 
>> Show the target bpf prog info in the fdinfo.
>>
>> $ cat /proc/self/fdinfo/13
>> pos:    0
>> flags:  02000000
>> mnt_id: 18
>> ino:    1045
>> link_type:      tracing_multi
>> link_id:        9
>> prog_tag:       9a7f9e3ab6f138ab
>> prog_id:        25
>> attach_type:    61
>> cnt:    2
>> prog-id  btf-id  cookie  func
>> 21       4       16706819        target_1
>> 22       5       16706819        target_2
> 
> This isn't a bug, but could the changelog say why the trampoline ip is
> not usable as the func column for prog targets (tr->ip is 0 for JIT'd
> prog addresses), rather than mostly showing the resulting output? It
> also doesn't mention that the first column header changes from "obj-id"
> to "prog-id" for prog-target links.
> 

Hmm, will describe the change in the commit msg.

Thanks,
Leon

> 
> ---
> 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/31320427087


  reply	other threads:[~2026-08-12  4:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09 15:00 [PATCH bpf-next 00/13] bpf: Add tracing_multi link support for bpf progs Leon Hwang
2026-08-09 15:00 ` [PATCH bpf-next 01/13] bpf: Initialize ftrace_managed in bpf_trampoline_get Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 02/13] bpf: Factor out update_fentry_multi helper Leon Hwang
2026-08-09 15:14   ` sashiko-bot
2026-08-12  4:02     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 03/13] bpf: Drop unnecessary ftrace_location() in update_fentry_multi() Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 04/13] bpf: Add tracing_multi link support for bpf progs Leon Hwang
2026-08-09 15:33   ` sashiko-bot
2026-08-12  4:03     ` Leon Hwang
2026-08-10 13:13   ` Jiri Olsa
2026-08-11  6:12     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 05/13] libbpf: " Leon Hwang
2026-08-09 15:21   ` sashiko-bot
2026-08-12  4:03     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 06/13] bpf: Add tracing_multi link fdinfo " Leon Hwang
2026-08-09 16:20   ` bot+bpf-ci
2026-08-12  4:04     ` Leon Hwang [this message]
2026-08-09 15:01 ` [PATCH bpf-next 07/13] bpf: Add tracing_multi link info " Leon Hwang
2026-08-09 15:17   ` sashiko-bot
2026-08-12  4:05     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 08/13] selftests/bpf: Add tracing_multi bpf prog attach test Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 09/13] selftests/bpf: Add tracing_multi bpf prog attach failure tests Leon Hwang
2026-08-09 15:17   ` sashiko-bot
2026-08-12  4:06     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 10/13] selftests/bpf: Add tracing_multi bpf prog cookie test Leon Hwang
2026-08-09 16:20   ` bot+bpf-ci
2026-08-12  4:06     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 11/13] selftests/bpf: Add tracing_multi bpf prog rollback test Leon Hwang
2026-08-09 15:21   ` sashiko-bot
2026-08-12  4:07     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 12/13] selftests/bpf: Add tracing_multi bpf prog link info test Leon Hwang
2026-08-09 15:29   ` sashiko-bot
2026-08-12  4:08     ` Leon Hwang
2026-08-09 15:01 ` [PATCH bpf-next 13/13] selftests/bpf: Test tailcall with fentry.multi Leon Hwang

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=11079006-dc15-4474-bd35-a8386b42d34f@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=a.s.protopopov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=avinash.duduskar@gmail.com \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=eyal.birger@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jordan@jrife.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=malin89@huawei.com \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=pulehui@huawei.com \
    --cc=qmo@kernel.org \
    --cc=rongtao@cestc.cn \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tanjingguo@huawei.com \
    --cc=yatsenko@meta.com \
    --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 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.