From: Kasper Pedersen <kernel@kasperkp.dk>
To: Josh Triplett <josh@joshtriplett.org>
Cc: john stultz <johnstul@us.ibm.com>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Peter Zijlstra <a.p.zijlstra@chello.nl>,
Suresh Siddha <suresh.b.siddha@intel.com>
Subject: Re: x86: tsc: v2 make TSC calibration more immune to interrupts
Date: Thu, 21 Apr 2011 21:46:15 +0200 [thread overview]
Message-ID: <4DB08987.20403@kasperkp.dk> (raw)
In-Reply-To: <20110420223929.GB5563@feather>
On 04/21/2011 12:39 AM, Josh Triplett wrote:
>
> Have you considered disabling interrupts while calibrating? That would
> ensure that you only have to care about SMIs, not arbitrary interrupts.
>
> Also, on more recent x86 systems you could look at MSR_SMI_COUNT (MSR
> 0x34) to detect if any SMIs have occurred during the sample period.
> rdmsr, start sample period, stop sample period, rdmsr, if delta of 0
> then no SMIs occurred. Exists on Nehalem and newer, at least.
I have now tested this, and it is worth doing.
+ local_irq_save(flags);
t1 = get_cycles();
if (hpet)
tp = hpet_readl(HPET_COUNTER) & 0xFFFFFFFF;
else
tp = acpi_pm_read_early();
t2 = get_cycles();
+ local_irq_restore(flags);
On P3, when no SMI occur, the sample is now always perfect.
On Core2 there is still very rare variation - up to 8000 clock,
maybe bus contention?
Thinking it was cache I tried keeping irqs disabled for 5M
iterations, and that makes it occur _more_ often.
Atom shows the same as Core2, but even more rarely.
So, even if we have a Nehalem with SMI counter, the 5 samples
will still have benefit.
/Kasper Pedersen
--
This is my second patch ever, tell me when I do something wrong.
next prev parent reply other threads:[~2011-04-21 19:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 18:52 x86: tsc: make TSC calibration more immune to interrupts Kasper Pedersen
2011-04-20 19:15 ` john stultz
2011-04-20 19:44 ` Kasper Pedersen
2011-04-20 20:28 ` john stultz
2011-04-20 21:22 ` x86: tsc: v2 " Kasper Pedersen
2011-04-20 22:39 ` Josh Triplett
2011-04-21 2:19 ` john stultz
2011-04-21 4:32 ` Josh Triplett
2011-04-21 19:46 ` Kasper Pedersen [this message]
2011-04-23 1:38 ` john stultz
2011-04-21 19:52 ` x86: tsc: v3 " Kasper Pedersen
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=4DB08987.20403@kasperkp.dk \
--to=kernel@kasperkp.dk \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=johnstul@us.ibm.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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