Message ID | 20210225073319.4121535-1-yhs@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: add bpf_for_each_map_elem() helper | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 6 maintainers not CCed: netdev@vger.kernel.org kpsingh@kernel.org songliubraving@fb.com kafai@fb.com john.fastabend@gmail.com andrii@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 9 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Thu, Feb 25, 2021 at 1:35 AM 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[+17] > 30: (18) r2 = subprog[+25] > ... > 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[-47] > > Signed-off-by: Yonghong Song <yhs@fb.com> > --- Acked-by: Andrii Nakryiko <andrii@kernel.org> > 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..6fc3e6f7f40c 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); > else > snprintf(dd->scratch_buff, sizeof(dd->scratch_buff), > "0x%llx", (unsigned long long)full_imm); > -- > 2.24.1 >
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c index 8608cd68cdd0..6fc3e6f7f40c 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); else snprintf(dd->scratch_buff, sizeof(dd->scratch_buff), "0x%llx", (unsigned long long)full_imm);
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[+17] 30: (18) r2 = subprog[+25] ... 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[-47] Signed-off-by: Yonghong Song <yhs@fb.com> --- tools/bpf/bpftool/xlated_dumper.c | 3 +++ 1 file changed, 3 insertions(+)