Skip to content

Commit

Permalink
proc: add a reschedule point in proc_readfd_common()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and Al Viro committed Jan 9, 2016
1 parent bc51b2a commit 3cc4a84
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/proc/fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,
name, len, instantiate, p,
(void *)(unsigned long)fd))
goto out_fd_loop;
cond_resched();
rcu_read_lock();
}
rcu_read_unlock();
Expand Down

0 comments on commit 3cc4a84

Please sign in to comment.