• Manfred Spraul's avatar
    [PATCH] fix f_version optimization for get_tgid_list · 94486dbd
    Manfred Spraul authored
    The kernel contains an optimization that skips the linked list walk in
    get_tgid_list for the common case of sequential accesses.  Unfortunately
    the optimization is buggy (missing NULL pointer check for the result of
    find_task_by_pid) and broken (actually - broken twice: the tgid value that
    is stored in f_version is always 0 because tgid is overwritten when the
    string is created and additionally the common case is not filldir < 0, it's
    running out of nr_tgids).
    
    The attached patch fixes these bugs.
    
    Roger Luethi <rl@hellgate.ch> ran a benchmark:
    
    	test: top -d 0 -b -n 10 > /dev/null
    
    	==> 2.6.8 <==
    	real    0m19.092s
    	user    0m5.013s
    	sys     0m12.622s
    
    	==> 2.6.8 + patch-tgid-bugfixes <==
    	real    0m10.062s
    	user    0m5.042s
    	sys     0m4.111s
    Signed-Off-By: default avatarManfred Spraul <manfred@colorfullife.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    94486dbd
base.c 42.5 KB