Skip to content

Commit 9a6694c

Browse files
virtuosoIngo Molnar
authored andcommitted
perf/x86/intel/pt: Do not force sync packets on every schedule-in
Currently, the PT driver zeroes out the status register every time before starting the event. However, all the writable bits are already taken care of in pt_handle_status() function, except the new PacketByteCnt field, which in new versions of PT contains the number of packet bytes written since the last sync (PSB) packet. Zeroing it out before enabling PT forces a sync packet to be written. This means that, with the existing code, a sync packet (PSB and PSBEND, 18 bytes in total) will be generated every time a PT event is scheduled in. To avoid these unnecessary syncs and save a WRMSR in the fast path, this patch changes the default behavior to not clear PacketByteCnt field, so that the sync packets will be generated with the period specified as "psb_period" attribute config field. This has little impact on the trace data as the other packets that are normally sent within PSB+ (between PSB and PSBEND) have their own generation scenarios which do not depend on the sync packets. One exception where we do need to force PSB like this when tracing starts, so that the decoder has a clear sync point in the trace. For this purpose we aready have hw::itrace_started flag, which we are currently using to output PERF_RECORD_ITRACE_START. This patch moves setting itrace_started from perf core to the pmu::start, where it should still be 0 on the very first run. Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/1438264104-16189-1-git-send-email-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar <[email protected]>
1 parent 27747f8 commit 9a6694c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

arch/x86/kernel/cpu/perf_event_intel_pt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ static void pt_config(struct perf_event *event)
191191
{
192192
u64 reg;
193193

194+
if (!event->hw.itrace_started) {
195+
event->hw.itrace_started = 1;
196+
wrmsrl(MSR_IA32_RTIT_STATUS, 0);
197+
}
198+
194199
reg = RTIT_CTL_TOPA | RTIT_CTL_BRANCH_EN | RTIT_CTL_TRACEEN;
195200

196201
if (!event->attr.exclude_kernel)
@@ -910,7 +915,6 @@ void intel_pt_interrupt(void)
910915

911916
pt_config_buffer(buf->cur->table, buf->cur_idx,
912917
buf->output_off);
913-
wrmsrl(MSR_IA32_RTIT_STATUS, 0);
914918
pt_config(event);
915919
}
916920
}
@@ -934,7 +938,6 @@ static void pt_event_start(struct perf_event *event, int mode)
934938

935939
pt_config_buffer(buf->cur->table, buf->cur_idx,
936940
buf->output_off);
937-
wrmsrl(MSR_IA32_RTIT_STATUS, 0);
938941
pt_config(event);
939942
}
940943

kernel/events/core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6139,8 +6139,6 @@ static void perf_log_itrace_start(struct perf_event *event)
61396139
event->hw.itrace_started)
61406140
return;
61416141

6142-
event->hw.itrace_started = 1;
6143-
61446142
rec.header.type = PERF_RECORD_ITRACE_START;
61456143
rec.header.misc = 0;
61466144
rec.header.size = sizeof(rec);

0 commit comments

Comments
 (0)