All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [timer] Optimise apply_slack() for size and speed.
@ 2012-02-03 16:00 Chinmay V S
  2012-02-05 10:44 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Chinmay V S @ 2012-02-03 16:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: cvs268, tglx, sebastian, arjan, jeff.chua.linux, Chinmay V S

Updated the patch for improved readability.
How about the following patch?


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>
---
 kernel/timer.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index a297ffc..eb4b708 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -785,9 +785,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)
@@ -811,9 +809,8 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)
 
 	bit = find_last_bit(&mask, BITS_PER_LONG);
 
-	mask = (1 << bit) - 1;
-
-	expires_limit = expires_limit & ~(mask);
+	/* Round down by zero-ing the lower bits */
+	expires_limit = (expires_limit >> bit) << bit;
 
 	return expires_limit;
 }
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [timer] Optimise apply_slack() for size and speed.
  2012-02-03 16:00 [PATCH] [timer] Optimise apply_slack() for size and speed Chinmay V S
@ 2012-02-05 10:44 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-02-05 10:44 UTC (permalink / raw)
  To: Chinmay V S; +Cc: linux-kernel, cvs268, tglx, sebastian, arjan, jeff.chua.linux

* Chinmay V S | 2012-02-03 21:30:50 [+0530]:

>Updated the patch for improved readability.
Arjan's point was that this is not critical for performance and as such
it does not need an improvement.

>How about the following patch?
I guess this will be left as is.

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-05 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 16:00 [PATCH] [timer] Optimise apply_slack() for size and speed Chinmay V S
2012-02-05 10:44 ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.