bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 0/5] bpf: add main_thread_only customization for task/task_file iterators
Date: Wed, 26 Aug 2020 17:06:18 -0700	[thread overview]
Message-ID: <20200827000618.2711826-1-yhs@fb.com> (raw)

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

-- 
2.24.1


             reply	other threads:[~2020-08-27  0:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27  0:06 Yonghong Song [this message]
2020-08-27  0:06 ` [PATCH bpf-next 1/5] bpf: make bpf_link_info.iter similar to bpf_iter_link_info Yonghong Song
2020-08-27  4:50   ` Andrii Nakryiko
2020-08-27  0:06 ` [PATCH bpf-next 2/5] bpf: add main_thread_only customization for task/task_file iterators Yonghong Song
2020-08-27  5:07   ` Andrii Nakryiko
2020-08-27 18:09     ` Yonghong Song
2020-09-02  0:34       ` Andrii Nakryiko
2020-09-02  2:23         ` Yonghong Song
2020-08-27  0:06 ` [PATCH bpf-next 3/5] bpf: add link_query support for newly added main_thread_only info Yonghong Song
2020-08-27  5:14   ` Andrii Nakryiko
2020-08-27  0:06 ` [PATCH bpf-next 4/5] bpftool: support optional 'task main_thread_only' argument Yonghong Song
2020-08-27  0:06 ` [PATCH bpf-next 5/5] selftests/bpf: test task_file iterator with main_thread_only Yonghong Song

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=20200827000618.2711826-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH bpf-next 0/5] bpf: add main_thread_only customization for task/task_file iterators' \
    /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

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