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

Fix performance regression on lmbench select benchmark

Christian Borntraeger reported that reinstating cond_resched() with
CONFIG_PREEMPT caused a performance regression on lmbench:

For example select file 500:
23 microseconds
32 microseconds

and that's really because we totally unnecessarily do the cond_resched()
in the innermost loop of select(), which is just silly.

This moves it out from the innermost loop (which only ever loops ove the
bits in a single "unsigned long" anyway), which makes the performance
regression go away.

Reported-and-tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+1 -1
+1 -1
fs/select.c
··· 249 249 retval++; 250 250 } 251 251 } 252 - cond_resched(); 253 252 } 254 253 if (res_in) 255 254 *rinp = res_in; ··· 256 257 *routp = res_out; 257 258 if (res_ex) 258 259 *rexp = res_ex; 260 + cond_resched(); 259 261 } 260 262 wait = NULL; 261 263 if (retval || !*timeout || signal_pending(current))