linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3 bpf-next 0/9] mm/bpf/perf: Store build id in file object
@ 2023-03-16 17:01 Jiri Olsa
  2023-03-16 17:01 ` [PATCHv3 bpf-next 1/9] mm: " Jiri Olsa
                   ` (9 more replies)
  0 siblings, 10 replies; 35+ messages in thread
From: Jiri Olsa @ 2023-03-16 17:01 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Hao Luo, Andrew Morton,
	Alexander Viro, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Matthew Wilcox
  Cc: bpf, linux-mm, linux-kernel, linux-fsdevel, linux-perf-users,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Daniel Borkmann, Namhyung Kim,
	Dave Chinner

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]:

> 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/20230228093206.821563-1-jolsa@kernel.org/
[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/20230228220714.GJ2825702@dread.disaster.area/
---
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

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2023-03-31 20:28 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 17:01 [PATCHv3 bpf-next 0/9] mm/bpf/perf: Store build id in file object Jiri Olsa
2023-03-16 17:01 ` [PATCHv3 bpf-next 1/9] mm: " Jiri Olsa
2023-03-16 22:07   ` Andrii Nakryiko
2023-03-16 17:01 ` [PATCHv3 bpf-next 2/9] perf: Use file object build id in perf_event_mmap_event Jiri Olsa
2023-03-16 17:01 ` [PATCHv3 bpf-next 3/9] bpf: Use file object build id in stackmap Jiri Olsa
2023-03-16 22:07   ` Andrii Nakryiko
2023-03-16 17:01 ` [PATCHv3 bpf-next 4/9] bpf: Switch BUILD_ID_SIZE_MAX to enum Jiri Olsa
2023-03-16 22:07   ` Andrii Nakryiko
2023-03-16 17:01 ` [PATCHv3 bpf-next 5/9] selftests/bpf: Add read_buildid function Jiri Olsa
2023-03-16 22:23   ` Andrii Nakryiko
2023-03-30 22:05     ` Jiri Olsa
2023-03-16 17:01 ` [PATCHv3 bpf-next 6/9] selftests/bpf: Add err.h header Jiri Olsa
2023-03-16 22:24   ` Andrii Nakryiko
2023-03-16 17:01 ` [PATCHv3 bpf-next 7/9] selftests/bpf: Replace extract_build_id with read_build_id Jiri Olsa
2023-03-16 17:01 ` [PATCHv3 bpf-next 8/9] selftests/bpf: Add iter_task_vma_buildid test Jiri Olsa
2023-03-16 22:31   ` Andrii Nakryiko
2023-03-16 17:01 ` [PATCHv3 bpf-next 9/9] selftests/bpf: Add file_build_id test Jiri Olsa
2023-03-16 19:59   ` Daniel Borkmann
2023-03-16 22:36   ` Andrii Nakryiko
2023-03-16 17:34 ` [PATCHv3 bpf-next 0/9] mm/bpf/perf: Store build id in file object Matthew Wilcox
2023-03-16 17:50   ` Ian Rogers
2023-03-16 21:51     ` Andrii Nakryiko
2023-03-17  3:51       ` Matthew Wilcox
2023-03-17 16:33         ` Andrii Nakryiko
2023-03-17 21:14           ` Al Viro
2023-03-17 21:21             ` Al Viro
2023-03-18  6:08               ` Andrii Nakryiko
2023-03-18  8:34                 ` Jiri Olsa
2023-03-18  8:33   ` Jiri Olsa
2023-03-18 15:16     ` Matthew Wilcox
2023-03-18 17:40       ` Jiri Olsa
2023-03-22 15:45       ` Arnaldo Carvalho de Melo
2023-03-31 18:19         ` Andrii Nakryiko
2023-03-31 18:36           ` Matthew Wilcox
2023-03-31 20:27             ` Andrii Nakryiko

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).