diff options
author | Eric Dumazet <edumazet@google.com> | 2015-12-03 14:12:07 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-09 02:56:10 -0500 |
commit | 3cc4a84e026e8d61b7ffe4a7367ed09a555f2c5b (patch) | |
tree | d538f2cde041d28d7ca3320d0e88d592cb76abad | |
parent | bc51b2a9193f917f2065313d9971d7d5e867bc81 (diff) |
proc: add a reschedule point in proc_readfd_common()
User can pass an arbitrary large buffer to getdents().
It is typically a 32KB buffer used by libc scandir() implementation.
When scanning /proc/{pid}/fd, we can hold cpu way too long,
so add a cond_resched() to be kind with other tasks.
We've seen latencies of more than 50ms on real workloads.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/proc/fd.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/proc/fd.c b/fs/proc/fd.c index 3c2a915c695a..56afa5ef08f2 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c | |||
@@ -258,6 +258,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx, | |||
258 | name, len, instantiate, p, | 258 | name, len, instantiate, p, |
259 | (void *)(unsigned long)fd)) | 259 | (void *)(unsigned long)fd)) |
260 | goto out_fd_loop; | 260 | goto out_fd_loop; |
261 | cond_resched(); | ||
261 | rcu_read_lock(); | 262 | rcu_read_lock(); |
262 | } | 263 | } |
263 | rcu_read_unlock(); | 264 | rcu_read_unlock(); |