Skip to content

Commit 81c171b

Browse files
Louis-Yeshantuo
authored andcommitted
Not treat SPE sample as LBR sample in perf_data_converter
PiperOrigin-RevId: 688756974
1 parent 3a715e1 commit 81c171b

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/perf_data_converter.cc

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ bool PerfDataConverter::Sample(const PerfDataHandler::SampleContext& sample) {
836836
// LBR callstacks include only user call chains. If this is an LBR sample,
837837
// we get the kernel callstack from the sample's callchain, and the user
838838
// callstack from the sample's branch_stack.
839-
const bool lbr_sample = !sample.branch_stack.empty();
839+
const bool lbr_sample = !sample.branch_stack.empty() && !sample.spe.is_spe;
840840
bool skipped_dup = false;
841841
for (const auto& frame : sample.callchain) {
842842
if (lbr_sample && frame.ip == quipper::PERF_CONTEXT_USER) {
@@ -875,23 +875,28 @@ bool PerfDataConverter::Sample(const PerfDataHandler::SampleContext& sample) {
875875
AddOrGetLocation(event_pid, frame.ip - 1, frame.mapping, builder));
876876
IncBuildIdStats(event_pid, frame.mapping);
877877
}
878-
for (const auto& frame : sample.branch_stack) {
879-
// branch_stack entries are pairs of <from, to> locations corresponding to
880-
// addresses of call instructions and target addresses of those calls.
881-
// We need only the addresses of the function call instructions, stored in
882-
// the 'from' field, to recover the call chains.
883-
if (frame.from.mapping == nullptr) {
884-
continue;
885-
}
886-
// An LBR entry includes the address of the call instruction, so we don't
887-
// have to do any adjustments.
888-
if (frame.from.ip < frame.from.mapping->start) {
889-
continue;
878+
879+
// Only add the frame from branch_stack if it is an LBR sample.
880+
if (lbr_sample) {
881+
for (const auto& frame : sample.branch_stack) {
882+
// branch_stack entries are pairs of <from, to> locations corresponding to
883+
// addresses of call instructions and target addresses of those calls. We
884+
// need only the addresses of the function call instructions, stored in
885+
// the 'from' field, to recover the call chains.
886+
if (frame.from.mapping == nullptr) {
887+
continue;
888+
}
889+
// An LBR entry includes the address of the call instruction, so we don't
890+
// have to do any adjustments.
891+
if (frame.from.ip < frame.from.mapping->start) {
892+
continue;
893+
}
894+
sample_key.stack.push_back(AddOrGetLocation(event_pid, frame.from.ip,
895+
frame.from.mapping, builder));
896+
IncBuildIdStats(event_pid, frame.from.mapping);
890897
}
891-
sample_key.stack.push_back(AddOrGetLocation(event_pid, frame.from.ip,
892-
frame.from.mapping, builder));
893-
IncBuildIdStats(event_pid, frame.from.mapping);
894898
}
899+
895900
AddOrUpdateSample(sample, event_pid, sample_key, builder);
896901
return true;
897902
}

0 commit comments

Comments
 (0)