Commit 9128d3ed authored by Ingo Molnar's avatar Ingo Molnar

perf/x86/msr: Clean up the code

Recent changes made a bit of an inconsistent mess out of arch/x86/events/msr.c,
fix it:

 - re-align the initialization tables to be vertically aligned and readable again

 - harmonize comment style in terms of punctuation, capitalization and spelling

 - use curly braces for multi-condition branches

 - remove extra newlines

 - simplify the code a bit

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: kan.liang@intel.com
Link: http://lkml.kernel.org/r/1515169132-3980-1-git-send-email-eranian@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9ae21dd6
...@@ -36,7 +36,6 @@ static bool test_therm_status(int idx) ...@@ -36,7 +36,6 @@ static bool test_therm_status(int idx)
return boot_cpu_has(X86_FEATURE_DTHERM); return boot_cpu_has(X86_FEATURE_DTHERM);
} }
static bool test_intel(int idx) static bool test_intel(int idx)
{ {
if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL || if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
...@@ -103,16 +102,16 @@ struct perf_msr { ...@@ -103,16 +102,16 @@ struct perf_msr {
bool (*test)(int idx); bool (*test)(int idx);
}; };
PMU_EVENT_ATTR_STRING(tsc, evattr_tsc, "event=0x00"); PMU_EVENT_ATTR_STRING(tsc, evattr_tsc, "event=0x00" );
PMU_EVENT_ATTR_STRING(aperf, evattr_aperf, "event=0x01"); PMU_EVENT_ATTR_STRING(aperf, evattr_aperf, "event=0x01" );
PMU_EVENT_ATTR_STRING(mperf, evattr_mperf, "event=0x02"); PMU_EVENT_ATTR_STRING(mperf, evattr_mperf, "event=0x02" );
PMU_EVENT_ATTR_STRING(pperf, evattr_pperf, "event=0x03"); PMU_EVENT_ATTR_STRING(pperf, evattr_pperf, "event=0x03" );
PMU_EVENT_ATTR_STRING(smi, evattr_smi, "event=0x04"); PMU_EVENT_ATTR_STRING(smi, evattr_smi, "event=0x04" );
PMU_EVENT_ATTR_STRING(ptsc, evattr_ptsc, "event=0x05"); PMU_EVENT_ATTR_STRING(ptsc, evattr_ptsc, "event=0x05" );
PMU_EVENT_ATTR_STRING(irperf, evattr_irperf, "event=0x06"); PMU_EVENT_ATTR_STRING(irperf, evattr_irperf, "event=0x06" );
PMU_EVENT_ATTR_STRING(cpu_thermal_margin, evattr_therm, "event=0x07"); PMU_EVENT_ATTR_STRING(cpu_thermal_margin, evattr_therm, "event=0x07" );
PMU_EVENT_ATTR_STRING(cpu_thermal_margin.snapshot, evattr_therm_snap, "1"); PMU_EVENT_ATTR_STRING(cpu_thermal_margin.snapshot, evattr_therm_snap, "1" );
PMU_EVENT_ATTR_STRING(cpu_thermal_margin.unit, evattr_therm_unit, "C"); PMU_EVENT_ATTR_STRING(cpu_thermal_margin.unit, evattr_therm_unit, "C" );
static struct perf_msr msr[] = { static struct perf_msr msr[] = {
[PERF_MSR_TSC] = { 0, &evattr_tsc, NULL, }, [PERF_MSR_TSC] = { 0, &evattr_tsc, NULL, },
...@@ -198,7 +197,7 @@ static void msr_event_update(struct perf_event *event) ...@@ -198,7 +197,7 @@ static void msr_event_update(struct perf_event *event)
u64 prev, now; u64 prev, now;
s64 delta; s64 delta;
/* Careful, an NMI might modify the previous event value. */ /* Careful, an NMI might modify the previous event value: */
again: again:
prev = local64_read(&event->hw.prev_count); prev = local64_read(&event->hw.prev_count);
now = msr_read_counter(event); now = msr_read_counter(event);
...@@ -211,18 +210,18 @@ static void msr_event_update(struct perf_event *event) ...@@ -211,18 +210,18 @@ static void msr_event_update(struct perf_event *event)
delta = sign_extend64(delta, 31); delta = sign_extend64(delta, 31);
local64_add(delta, &event->count); local64_add(delta, &event->count);
} else if (unlikely(event->hw.event_base == MSR_IA32_THERM_STATUS)) { } else if (unlikely(event->hw.event_base == MSR_IA32_THERM_STATUS)) {
/* if valid, extract digital readout, other set to -1 */ /* If valid, extract digital readout, otherwise set to -1: */
now = now & (1ULL << 31) ? (now >> 16) & 0x3f : -1; now = now & (1ULL << 31) ? (now >> 16) & 0x3f : -1;
local64_set(&event->count, now); local64_set(&event->count, now);
} else } else {
local64_add(delta, &event->count); local64_add(delta, &event->count);
}
} }
static void msr_event_start(struct perf_event *event, int flags) static void msr_event_start(struct perf_event *event, int flags)
{ {
u64 now; u64 now = msr_read_counter(event);
now = msr_read_counter(event);
local64_set(&event->hw.prev_count, now); local64_set(&event->hw.prev_count, now);
} }
...@@ -269,9 +268,7 @@ static int __init msr_init(void) ...@@ -269,9 +268,7 @@ static int __init msr_init(void)
for (i = PERF_MSR_TSC + 1; i < PERF_MSR_EVENT_MAX; i++) { for (i = PERF_MSR_TSC + 1; i < PERF_MSR_EVENT_MAX; i++) {
u64 val; u64 val;
/* /* Virt sucks; you cannot tell if a R/O MSR is present :/ */
* Virt sucks arse; you cannot tell if a R/O MSR is present :/
*/
if (!msr[i].test(i) || rdmsrl_safe(msr[i].msr, &val)) if (!msr[i].test(i) || rdmsrl_safe(msr[i].msr, &val))
msr[i].attr = NULL; msr[i].attr = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment