From: Song Liu <songliubraving@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <peterz@infradead.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
<kernel-team@fb.com>, <john.fastabend@gmail.com>,
<kpsingh@chromium.org>, Song Liu <songliubraving@fb.com>
Subject: [PATCH v4 bpf-next 0/4] bpf: introduce bpf_get_task_stack()
Date: Sun, 28 Jun 2020 22:55:26 -0700 [thread overview]
Message-ID: <20200629055530.3244342-1-songliubraving@fb.com> (raw)
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 v3 => v4:
1. Simplify the selftests with bpf_iter.h. (Yonghong)
2. Add example output to commit log of 4/4. (Yonghong)
Changes v2 => v3:
1. Rebase on top of bpf-next. (Yonghong)
2. Sanitize get_callchain_entry(). (Peter)
3. Use has_callchain_buf for bpf_get_task_stack. (Andrii)
4. Other small clean up. (Yonghong, Andrii).
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: expose get/put_callchain_entry()
bpf: introduce helper bpf_get_task_stack()
bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk()
selftests/bpf: add bpf_iter test with bpf_get_task_stack()
include/linux/bpf.h | 1 +
include/linux/perf_event.h | 2 +
include/uapi/linux/bpf.h | 36 ++++++++-
kernel/bpf/stackmap.c | 75 ++++++++++++++++++-
kernel/bpf/verifier.c | 4 +-
kernel/events/callchain.c | 13 ++--
kernel/trace/bpf_trace.c | 12 ++-
scripts/bpf_helpers_doc.py | 2 +
tools/include/uapi/linux/bpf.h | 36 ++++++++-
.../selftests/bpf/prog_tests/bpf_iter.c | 17 +++++
.../selftests/bpf/progs/bpf_iter_task_stack.c | 37 +++++++++
11 files changed, 220 insertions(+), 15 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c
--
2.24.1
next reply other threads:[~2020-06-29 18:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 5:55 Song Liu [this message]
2020-06-29 5:55 ` [PATCH v4 bpf-next 1/4] perf: expose get/put_callchain_entry() Song Liu
2020-06-29 5:55 ` [PATCH v4 bpf-next 2/4] bpf: introduce helper bpf_get_task_stack() Song Liu
2020-06-30 4:18 ` Alexei Starovoitov
2020-06-30 6:12 ` Song Liu
2020-06-29 5:55 ` [PATCH v4 bpf-next 3/4] bpf: allow %pB in bpf_seq_printf() and bpf_trace_printk() Song Liu
2020-06-29 5:55 ` [PATCH v4 bpf-next 4/4] selftests/bpf: add bpf_iter test with bpf_get_task_stack() Song Liu
2020-06-29 15:06 ` Yonghong Song
2020-06-29 16:56 ` Song Liu
2020-06-29 18:22 ` Yonghong Song
2020-06-29 19:25 ` [PATCH v4 bpf-next 0/4] bpf: introduce bpf_get_task_stack() Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200629055530.3244342-1-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.