bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] bpf: fix stackmap on perf_events with PEBS
@ 2020-07-11  1:26 Song Liu
  2020-07-11  1:26 ` [PATCH bpf-next 1/5] bpf: block bpf_get_[stack|stackid] on perf_event with PEBS entries Song Liu
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Song Liu @ 2020-07-11  1:26 UTC (permalink / raw)
  To: linux-kernel, bpf, netdev
  Cc: ast, daniel, kernel-team, john.fastabend, kpsingh, brouer,
	peterz, Song Liu

Calling get_perf_callchain() on perf_events from PEBS entries may cause
unwinder errors. To fix this issue, perf subsystem fetches callchain early,
and marks perf_events are marked with __PERF_SAMPLE_CALLCHAIN_EARLY.
Similar issue exists when BPF program calls get_perf_callchain() via
helper functions. For more information about this issue, please refer to
discussions in [1].

This set provides a solution for this problem.

1/5 blocks ioctl(PERF_EVENT_IOC_SET_BPF) attaching BPF program that calls
    get_perf_callchain() to perf events with PEBS entries.
2/5 exposes callchain fetched by perf subsystem to BPF program.
3/5 introduces bpf_get_callchain_stackid(), which is alternative to
    bpf_get_stackid() for perf_event with PEBS.
4/5 adds selftests for 1/5.
5/5 adds selftests for 2/5 and 3/5.

[1] https://lore.kernel.org/lkml/ED7B9430-6489-4260-B3C5-9CFA2E3AA87A@fb.com/

Song Liu (5):
  bpf: block bpf_get_[stack|stackid] on perf_event with PEBS entries
  bpf: add callchain to bpf_perf_event_data
  bpf: introduce bpf_get_callchain_stackid
  selftests/bpf: add get_stackid_cannot_attach
  selftests/bpf: add callchain_stackid

 include/linux/bpf.h                           |  1 +
 include/linux/filter.h                        |  3 +-
 include/linux/perf_event.h                    |  5 --
 include/linux/trace_events.h                  |  5 ++
 include/uapi/linux/bpf.h                      | 43 +++++++++++++
 include/uapi/linux/bpf_perf_event.h           |  7 +++
 kernel/bpf/btf.c                              |  5 ++
 kernel/bpf/stackmap.c                         | 63 ++++++++++++++-----
 kernel/bpf/verifier.c                         |  7 ++-
 kernel/events/core.c                          | 10 +++
 kernel/trace/bpf_trace.c                      | 29 +++++++++
 scripts/bpf_helpers_doc.py                    |  2 +
 tools/include/uapi/linux/bpf.h                | 43 +++++++++++++
 tools/include/uapi/linux/bpf_perf_event.h     |  8 +++
 .../bpf/prog_tests/callchain_stackid.c        | 61 ++++++++++++++++++
 .../prog_tests/get_stackid_cannot_attach.c    | 57 +++++++++++++++++
 .../selftests/bpf/progs/callchain_stackid.c   | 37 +++++++++++
 17 files changed, 364 insertions(+), 22 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/callchain_stackid.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/get_stackid_cannot_attach.c
 create mode 100644 tools/testing/selftests/bpf/progs/callchain_stackid.c

--
2.24.1

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

end of thread, other threads:[~2020-07-12  6:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-11  1:26 [PATCH bpf-next 0/5] bpf: fix stackmap on perf_events with PEBS Song Liu
2020-07-11  1:26 ` [PATCH bpf-next 1/5] bpf: block bpf_get_[stack|stackid] on perf_event with PEBS entries Song Liu
2020-07-11  3:53   ` Andrii Nakryiko
2020-07-11  6:28     ` Song Liu
2020-07-12  5:06       ` Andrii Nakryiko
2020-07-12  6:34         ` Song Liu
2020-07-11  1:26 ` [PATCH bpf-next 2/5] bpf: add callchain to bpf_perf_event_data Song Liu
2020-07-11  1:26 ` [PATCH bpf-next 3/5] bpf: introduce bpf_get_callchain_stackid Song Liu
2020-07-11  1:26 ` [PATCH bpf-next 4/5] selftests/bpf: add get_stackid_cannot_attach Song Liu
2020-07-11  1:26 ` [PATCH bpf-next 5/5] selftests/bpf: add callchain_stackid Song Liu

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