diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2017-03-30 11:39:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-08-29 09:09:24 -0400 |
commit | 8d4e6c4caa12dafbcba138e5450b7af17b0b2194 (patch) | |
tree | a9b6c4f3076bd27f9a87fb67a2907c9a0a3c5cbd | |
parent | e0563e049531973e665db853e825a4efed9f881d (diff) |
perf/core, pt, bts: Get rid of itrace_started
I just noticed that hw.itrace_started and hw.config are aliased to the
same location. Now, the PT driver happens to use both, which works out
fine by sheer luck:
- STORE(hw.itrace_start) is ordered before STORE(hw.config), in the
program order, although there are no compiler barriers to ensure that,
- to the perf_log_itrace_start() hw.itrace_start looks set at the same
time as when it is intended to be set because both stores happen in the
same path,
- hw.config is never reset to zero in the PT driver.
Now, the use of hw.config by the PT driver makes more sense (it being a
HW PMU) than messing around with itrace_started, which is an awkward API
to begin with.
This patch replaces hw.itrace_started with an attach_state bit and an
API call for the PMU drivers to use to communicate the condition.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
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: vince@deater.net
Link: http://lkml.kernel.org/r/20170330153956.25994-1-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/events/intel/bts.c | 2 | ||||
-rw-r--r-- | arch/x86/events/intel/pt.c | 5 | ||||
-rw-r--r-- | include/linux/perf_event.h | 5 | ||||
-rw-r--r-- | kernel/events/core.c | 7 |
4 files changed, 12 insertions, 7 deletions
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index ddd8d3516bfc..16076eb34699 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c | |||
@@ -268,7 +268,7 @@ static void bts_event_start(struct perf_event *event, int flags) | |||
268 | bts->ds_back.bts_absolute_maximum = cpuc->ds->bts_absolute_maximum; | 268 | bts->ds_back.bts_absolute_maximum = cpuc->ds->bts_absolute_maximum; |
269 | bts->ds_back.bts_interrupt_threshold = cpuc->ds->bts_interrupt_threshold; | 269 | bts->ds_back.bts_interrupt_threshold = cpuc->ds->bts_interrupt_threshold; |
270 | 270 | ||
271 | event->hw.itrace_started = 1; | 271 | perf_event_itrace_started(event); |
272 | event->hw.state = 0; | 272 | event->hw.state = 0; |
273 | 273 | ||
274 | __bts_event_start(event); | 274 | __bts_event_start(event); |
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index ae8324d65e61..81fd41d5a0d9 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c | |||
@@ -471,8 +471,9 @@ static void pt_config(struct perf_event *event) | |||
471 | struct pt *pt = this_cpu_ptr(&pt_ctx); | 471 | struct pt *pt = this_cpu_ptr(&pt_ctx); |
472 | u64 reg; | 472 | u64 reg; |
473 | 473 | ||
474 | if (!event->hw.itrace_started) { | 474 | /* First round: clear STATUS, in particular the PSB byte counter. */ |
475 | event->hw.itrace_started = 1; | 475 | if (!event->hw.config) { |
476 | perf_event_itrace_started(event); | ||
476 | wrmsrl(MSR_IA32_RTIT_STATUS, 0); | 477 | wrmsrl(MSR_IA32_RTIT_STATUS, 0); |
477 | } | 478 | } |
478 | 479 | ||
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index c00cd4b02f32..adda0aaae6c8 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -147,9 +147,6 @@ struct hw_perf_event { | |||
147 | struct list_head cqm_groups_entry; | 147 | struct list_head cqm_groups_entry; |
148 | struct list_head cqm_group_entry; | 148 | struct list_head cqm_group_entry; |
149 | }; | 149 | }; |
150 | struct { /* itrace */ | ||
151 | int itrace_started; | ||
152 | }; | ||
153 | struct { /* amd_power */ | 150 | struct { /* amd_power */ |
154 | u64 pwr_acc; | 151 | u64 pwr_acc; |
155 | u64 ptsc; | 152 | u64 ptsc; |
@@ -541,6 +538,7 @@ struct swevent_hlist { | |||
541 | #define PERF_ATTACH_GROUP 0x02 | 538 | #define PERF_ATTACH_GROUP 0x02 |
542 | #define PERF_ATTACH_TASK 0x04 | 539 | #define PERF_ATTACH_TASK 0x04 |
543 | #define PERF_ATTACH_TASK_DATA 0x08 | 540 | #define PERF_ATTACH_TASK_DATA 0x08 |
541 | #define PERF_ATTACH_ITRACE 0x10 | ||
544 | 542 | ||
545 | struct perf_cgroup; | 543 | struct perf_cgroup; |
546 | struct ring_buffer; | 544 | struct ring_buffer; |
@@ -864,6 +862,7 @@ extern int perf_aux_output_skip(struct perf_output_handle *handle, | |||
864 | unsigned long size); | 862 | unsigned long size); |
865 | extern void *perf_get_aux(struct perf_output_handle *handle); | 863 | extern void *perf_get_aux(struct perf_output_handle *handle); |
866 | extern void perf_aux_output_flag(struct perf_output_handle *handle, u64 flags); | 864 | extern void perf_aux_output_flag(struct perf_output_handle *handle, u64 flags); |
865 | extern void perf_event_itrace_started(struct perf_event *event); | ||
867 | 866 | ||
868 | extern int perf_pmu_register(struct pmu *pmu, const char *name, int type); | 867 | extern int perf_pmu_register(struct pmu *pmu, const char *name, int type); |
869 | extern void perf_pmu_unregister(struct pmu *pmu); | 868 | extern void perf_pmu_unregister(struct pmu *pmu); |
diff --git a/kernel/events/core.c b/kernel/events/core.c index e5467e107624..77fd6b11ef22 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -7301,6 +7301,11 @@ static void perf_log_throttle(struct perf_event *event, int enable) | |||
7301 | perf_output_end(&handle); | 7301 | perf_output_end(&handle); |
7302 | } | 7302 | } |
7303 | 7303 | ||
7304 | void perf_event_itrace_started(struct perf_event *event) | ||
7305 | { | ||
7306 | event->attach_state |= PERF_ATTACH_ITRACE; | ||
7307 | } | ||
7308 | |||
7304 | static void perf_log_itrace_start(struct perf_event *event) | 7309 | static void perf_log_itrace_start(struct perf_event *event) |
7305 | { | 7310 | { |
7306 | struct perf_output_handle handle; | 7311 | struct perf_output_handle handle; |
@@ -7316,7 +7321,7 @@ static void perf_log_itrace_start(struct perf_event *event) | |||
7316 | event = event->parent; | 7321 | event = event->parent; |
7317 | 7322 | ||
7318 | if (!(event->pmu->capabilities & PERF_PMU_CAP_ITRACE) || | 7323 | if (!(event->pmu->capabilities & PERF_PMU_CAP_ITRACE) || |
7319 | event->hw.itrace_started) | 7324 | event->attach_state & PERF_ATTACH_ITRACE) |
7320 | return; | 7325 | return; |
7321 | 7326 | ||
7322 | rec.header.type = PERF_RECORD_ITRACE_START; | 7327 | rec.header.type = PERF_RECORD_ITRACE_START; |