]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix bpf_iter's task iterator logic
authorAndrii Nakryiko <andriin@fb.com>
Thu, 14 May 2020 05:51:37 +0000 (22:51 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 May 2020 01:37:32 +0000 (18:37 -0700)
commit2363f6a31c17c3b54a3d398d5441f854c25f502e
tree8c0045ceb528c231cc94e10534e305f9d196cc3c
parent3efd38ffb1a1c942c52d45a031bbc219cc190a64
bpf: Fix bpf_iter's task iterator logic

task_seq_get_next might stop prematurely if get_pid_task() fails to get
task_struct. Failure to do so doesn't mean that there are no more tasks with
higher pids. Procfs's iteration algorithm (see next_tgid in fs/proc/base.c)
does a retry in such case. After this fix, instead of stopping prematurely
after about 300 tasks on my server, bpf_iter program now returns >4000, which
sounds much closer to reality.

Fixes: 5450d3427cbf ("bpf: Add task and task/file iterator targets")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200514055137.1564581-1-andriin@fb.com
kernel/bpf/task_iter.c