From: Eric Dumazet Date: Thu, 3 Dec 2015 19:12:07 +0000 (-0800) Subject: proc: add a reschedule point in proc_readfd_common() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3cc4a84e026e8d61b7ffe4a7367ed09a555f2c5b;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Alexander Viro Signed-off-by: Al Viro --- 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, name, len, instantiate, p, (void *)(unsigned long)fd)) goto out_fd_loop; + cond_resched(); rcu_read_lock(); } rcu_read_unlock();