From: Stratos Karafotis <stratosk@semaphore.gr>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
Dirk Brandewie <dirk.j.brandewie@intel.com>
Cc: "cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] cpufreq: intel_pstate: Disable interrupts during MSRs reading
Date: Tue, 29 Apr 2014 20:46:05 +0300 [thread overview]
Message-ID: <535FE55D.40500@semaphore.gr> (raw)
According to Intel 64 and IA-32 Architectures SDM, Volume 3,
Chapter 14.2, "Software needs to exercise care to avoid delays
between the two RDMSRs (for example interrupts)".
So, disable interrupts during reading MSRs IA32_APERF and IA32_MPERF.
Since the TSC is also takes place in the calculation include it in
the protected section. This should increase the accuracy of the
calculations.
Tested on Intel i7-3770 CPU @ 3.40GHz.
Benchmarks (Phoronix Linux compilation) show a slightly increase
in performance by ~0.1% and a decrease in power consumption by
~0.13%.
Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
---
I hope it's not too inappropriate to post test results in
conjunction with my previous patch about the change of calculation
method of next p-state (https://lkml.org/lkml/2014/4/27/100).
I used Phoronix benchmark - Linux Kernel Compilation 3.1.
Below the test results using turbostat (5 iterations):
Without 2 patches:
Ph. avg Time Total time PkgWatt Total Energy
79.63 266.416 57.74 15382.85984
79.63 265.609 57.87 15370.79283
79.57 266.994 57.54 15362.83476
79.53 265.304 57.83 15342.53032
79.71 265.977 57.76 15362.83152
avg 79.61 266.06 57.74 15364.36985
With change calculation patch:
Ph. avg Time Total time PkgWatt Total Energy
78.23 258.826 59.14 15306.96964
78.41 259.110 59.15 15326.35650
78.40 258.530 59.26 15320.48780
78.46 258.673 59.20 15313.44160
78.19 259.075 59.16 15326.87700
avg 78.34 258.842 59.18 15318.82650
With change calculation patch + this one
Ph. avg Time Total time PkgWatt Total Energy
78.33 259.320 59.06 15315.43920
78.28 258.245 59.20 15288.10400
78.08 257.523 59.32 15276.26436
78.38 259.084 59.13 15319.63692
78.31 258.232 59.22 15292.49904
avg 78.27 258.480 59.18 15298.38870
drivers/cpufreq/intel_pstate.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 8e309db..95b3958 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -576,10 +576,13 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
{
u64 aperf, mperf;
unsigned long long tsc;
+ unsigned long flags;
+ local_irq_save(flags);
rdmsrl(MSR_IA32_APERF, aperf);
rdmsrl(MSR_IA32_MPERF, mperf);
tsc = native_read_tsc();
+ local_irq_restore(flags);
aperf = aperf >> FRAC_BITS;
mperf = mperf >> FRAC_BITS;
--
1.9.0
next reply other threads:[~2014-04-29 17:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-29 17:46 Stratos Karafotis [this message]
2014-04-29 22:29 ` [PATCH] cpufreq: intel_pstate: Disable interrupts during MSRs reading Rafael J. Wysocki
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=535FE55D.40500@semaphore.gr \
--to=stratosk@semaphore.gr \
--cc=cpufreq@vger.kernel.org \
--cc=dirk.j.brandewie@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).