* [PATCH] kernel: timer.c: Small improvement in apply_slack()
@ 2014-07-28 14:48 Rasmus Villemoes
0 siblings, 0 replies; only message in thread
From: Rasmus Villemoes @ 2014-07-28 14:48 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: linux-kernel, Rasmus Villemoes
In apply_slack(), find_last_bit() is applied to a bitmask consisting
of precisely BITS_PER_LONG bits. Since mask is non-zero, we might as
well eliminate the function call and use __fls() directly. On x86_64,
this shaves 22 bytes of the only caller, mod_timer().
Found through Coverity CID 1192106, but that is a false positive,
since Coverity is not aware that mask != 0 implies that find_last_bit
will not return BITS_PER_LONG.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
kernel/timer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/timer.c b/kernel/timer.c
index 3bb01a3..b7d1a1e 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -836,7 +836,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 = (1UL << bit) - 1;
--
1.9.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-07-28 14:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-28 14:48 [PATCH] kernel: timer.c: Small improvement in apply_slack() Rasmus Villemoes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®