perf stat: Add hint for SMI cost measurement
PATCH v2 1/1 perf stat: Add hint for SMI cost measurement
From: Kan Liang <[email protected]>
Entering/exiting a C-state deeper than C0 may cause slight difference in counts between aperf and unhalted core cycles, which may impact the SMI cost.
Add smi_env_check() to check if C-state is completely disabled during the measurement. If not, give a hint to user.
Update the document as well.
Suggested-by Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by Kan Liang <[email protected]>
---
Changes since V1:
- Update changelog, document, and user-visible message
tools/perf/Documentation/perf-stat.txt | 5 +++++ tools/perf/builtin-stat.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
tools/perf/Documentation/perf-stat.txt +5 -0
@@ -309,6 +309,11 @@ The output is SMI cycles%, equals to (aperf - unhalted core cycles) / aperf Users who wants to get the actual value can apply --no-metric-only. +Entering/exiting a C-state deeper than C0 may cause slight difference in counts +between aperf and unhalted core cycles, which may impact the SMI cost. +Please completely disable C-state during the measurement, +e.g. set idle=poll in grub. + EXAMPLES --------
tools/perf/builtin-stat.c +25 -0
@@ -87,6 +87,7 @@#define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" +#define CPUIDLE_CUR_DRV "devices/system/cpu/cpuidle/current_driver"static void print_counters (struct timespec *ts,int argc,const char **argv);
@@ -1024,6 +1025,27 @@ __weak void arch_topdown_group_warn(void) { } +static void smi_env_check (void ) +{ +char *name; +size_t len; +int err; + + err =sysfs__read_str (CPUIDLE_CUR_DRV , &name, &len); +if (err) { +pr_warning ("Failed to read %s, err %d. Ignoring C-state status check.\n" , +CPUIDLE_CUR_DRV , err); +return ; + } + +if (strncmp (name,"none" ,4 )) { +pr_warning ("Entering/exiting a C-state deeper than C0 may result inaccurate SMI cost.\n" +"Please completely disable C-state, e.g. set idle=poll in grub.\n" ); + } + +free (name); +} +/* * Add default attributes, if there were no attributes specified or * if -d/--detailed, -d -d or -d -d -d is used:
@@ -1196,6 +1218,9 @@ static int add_default_attributes(void)if (pmu_have_event ("msr" ,"aperf" ) &&pmu_have_event ("msr" ,"smi" )) { + +smi_env_check (); +if (!force_metric_only) stat_config.metric_only = true; err =parse_events (evsel_list, smi_cost_attrs, &errinfo);
Signature · 1 line
2.7.4