From: Quentin Monnet <quentin@isovalent.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, yhs@fb.com
Subject: Re: [PATCH bpf-next v6] bpftool: Add bpf_cookie to link output
Date: Sun, 27 Mar 2022 23:03:49 +0100 [thread overview]
Message-ID: <6b558a11-7f5e-8a4e-b70b-e4c7d3c3e052@isovalent.com> (raw)
In-Reply-To: <20220326090834.f7ukfgjyfhk6sbws@erthalion.local>
2022-03-26 10:08 UTC+0100 ~ Dmitry Dolgov <9erthalion6@gmail.com>
>> On Sat, Mar 26, 2022 at 01:38:36AM +0000, Quentin Monnet wrote:
>> 2022-03-09 17:31 UTC+0100 ~ Dmitrii Dolgov <9erthalion6@gmail.com>
>>> Commit 82e6b1eee6a8 ("bpf: Allow to specify user-provided bpf_cookie for
>>> BPF perf links") introduced the concept of user specified bpf_cookie,
>>> which could be accessed by BPF programs using bpf_get_attach_cookie().
>>> For troubleshooting purposes it is convenient to expose bpf_cookie via
>>> bpftool as well, so there is no need to meddle with the target BPF
>>> program itself.
>>>
>>> [...]
>>>
>>> diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c
>>> index 7c384d10e95f..bb6c969a114a 100644
>>> --- a/tools/bpf/bpftool/pids.c
>>> +++ b/tools/bpf/bpftool/pids.c
>>> @@ -78,6 +78,8 @@ static void add_ref(struct hashmap *map, struct pid_iter_entry *e)
>>> ref->pid = e->pid;
>>> memcpy(ref->comm, e->comm, sizeof(ref->comm));
>>> refs->ref_cnt = 1;
>>> + refs->has_bpf_cookie = e->has_bpf_cookie;
>>> + refs->bpf_cookie = e->bpf_cookie;
>>>
>>> err = hashmap__append(map, u32_as_hash_field(e->id), refs);
>>> if (err)
>>> @@ -205,6 +207,9 @@ void emit_obj_refs_json(struct hashmap *map, __u32 id,
>>> if (refs->ref_cnt == 0)
>>> break;
>>>
>>> + if (refs->has_bpf_cookie)
>>> + jsonw_lluint_field(json_writer, "bpf_cookie", refs->bpf_cookie);
>>> +
>>
>> Thinking again about this patch, shouldn't the JSON output for the
>> cookie(s) be an array if we expect to have several cookies for
>> multi-attach links in the future?
>
> Interesting point. My impression is that this could be done together
> with the other changes about making multi-attach links possible (I
> didn't miss anything, it's not yet implemented, right?). On the other
> hand I'm planning to prepare few more patches in similar direction -- so
> if everyone agrees it has to be extended to an array now, I can tackle
> this as well.
Correct, it's not implemented yet for multi-attach links. My concern
here is to avoid changing the JSON structure in the future (to avoid
breaking changes for tools that would process the JSON). If we know
we're likely to have several cookies in the future, it may be worth
using an array “from start” (since no version has been tagged yet after
you added support for the cookie).
Quentin
next prev parent reply other threads:[~2022-03-27 22:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 16:31 [PATCH bpf-next v6] bpftool: Add bpf_cookie to link output Dmitrii Dolgov
2022-03-11 22:24 ` Andrii Nakryiko
2022-03-12 22:59 ` Quentin Monnet
2022-03-15 18:33 ` Andrii Nakryiko
2022-03-15 21:01 ` Quentin Monnet
2022-03-15 22:10 ` patchwork-bot+netdevbpf
2022-03-26 1:38 ` Quentin Monnet
2022-03-26 9:08 ` Dmitry Dolgov
2022-03-27 22:03 ` Quentin Monnet [this message]
2022-03-28 13:06 ` Dmitry Dolgov
2022-03-28 21:39 ` Andrii Nakryiko
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=6b558a11-7f5e-8a4e-b70b-e4c7d3c3e052@isovalent.com \
--to=quentin@isovalent.com \
--cc=9erthalion6@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=yhs@fb.com \
/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