diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2021-09-07 19:39:01 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2021-10-15 12:25:31 +0300 |
commit | 8b8ff8cc3b8155c18162e8b1f70e1230db176862 (patch) | |
tree | 7fa6284dbe477808c4a93170cfb6ea7ac5463980 /kernel/events | |
parent | 41100833cdd8b1bef363b81a6482d74711c116ad (diff) | |
download | linux-8b8ff8cc3b8155c18162e8b1f70e1230db176862.tar.xz |
perf/x86: Add new event for AUX output counter index
PEBS-via-PT records contain a mask of applicable counters. To identify
which event belongs to which counter, a side-band event is needed. Until
now, there has been no side-band event, and consequently users were limited
to using a single event.
Add such a side-band event. Note the event is optimised to output only
when the counter index changes for an event. That works only so long as
all PEBS-via-PT events are scheduled together, which they are for a
recording session because they are in a single group.
Also no attribute bit is used to select the new event, so a new
kernel is not compatible with older perf tools. The assumption
being that PEBS-via-PT is sufficiently esoteric that users will not
be troubled by this.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210907163903.11820-2-adrian.hunter@intel.com
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/core.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 1cb1f9b8392e..0e90a5084f18 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9062,6 +9062,36 @@ static void perf_log_itrace_start(struct perf_event *event) perf_output_end(&handle); } +void perf_report_aux_output_id(struct perf_event *event, u64 hw_id) +{ + struct perf_output_handle handle; + struct perf_sample_data sample; + struct perf_aux_event { + struct perf_event_header header; + u64 hw_id; + } rec; + int ret; + + if (event->parent) + event = event->parent; + + rec.header.type = PERF_RECORD_AUX_OUTPUT_HW_ID; + rec.header.misc = 0; + rec.header.size = sizeof(rec); + rec.hw_id = hw_id; + + perf_event_header__init_id(&rec.header, &sample, event); + ret = perf_output_begin(&handle, &sample, event, rec.header.size); + + if (ret) + return; + + perf_output_put(&handle, rec); + perf_event__output_id_sample(event, &handle, &sample); + + perf_output_end(&handle); +} + static int __perf_event_account_interrupt(struct perf_event *event, int throttle) { |