mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chinmay V S <chinmay.v.s@pathpartnertech.com>
To: linux-kernel@vger.kernel.org
Cc: cvs268@gmail.com, tglx@linutronix.de, sebastian@breakpoint.cc,
	arjan@linux.intel.com, jeff.chua.linux@gmail.com,
	Chinmay V S <chinmay.v.s@pathpartnertech.com>
Subject: [RFC] [PATCH] [timer] Optimise apply_slack() for size and speed.
Date: Tue, 31 Jan 2012 15:07:32 +0530	[thread overview]
Message-ID: <1328002652-7700-1-git-send-email-chinmay.v.s@pathpartnertech.com> (raw)

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 |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/timer.c b/kernel/timer.c
index a297ffc..0379658 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,7 @@ 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);
+	expires_limit = (expires_limit >> bit) << bit;
 
 	return expires_limit;
 }
-- 
1.7.5.4


             reply	other threads:[~2012-01-31  9:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31  9:37 Chinmay V S [this message]
2012-02-02 22:59 ` Sebastian Andrzej Siewior
     [not found]   ` <CAKZbaaTDcfEVPa2JRSnkv_YCiScoTTqpmzaGQGWT98QJpYzZ8A@mail.gmail.com>
2012-02-03 14:52     ` Arjan van de Ven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328002652-7700-1-git-send-email-chinmay.v.s@pathpartnertech.com \
    --to=chinmay.v.s@pathpartnertech.com \
    --cc=arjan@linux.intel.com \
    --cc=cvs268@gmail.com \
    --cc=jeff.chua.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebastian@breakpoint.cc \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®