timer: optimize apply_slack()
PATCH 1/1 timer: optimize apply_slack()
__fls(mask) is equivalent to find_last_bit(&mask, BITS_PER_LONG), but cheaper. find_last_bit was showing up high on the list when I was profiling for stalls on icache misses on a system with very small cache size (MIPS).
Signed-off-by Felix Fietkau <[email protected]>
--- kernel/timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/timer.c +1 -1
@@ -809,7 +809,7 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)if (mask ==0 )return expires; - bit =find_last_bit (&mask,BITS_PER_LONG ); + bit =__fls (mask); mask = (1 << bit) -1 ;
Signature · 1 line
1.7.3.2
Quoted 14 lines · Felix Fietkau
__fls(mask)is equivalent tofind_last_bit(&mask, BITS_PER_LONG), but cheaper.find_last_bitwas showing up high on the list when I was profiling for stalls on icache misses on a system with very small cache size (MIPS).Signed-off-by Felix Fietkau <[email protected]>--- kernel/timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)kernel/timer.c +0
-0
kernel/timer.c unsigned long apply_slack(struct timer_list *timer, unsigned long expires) · line 815
Quoted 8 lines
kernel/timer.c +1
-1@@ -809,7 +809,7 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)if (mask ==0 )return expires; - bit =find_last_bit (&mask,BITS_PER_LONG ); + bit =__fls (mask); mask = (1 << bit) -1 ;
Not a comment on your patch, but this code seems not correct.
This probably should be :
mask = (1UL << bit) - 1;