diff options
| author | Chinmay V S <chinmay.v.s@pathpartnertech.com> | 2012-02-03 21:30:50 +0530 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2016-08-26 20:20:22 +0200 |
| commit | 478c700c01cb041a95a4540915717c3012d1e5b2 (patch) | |
| tree | 0a2668e972ebd87099f1ba3de34fb3e7e5928462 | |
| parent | 6d1a0ace27b41d4f3f50ec42d0300a75ac5f7c68 (diff) | |
Optimise apply_slack() for size and speed.
To apply proper slack, the original algorithm used to prepare a mask and
then apply the mask to obtain the appropriately rounded-off absolute
time the timer expires.
This patch modifies the masking logic to a bit-shift logic, therby
reducing the complexity and number of operations. Thus obtaining a minor
speed-up.
Signed-off-by: Chinmay V S <chinmay.v.s@pathpartnertech.com>
Signed-off-by: Stefan Guendhoer <stefan@guendhoer.com>
| -rw-r--r-- | kernel/timer.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/kernel/timer.c b/kernel/timer.c index f22f8ae13..f5bdb1b50 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -805,9 +805,7 @@ EXPORT_SYMBOL(mod_timer_pending); * Algorithm: * 1) calculate the maximum (absolute) time * 2) calculate the highest bit where the expires and new max are different - * 3) use this bit to make a mask - * 4) use the bitmask to round down the maximum time, so that all last - * bits are zeros + * 3) round down the maximum time, so that all the lower bits are zeros */ static inline unsigned long apply_slack(struct timer_list *timer, unsigned long expires) @@ -831,9 +829,8 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires) bit = find_last_bit(&mask, BITS_PER_LONG); - mask = (1UL << bit) - 1; - - expires_limit = expires_limit & ~(mask); + /* Round down by zero-ing the lower bits */ + expires_limit = (expires_limit >> bit) << bit; return expires_limit; } |
