Skip to content

bpf: add a ksym BPF iterator

Alan Maguire bpf lkml 6 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest2 patches 0 repliesApplied 2/2
  2. v52 patches 1 replySuperseded
  3. v42 patches 3 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v32 patches3 repliesSuperseded
v22 patches5 repliesSuperseded
v1 RFC2 patches1 replySuperseded

Patches in v6 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: add a ksym BPF iteratorkernel/kallsyms.c+91 -00 repliesApplied
2/2selftests/bpf: add a ksym iter subtesttools/testing/selftests/bpf/prog_tests/bpf_iter.c tools/testing/selftests/bpf/progs/bpf_iter.h tools/testing/selftests/bpf/progs/bpf_iter_ksym.c+97 -00 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchYonghong Song
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 bpf-next 0/2] bpf: add a ksym BPF iterator

a ksym BPF iterator would be useful as it would allow more flexible interactions with kernel symbols than are currently supported; it could for example create more efficient map representations for lookup, speed up symbol resolution etc.

The idea was initially discussed here [1].

Changes since v5 [2]:
- no need to add kallsym_iter to bpf_iter.h as it has existed in kernels for a long time so will by in vmlinux.h for older kernels too, unlike struct bpf_iter__ksym (Yonghong, patch 2)

Changes since v4 [3]:

- add BPF_ITER_RESCHED to improve responsiveness (Hao, patch 1)
- remove pr_warn to be consistent with other iterators (Andrii, patch 1)
- add definitions to bpf_iter.h to ensure iter tests build on older kernels (Andrii, patch 2)

Changes since v3 [4]:

- use late_initcall() to register iter; means we are both consistent with other iters and can encapsulate all iter-specific code in kallsyms.c in CONFIG_BPF_SYSCALL (Alexei, Yonghong, patch 1).

Changes since v2 [5]:

- set iter->show_value on initialization based on current creds and use it in selftest to determine if we show values (Yonghong, patches 1/2)
- inline iter registration into kallsyms_init (Yonghong, patch 1)

Changes since RFC [6]:

- change name of iterator (and associated structures/fields) to "ksym" (Andrii, patches 1, 2)
- remove dependency on CONFIG_PROC_FS; it was used for other BPF iterators, and I assumed it was needed because of seq ops but I don't think it is required on digging futher (Andrii, patch 1)

[1] https://lore.kernel.org/all/YjRPZj6Z8vuLeEZo@krava/
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/
[4] https://lore.kernel.org/bpf/[email protected]
[5] https://lore.kernel.org/bpf/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/

Alan Maguire (2):
bpf: add a ksym BPF iterator
selftests/bpf: add a ksym iter subtest

 kernel/kallsyms.c                                 | 91 +++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 16 ++++
 tools/testing/selftests/bpf/progs/bpf_iter.h      |  7 ++
 tools/testing/selftests/bpf/progs/bpf_iter_ksym.c | 74 ++++++++++++++++++
 4 files changed, 188 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_ksym.c
Signature · 1 line
1.8.3.1