From: kan.liang@intel.com
To: peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
linux-kernel@vger.kernel.org
Cc: bp@alien8.de, acme@kernel.org, eranian@google.com,
jolsa@kernel.org, ak@linux.intel.com,
Kan Liang <Kan.liang@intel.com>
Subject: [PATCH V3 0/2] measure SMI cost (kernel)
Date: Mon, 27 Mar 2017 11:30:46 -0700 [thread overview]
Message-ID: <1490639448-4147-1-git-send-email-kan.liang@intel.com> (raw)
From: Kan Liang <Kan.liang@intel.com>
Currently, there is no way to measure the time cost in System management
mode (SMM) by perf.
Intel perfmon supports FREEZE_WHILE_SMM bit in IA32_DEBUGCTL. Once it sets,
the PMU core counters will freeze on SMI handler. But it will not have an
effect on free running counters. E.g. APERF counter.
The cost of SMI can be measured by (aperf - cycles).
A new sysfs entry /sys/device/cpu/freeze_on_smi is introduced to set
FREEZE_WHILE_SMM bit in IA32_DEBUGCTL.
A new --smi-cost mode in perf stat is implemented to measure the SMI cost
by calculating cycles and aperf results. In practice, the percentages of
SMI cycles should be more useful than absolute value. So the output will be
the percentage of SMI cycles and SMI#.
If user wants to get the actual cycles, they can apply --no-metric-only.
Here is an example output.
Performance counter stats for 'sudo echo ':
SMI cycles% SMI#
0.1% 1
0.010858678 seconds time elapsed
Changes since V1:
- Only include kernel patch
- New functions to set msr bit on cpu and cpus.
Using the new functions to replace rdmsrl_on_cpu and wrmsrl_on_cpu.
That avoids the extra IPIs and atomic issue.
- Support hotplug
Changes since V2:
- reuse msr_info
Kan Liang (2):
x86/msr: add msr_set/clear_bit_on_cpu/cpus access functions
perf/x86: add sysfs entry to freeze counter on SMI
arch/x86/events/core.c | 10 ++++++
arch/x86/events/intel/core.c | 48 +++++++++++++++++++++++++
arch/x86/events/perf_event.h | 3 ++
arch/x86/include/asm/msr-index.h | 2 ++
arch/x86/include/asm/msr.h | 25 +++++++++++++
arch/x86/lib/msr-smp.c | 76 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 164 insertions(+)
--
2.7.4
next reply other threads:[~2017-03-27 18:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-27 18:30 kan.liang [this message]
2017-03-27 18:30 ` [PATCH V3 1/2] x86/msr: add msr_set/clear_bit_on_cpu/cpus access functions kan.liang
2017-03-28 8:36 ` Thomas Gleixner
2017-03-28 17:23 ` Thomas Gleixner
2017-03-28 17:38 ` Liang, Kan
2017-03-28 18:34 ` Thomas Gleixner
2017-03-27 18:30 ` [PATCH V3 2/2] perf/x86: add sysfs entry to freeze counter on SMI kan.liang
2017-03-28 8:42 ` Thomas Gleixner
2017-03-28 13:23 ` Liang, Kan
2017-03-28 17:03 ` Thomas Gleixner
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=1490639448-4147-1-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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