bpf: add main_thread_only customization for task/task_file iterators
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | bpf: make bpf_link_info.iter similar to bpf_iter_link_infoinclude/ tools/ | +8 | 1 reply | |
| 2/5 | bpf: add main_thread_only customization for task/task_file iteratorsinclude/ include/ kernel/ +1 more | +43 | 4 replies | |
| 3/5 | bpf: add link_query support for newly added main_thread_only infoinclude/ kernel/ tools/ | +27 | 1 reply | |
| 4/5 | bpftool: support optional 'task main_thread_only' argumenttools/ tools/ tools/ +1 more | +59 | 0 replies | |
| 5/5 | selftests/bpf: test task_file iterator with main_thread_onlytools/ tools/ | +46 | 0 replies |
Reviews trailers per patch
1 of 5 patches has a Reviewed-by or Acked-by.
| Patch | Andrii Nakryiko |
|---|---|
| 1/5 | A-b |
| 2/5 | |
| 3/5 | |
| 4/5 | |
| 5/5 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next 0/5] bpf: add main_thread_only customization for task/task_file iterators
Commit e679654a704e ("bpf: Fix a rcu_sched stall issue with bpf task/task_file iterator") introduced rate limiting in bpf_seq_read() to fix a case where traversing too many tasks and files (tens of millions of files) may cause kernel rcu stall. But rate limiting won't reduce the amount of work to traverse all these files.
In practice, for a user process, typically all threads belongs to that process share the same file table and there is no need to visit every thread for its files.
This patch implemented a customization for task/task_file iterators to traverse files only for thread with task->tgid == task->pid, which will include some kernel threads and user process main threads. Such reduction of unnecessary work will make iterator runtime much faster if there are a lot of non-main threads and open files for the process.
Patch #1 fix an uapi issue for bpf_link_info.iter. Patch #2 implemented the main_thread_only customization for task/task_file iterators.
Patch #3 added link_query support for new customization. Patch #4 added bpftool support and Patch #5 added a selftest.
Yonghong Song (5):
bpf: make bpf_link_info.iter similar to bpf_iter_link_info
bpf: add main_thread_only customization for task/task_file iterators
bpf: add link_query support for newly added main_thread_only info
bpftool: support optional 'task main_thread_only' argument selftests/bpf: test task_file iterator with main_thread_only
include/linux/bpf.h | 3 +- include/uapi/linux/bpf.h | 16 ++++- kernel/bpf/task_iter.c | 63 ++++++++++++++----- .../bpftool/Documentation/bpftool-iter.rst | 17 ++++- tools/bpf/bpftool/bash-completion/bpftool | 9 ++- tools/bpf/bpftool/iter.c | 28 +++++++-- tools/bpf/bpftool/link.c | 12 ++++ tools/include/uapi/linux/bpf.h | 16 ++++- .../selftests/bpf/prog_tests/bpf_iter.c | 50 +++++++++++---- .../selftests/bpf/progs/bpf_iter_task_file.c | 9 ++- 10 files changed, 183 insertions(+), 40 deletions(-)
Signature · 1 line
2.24.1