On 8/18/20 10:06 AM, Alexei Starovoitov wrote:
On Tue, Aug 18, 2020 at 9:24 AM Yonghong Song <yhs@xxxxxx> wrote:
index f21b5e1e4540..885b14cab2c0 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -27,6 +27,8 @@ static struct task_struct *task_seq_get_next(struct pid_namespace *ns,
struct task_struct *task = NULL;
struct pid *pid;
+ cond_resched();
+
rcu_read_lock();
retry:
pid = idr_get_next(&ns->idr, tid);
@@ -137,6 +139,8 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info,
struct task_struct *curr_task;
int curr_fd = info->fd;
+ cond_resched();
+
Instead of adding it to every *seq_get_next() it probably should be in
bpf_seq_read().
Yes, we can add cond_resched() to bpf_seq_read(). This should cover both
cases. Will make the change.
If cond_resched() is needed in task_file_seq_get_next() it should
probably be after 'again:'.
We probably do not need here unless all tasks have zero files or each
file just closed with f->f_count == 0 but the file pointer still there.