Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

proc: smaller readlock section in readdir("/proc")

Readdir context is thread local, so ->pos is thread local,
move it out of readlock.

Link: http://lkml.kernel.org/r/20180627195339.GD18113@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
8d48b2e0 2cd36fb3

+2 -2
+2 -2
fs/proc/generic.c
··· 286 286 if (!dir_emit_dots(file, ctx)) 287 287 return 0; 288 288 289 + i = ctx->pos - 2; 289 290 read_lock(&proc_subdir_lock); 290 291 de = pde_subdir_first(de); 291 - i = ctx->pos - 2; 292 292 for (;;) { 293 293 if (!de) { 294 294 read_unlock(&proc_subdir_lock); ··· 309 309 pde_put(de); 310 310 return 0; 311 311 } 312 - read_lock(&proc_subdir_lock); 313 312 ctx->pos++; 313 + read_lock(&proc_subdir_lock); 314 314 next = pde_subdir_next(de); 315 315 pde_put(de); 316 316 de = next;