Skip to content

mm/bpf/perf: Store build id in file object

Jiri Olsa bpf linux-fsdevel linux-mm linux-perf-users lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest9 patches 25 repliesIn review
  2. v2 RFC9 patches 14 repliesSuperseded
  3. v1 RFC5 patches 17 repliesSuperseded

Changes in v3 from the cover letter

- moved build id back to file object (discussed in [4])
- drop patch 4, it's not needed [Andrii]
- added ack to patch 7 [Andrii]
- replaced BUILD_ID_SIZE_MAX macro with enum [Andrii]
- few re-formatting fixes [Andrii]

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9mm: Store build id in file objectfs/file_table.c include/linux/buildid.h include/linux/fs.h +3 more+96 -01 reply
2/9perf: Use file object build id in perf_event_mmap_eventkernel/events/core.c+39 -40 replies
3/9bpf: Use file object build id in stackmapkernel/bpf/stackmap.c+23 -11 reply
4/9bpf: Switch BUILD_ID_SIZE_MAX to enuminclude/linux/buildid.h+3 -11 reply
5/9selftests/bpf: Add read_buildid functiontools/testing/selftests/bpf/trace_helpers.c tools/testing/selftests/bpf/trace_helpers.h+91 -02 replies
6/9selftests/bpf: Add err.h headertools/testing/selftests/bpf/progs/err.h tools/testing/selftests/bpf/progs/profiler.inc.h+19 -21 reply
7/9selftests/bpf: Replace extract_build_id with read_build_idtools/testing/selftests/bpf/prog_tests/stacktrace_build_id.c tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c tools/testing/selftests/bpf/test_progs.c +1 more+13 -490 replies
8/9selftests/bpf: Add iter_task_vma_buildid testtools/testing/selftests/bpf/prog_tests/bpf_iter.c tools/testing/selftests/bpf/progs/bpf_iter_task_vma_buildid.c+134 -01 reply
9/9selftests/bpf: Add file_build_id testtools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/no_build_id.c tools/testing/selftests/bpf/prog_tests/file_build_id.c +2 more+190 -12 replies

Reviews trailers per patch

5 of 9 patches have a Reviewed-by or Acked-by.

PatchAndrii Nakryiko
1/9
2/9
3/9A-b
4/9A-b
5/9
6/9A-b
7/9A-b
8/9
9/9A-b

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

Read the v3 thread

Cover letter [PATCHv3 bpf-next 0/9] mm/bpf/perf: Store build id in file object

hi,
this patchset adds build id object pointer to struct file object.

We have several use cases for build id to be used in BPF programs [2][3].

Having build id pointer stored directly in file object allows to get build id reliably regardless of the execution context as described in [3].

Previous iteration [1] stored build id pointer into inode, but it became clear that struct file object is better place, because we read the build id when the file is mmap-ed and as Dave Chinner said [4]:

Quoted 4 lines

Yes, the problem being that we can cache hundreds of millions of inodes in memory, and only a very small subset of them are going to have open files associated with them. And an even smaller subset are going to be mmapped.

thanks,
jirka

v3 changes:
- moved build id back to file object (discussed in [4])
- drop patch 4, it's not needed [Andrii]
- added ack to patch 7 [Andrii]
- replaced BUILD_ID_SIZE_MAX macro with enum [Andrii]
- few re-formatting fixes [Andrii]

v2 changes:
- store build id under inode [Matthew Wilcox]
- use urandom_read and liburandom_read.so for test [Andrii]
- add libelf-based helper to fetch build ID from elf [Andrii]
- store build id or error we got when reading it [Andrii]
- use full name i_build_id [Andrii]
- several tests fixes [Andrii]

[1] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/CA+khW7juLEcrTOd7iKG3C_WY8L265XKNo0iLzV1fE=o-cyeHcQ@mail.gmail.com/
[3] https://lore.kernel.org/bpf/ZABf26mV0D0LS7r%2F@krava/
[4] https://lore.kernel.org/bpf/[email protected]/
---
Jiri Olsa (9):
mm: Store build id in file object
perf: Use file object build id in perf_event_mmap_event
bpf: Use file object build id in stackmap
bpf: Switch BUILD_ID_SIZE_MAX to enum
selftests/bpf: Add read_buildid function
selftests/bpf: Add err.h header
selftests/bpf: Replace extract_build_id with read_build_id
selftests/bpf: Add iter_task_vma_buildid test
selftests/bpf: Add file_build_id test

 fs/file_table.c                                                  |  3 +++
 include/linux/buildid.h                                          | 21 ++++++++++++++++++-
 include/linux/fs.h                                               |  7 +++++++
 kernel/bpf/stackmap.c                                            | 24 +++++++++++++++++++++-
 kernel/events/core.c                                             | 43 ++++++++++++++++++++++++++++++++++----
 lib/buildid.c                                                    | 42 +++++++++++++++++++++++++++++++++++++
 mm/Kconfig                                                       |  9 ++++++++
 mm/mmap.c                                                        | 18 ++++++++++++++++
 tools/testing/selftests/bpf/Makefile                             |  7 ++++++-
 tools/testing/selftests/bpf/no_build_id.c                        |  6 ++++++
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c                | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/file_build_id.c           | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/stacktrace_build_id.c     | 19 +++++++----------
 tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | 17 ++++++---------
 tools/testing/selftests/bpf/progs/bpf_iter_task_vma_buildid.c    | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/err.h                          | 18 ++++++++++++++++
 tools/testing/selftests/bpf/progs/file_build_id.c                | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/profiler.inc.h                 |  3 +--
 tools/testing/selftests/bpf/test_progs.c                         | 25 ----------------------
 tools/testing/selftests/bpf/test_progs.h                         | 11 +++++++++-
 tools/testing/selftests/bpf/trace_helpers.c                      | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/trace_helpers.h                      |  5 +++++
 22 files changed, 608 insertions(+), 58 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/no_build_id.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/file_build_id.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_vma_buildid.c
 create mode 100644 tools/testing/selftests/bpf/progs/err.h
 create mode 100644 tools/testing/selftests/bpf/progs/file_build_id.c