From: David Miller <davem@davemloft.net>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org
Subject: [BUG]: hrtimer overflow bug on 64-bit systems
Date: Thu, 24 May 2007 15:06:40 -0700 (PDT) [thread overview]
Message-ID: <20070524.150640.31659488.davem@davemloft.net> (raw)
I've been tracing this problem on sparc64 now that it uses hi-res
timers, and I finally figured it out.
The symptom is that ksoftirqd on most of the cpus of an idle SMP
system chew up around %10 of cpu time.
The raise_softirq_irqoff() is constantly being invoked via
tick_nohz_stop_sched_tick(), but why?
Tracing revealed that delta_ticks is enormous, which is correct
because no timers are pending on the cpu so we should schedule the
hrtimer as far into the future as possible.
tick_nohz_stop_sched_tick() then proceeds to start the hrtimer, and
then it checks hrtimer_active() but for some reason this is always
false.
Why?
The reason is that the expires calculation here:
expires = ktime_add_ns(last_update, tick_period.tv64 *
delta_jiffies);
overflows on 64-bit systems.
On 32-bit systems, LONG_MAX is a 32-bit quantity so the largest
possible delta_jiffies don't cause an overflow in this multiply
(which is 64-bit). (LONG_MAX determines how large a value
will be returned to indicate "infinity" from get_next_timer_interrupt(),
specifically it's the initialization of local variable 'expires'
in __next_timer_interrupt).
Because of this 'expires' is zero and of course that causes the
hrtimer to not get scheduled at all.
I'm surprised this problem is not seen with the x86_64 hrtimer patches
applied :-)
I'm not exactly sure how to best fix this, we could either make
__next_timer_interrupt use INT_MAX or we could make
tick_nohz_stop_sched_tick() realize and handle the overflow
properly. Neither of those solutions are fully satisfactory in
my opinion :-)
FWIW, I've verified that using INT_MAX in __next_timer_interrupt()
makes the problem go away.
reply other threads:[~2007-05-24 22:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070524.150640.31659488.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--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®