From: Andrew Morton <akpm@linux-foundation.org>
To: David Fries <david@fries.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] system timer: fix crash in <100Hz system timer
Date: Tue, 8 Jan 2008 23:15:07 -0800 [thread overview]
Message-ID: <20080108231507.ff34862f.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080105221653.GA10065@spacedout.fries.net>
On Sat, 5 Jan 2008 16:16:55 -0600 David Fries <david@fries.net> wrote:
> --- a/kernel/time.c
> +++ b/kernel/time.c
> @@ -565,7 +565,11 @@ EXPORT_SYMBOL(jiffies_to_timeval);
> clock_t jiffies_to_clock_t(long x)
> {
> #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
> + #if HZ < USER_HZ
> + return x * (USER_HZ / HZ);
> + #else
> return x / (HZ / USER_HZ);
> + #endif
> #else
> u64 tmp = (u64)x * TICK_NSEC;
> do_div(tmp, (NSEC_PER_SEC / USER_HZ));
> @@ -598,7 +602,12 @@ EXPORT_SYMBOL(clock_t_to_jiffies);
> u64 jiffies_64_to_clock_t(u64 x)
> {
> #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
> - do_div(x, HZ / USER_HZ);
> + #if HZ < USER_HZ
> + x *= USER_HZ;
> + do_div(x, HZ);
> + #else
> + do_div(x, HZ / USER_HZ);
> + #endif
> #else
Somwhat off-topic:
I guess HZ=USER_HZ is a not-uncommon case, and it's pretty silly calling
do_div(x, 1) all the time. How about we optimise that case?
Perhaps there are other places...
--- a/kernel/time.c~speed-up-jiffies-conversion-functions-if-hz==user_hz
+++ a/kernel/time.c
@@ -618,8 +618,10 @@ u64 jiffies_64_to_clock_t(u64 x)
# if HZ < USER_HZ
x *= USER_HZ;
do_div(x, HZ);
-# else
+# elif HZ > USER_HZ
do_div(x, HZ / USER_HZ);
+# else
+ /* Nothing to do */
# endif
#else
/*
_
prev parent reply other threads:[~2008-01-09 7:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-05 22:16 [PATCH] system timer: fix crash in <100Hz system timer David Fries
2008-01-07 23:36 ` Andrew Morton
2008-01-07 23:51 ` H. Peter Anvin
2008-01-08 0:09 ` Andrew Morton
2008-01-09 7:15 ` Andrew Morton [this message]
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=20080108231507.ff34862f.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=david@fries.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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