proc: add a schedule point in proc_pid_readdir()
authorEric Dumazet <[email protected]>
Tue, 24 Jan 2017 23:18:07 +0000 (15:18 -0800)
committerLinus Torvalds <[email protected]>
Wed, 25 Jan 2017 00:26:14 +0000 (16:26 -0800)
We have seen proc_pid_readdir() invocations holding cpu for more than 50
ms.  Add a cond_resched() to be gentle with other tasks.

[[email protected]: coding style fix]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/proc/base.c

index 8e7e61b28f31c037961c081d09a7be5f818013ef..87c9a9aacda3601e2686e239243f447728137943 100644 (file)
@@ -3179,6 +3179,8 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
             iter.tgid += 1, iter = next_tgid(ns, iter)) {
                char name[PROC_NUMBUF];
                int len;
+
+               cond_resched();
                if (!has_pid_permissions(ns, iter.task, 2))
                        continue;