From: Song Liu <songliubraving@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <kernel-team@fb.com>,
<peterz@infradead.org>, Song Liu <songliubraving@fb.com>
Subject: [PATCH v4 bpf-next 0/6] bpf: enable task local storage for tracing programs
Date: Mon, 22 Feb 2021 17:20:08 -0800 [thread overview]
Message-ID: <20210223012014.2087583-1-songliubraving@fb.com> (raw)
This set enables task local storage for non-BPF_LSM programs.
It is common for tracing BPF program to access per-task data. Currently,
these data are stored in hash tables with pid as the key. In
bcc/libbpftools [1], 9 out of 23 tools use such hash tables. However,
hash table is not ideal for many use case. Task local storage provides
better usability and performance for BPF programs. Please refer to 4/4 for
some performance comparison of task local storage vs. hash table.
Changes v3 => v4:
1. Prevent deadlock from recursive calls of bpf_task_storage_[get|delete].
(2/6 checks potential deadlock and fails over, 4/6 adds a selftest).
Changes v2 => v3:
1. Make the selftest more robust. (Andrii)
2. Small changes with runqslower. (Andrii)
3. Shortern CC list to make it easy for vger.
Changes v1 => v2:
1. Do not allocate task local storage when the task is being freed.
2. Revise the selftest and added a new test for a task being freed.
3. Minor changes in runqslower.
Song Liu (6):
bpf: enable task local storage for tracing programs
bpf: prevent deadlock from recursive bpf_task_storage_[get|delete]
selftests/bpf: add non-BPF_LSM test for task local storage
selftests/bpf: test deadlock from recursive
bpf_task_storage_[get|delete]
bpf: runqslower: prefer using local vmlimux to generate vmlinux.h
bpf: runqslower: use task local storage
include/linux/bpf.h | 7 ++
include/linux/bpf_lsm.h | 22 -----
include/linux/bpf_types.h | 2 +-
include/linux/sched.h | 5 +
kernel/bpf/Makefile | 3 +-
kernel/bpf/bpf_local_storage.c | 28 +++---
kernel/bpf/bpf_lsm.c | 4 -
kernel/bpf/bpf_task_storage.c | 89 +++++++++++-------
kernel/fork.c | 5 +
kernel/trace/bpf_trace.c | 4 +
tools/bpf/runqslower/Makefile | 5 +-
tools/bpf/runqslower/runqslower.bpf.c | 33 ++++---
.../bpf/prog_tests/task_local_storage.c | 92 +++++++++++++++++++
.../selftests/bpf/progs/task_local_storage.c | 64 +++++++++++++
.../bpf/progs/task_local_storage_exit_creds.c | 32 +++++++
.../selftests/bpf/progs/task_ls_recursion.c | 70 ++++++++++++++
16 files changed, 381 insertions(+), 84 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/task_local_storage.c
create mode 100644 tools/testing/selftests/bpf/progs/task_local_storage.c
create mode 100644 tools/testing/selftests/bpf/progs/task_local_storage_exit_creds.c
create mode 100644 tools/testing/selftests/bpf/progs/task_ls_recursion.c
--
2.24.1
next reply other threads:[~2021-02-23 1:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 1:20 Song Liu [this message]
2021-02-23 1:20 ` [PATCH v4 bpf-next 1/6] bpf: enable task local storage for tracing programs Song Liu
2021-02-23 3:08 ` kernel test robot
2021-02-23 4:04 ` kernel test robot
2021-02-23 19:23 ` Martin KaFai Lau
2021-02-23 20:51 ` Song Liu
2021-02-23 1:20 ` [PATCH v4 bpf-next 2/6] bpf: prevent deadlock from recursive bpf_task_storage_[get|delete] Song Liu
2021-02-23 6:21 ` Andrii Nakryiko
2021-02-23 7:16 ` Song Liu
2021-02-23 7:19 ` Andrii Nakryiko
2021-02-23 16:44 ` Alexei Starovoitov
2021-02-23 11:06 ` Peter Zijlstra
2021-02-23 20:49 ` Song Liu
2021-02-23 1:20 ` [PATCH v4 bpf-next 3/6] selftests/bpf: add non-BPF_LSM test for task local storage Song Liu
2021-02-23 1:20 ` [PATCH v4 bpf-next 4/6] selftests/bpf: test deadlock from recursive bpf_task_storage_[get|delete] Song Liu
2021-02-23 1:20 ` [PATCH v4 bpf-next 5/6] bpf: runqslower: prefer using local vmlimux to generate vmlinux.h Song Liu
2021-02-23 6:26 ` Andrii Nakryiko
2021-02-23 21:24 ` Martin KaFai Lau
2021-02-23 1:20 ` [PATCH v4 bpf-next 6/6] bpf: runqslower: use task local storage Song Liu
2021-02-23 21:33 ` Martin KaFai Lau
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=20210223012014.2087583-1-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--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 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).