linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/4] bpf: introduce bpf_get_task_stack()
@ 2020-06-26  0:13 Song Liu
  2020-06-26  0:13 ` [PATCH v2 bpf-next 1/4] perf: export get/put_chain_entry() Song Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Song Liu @ 2020-06-26  0:13 UTC (permalink / raw)
  To: bpf, netdev, linux-kernel
  Cc: peterz, ast, daniel, kernel-team, john.fastabend, kpsingh, Song Liu

This set introduces a new helper bpf_get_task_stack(). The primary use case
is to dump all /proc/*/stack to seq_file via bpf_iter__task.

A few different approaches have been explored and compared:

  1. A simple wrapper around stack_trace_save_tsk(), as v1 [1].

     This approach introduces new syntax, which is different to existing
     helper bpf_get_stack(). Therefore, this is not ideal.

  2. Extend get_perf_callchain() to support "task" as argument.

     This approach reuses most of bpf_get_stack(). However, extending
     get_perf_callchain() requires non-trivial changes to architecture
     specific code. Which is error prone.

  3. Current (v2) approach, leverages most of existing bpf_get_stack(), and
     uses stack_trace_save_tsk() to handle architecture specific logic.

[1] https://lore.kernel.org/netdev/20200623070802.2310018-1-songliubraving@fb.com/

Changes v1 => v2:
1. Reuse most of bpf_get_stack() logic. (Andrii)
2. Fix unsigned long vs. u64 mismatch for 32-bit systems. (Yonghong)
3. Add %pB support in bpf_trace_printk(). (Daniel)
4. Fix buffer size to bytes.

Song Liu (4):
  perf: export get/put_chain_entry()
  bpf: introduce helper bpf_get_task_stak()
  bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk()
  selftests/bpf: add bpf_iter test with bpf_get_task_stack_trace()

 include/linux/bpf.h                           |  1 +
 include/linux/perf_event.h                    |  2 +
 include/uapi/linux/bpf.h                      | 35 +++++++-
 kernel/bpf/stackmap.c                         | 79 ++++++++++++++++++-
 kernel/events/callchain.c                     |  4 +-
 kernel/trace/bpf_trace.c                      | 14 +++-
 scripts/bpf_helpers_doc.py                    |  2 +
 tools/include/uapi/linux/bpf.h                | 35 +++++++-
 .../selftests/bpf/prog_tests/bpf_iter.c       | 17 ++++
 .../selftests/bpf/progs/bpf_iter_task_stack.c | 60 ++++++++++++++
 10 files changed, 239 insertions(+), 10 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c

--
2.24.1

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

end of thread, other threads:[~2020-06-27  0:06 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26  0:13 [PATCH v2 bpf-next 0/4] bpf: introduce bpf_get_task_stack() Song Liu
2020-06-26  0:13 ` [PATCH v2 bpf-next 1/4] perf: export get/put_chain_entry() Song Liu
2020-06-26 11:00   ` Peter Zijlstra
2020-06-26 20:06     ` Andrii Nakryiko
2020-06-26 21:38       ` Song Liu
2020-06-26 21:29     ` Song Liu
2020-06-26  0:13 ` [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf_get_task_stak() Song Liu
2020-06-26 15:40   ` Yonghong Song
2020-06-26 22:37     ` Song Liu
2020-06-26 20:17   ` Andrii Nakryiko
2020-06-26 20:22     ` Andrii Nakryiko
2020-06-26 22:45     ` Song Liu
2020-06-26 22:51       ` Andrii Nakryiko
2020-06-26 23:47         ` Song Liu
2020-06-27  0:06           ` Andrii Nakryiko
2020-06-26  0:13 ` [PATCH v2 bpf-next 3/4] bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk() Song Liu
2020-06-26 15:44   ` [Potential Spoof] " Yonghong Song
2020-06-26  0:13 ` [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack() Song Liu
2020-06-26 15:52   ` Yonghong Song
2020-06-26 20:21   ` Andrii Nakryiko
2020-06-26 23:05     ` Song Liu
2020-06-26 23:11       ` Andrii Nakryiko
2020-06-26 23:40         ` 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).