From: Yonghong Song <yhs@fb.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Cong Wang <xiyou.wangcong@gmail.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next v2 09/11] bpftool: print local function pointer properly
Date: Tue, 23 Feb 2021 11:00:36 -0800 [thread overview]
Message-ID: <916d6dba-d5d7-597b-6be8-7aca43aaacf3@fb.com> (raw)
In-Reply-To: <CAEf4BzYgtusa_e3ULwgh4ZCsVRqpVRXi-rnmPrxWyk0WoFt_8g@mail.gmail.com>
On 2/23/21 12:06 AM, Andrii Nakryiko wrote:
> On Wed, Feb 17, 2021 at 12:56 PM Yonghong Song <yhs@fb.com> wrote:
>>
>> With later hashmap example, using bpftool xlated output may
>> look like:
>> int dump_task(struct bpf_iter__task * ctx):
>> ; struct task_struct *task = ctx->task;
>> 0: (79) r2 = *(u64 *)(r1 +8)
>> ; if (task == (void *)0 || called > 0)
>> ...
>> 19: (18) r2 = subprog[+18]
>> 30: (18) r2 = subprog[+26]
>> ...
>> 36: (95) exit
>> __u64 check_hash_elem(struct bpf_map * map, __u32 * key, __u64 * val,
>> struct callback_ctx * data):
>> ; struct bpf_iter__task *ctx = data->ctx;
>> 37: (79) r5 = *(u64 *)(r4 +0)
>> ...
>> 55: (95) exit
>> __u64 check_percpu_elem(struct bpf_map * map, __u32 * key,
>> __u64 * val, void * unused):
>> ; check_percpu_elem(struct bpf_map *map, __u32 *key, __u64 *val, void *unused)
>> 56: (bf) r6 = r3
>> ...
>> 83: (18) r2 = subprog[-46]
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>> ---
>> tools/bpf/bpftool/xlated_dumper.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
>> index 8608cd68cdd0..b87caae2e7da 100644
>> --- a/tools/bpf/bpftool/xlated_dumper.c
>> +++ b/tools/bpf/bpftool/xlated_dumper.c
>> @@ -196,6 +196,9 @@ static const char *print_imm(void *private_data,
>> else if (insn->src_reg == BPF_PSEUDO_MAP_VALUE)
>> snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
>> "map[id:%u][0]+%u", insn->imm, (insn + 1)->imm);
>> + else if (insn->src_reg == BPF_PSEUDO_FUNC)
>> + snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
>> + "subprog[%+d]", insn->imm + 1);
>
> print_call_pcrel() doesn't do +1 adjustment, why is it needed here?
original intention is to have imm + 1, so user will directly get to the
target insn. But yes, it makes sense to be consistent here. bpf
programmer may already know to add 1 implicitly to the current insn
index for the target. Will fix in the next version.
>
>> else
>> snprintf(dd->scratch_buff, sizeof(dd->scratch_buff),
>> "0x%llx", (unsigned long long)full_imm);
>> --
>> 2.24.1
>>
next prev parent reply other threads:[~2021-02-23 19:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-17 18:18 [PATCH bpf-next v2 00/11] bpf: add bpf_for_each_map_elem() helper Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 01/11] bpf: factor out visit_func_call_insn() in check_cfg() Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 02/11] bpf: factor out verbose_invalid_scalar() Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 03/11] bpf: refactor check_func_call() to allow callback function Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 04/11] bpf: add bpf_for_each_map_elem() helper Yonghong Song
2021-02-22 20:59 ` Alexei Starovoitov
2021-02-23 18:39 ` Yonghong Song
2021-02-23 18:46 ` Alexei Starovoitov
2021-02-23 19:37 ` Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 05/11] bpf: add hashtab support for " Yonghong Song
2021-02-22 22:56 ` Alexei Starovoitov
2021-02-23 18:41 ` Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 06/11] bpf: add arraymap " Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 07/11] libbpf: move function is_ldimm64() earlier in libbpf.c Yonghong Song
2021-02-23 8:06 ` Andrii Nakryiko
2021-02-17 18:18 ` [PATCH bpf-next v2 08/11] libbpf: support local function pointer relocation Yonghong Song
2021-02-23 8:03 ` Andrii Nakryiko
2021-02-23 18:55 ` Yonghong Song
2021-02-23 19:07 ` Alexei Starovoitov
2021-02-23 19:21 ` Andrii Nakryiko
2021-02-23 19:19 ` Andrii Nakryiko
2021-02-23 19:47 ` Yonghong Song
2021-02-23 21:24 ` Andrii Nakryiko
2021-02-17 18:18 ` [PATCH bpf-next v2 09/11] bpftool: print local function pointer properly Yonghong Song
2021-02-23 8:06 ` Andrii Nakryiko
2021-02-23 19:00 ` Yonghong Song [this message]
2021-02-17 18:18 ` [PATCH bpf-next v2 10/11] selftests/bpf: add hashmap test for bpf_for_each_map_elem() helper Yonghong Song
2021-02-17 18:18 ` [PATCH bpf-next v2 11/11] selftests/bpf: add arraymap " Yonghong Song
2021-02-17 18:29 ` [PATCH bpf-next v2 00/11] bpf: add " Yonghong Song
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=916d6dba-d5d7-597b-6be8-7aca43aaacf3@fb.com \
--to=yhs@fb.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=xiyou.wangcong@gmail.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;
as well as URLs for NNTP newsgroup(s).