From 45b54891c300e456f21b2cf0a67d02f4e4ed2fe6 Mon Sep 17 00:00:00 2001 From: Galaxy Date: Tue, 23 Apr 2024 02:16:07 -0700 Subject: [PATCH] Fix loss of spe packets. Spe packets are decoded by spe events along with dummy events. Dummy events provide context-switch info to determine pid and tid of spe packets. But in some cases, such as numa binding scenarios, there are very few or no dummy data. Then spe packets are lost. Fortunately, in some kernel versions, tid is contained in spe packets which has been decoded in arm_spe_decoder.cpp. For these packets we do not neeed dummy events to derive tid. After reading spe packets from ring buffer, GetProcTopology is used to get process info from tid and pid field is filled in the packet. --- pmu/spe.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pmu/spe.cpp b/pmu/spe.cpp index eeb77e1..940147d 100644 --- a/pmu/spe.cpp +++ b/pmu/spe.cpp @@ -405,6 +405,13 @@ static void SetTidByTimestamp(struct ContextSwitchData *dummyData, int *dummyIdx start->cpu = cpu; start->timestamp = recordTime; + if (start->tid != 0) { + // In some kernel versions, tid is contained in spe packet, + // which has been decoded in arm_spe_decoder.cpp. + // Then we do not need dummy events to derive tid for this packet. + continue; + } + if (*dummyIdx >= dummyData[0].num - 1) { // Now, all spe records locate after the last switch-in data. // We have to use switch-out data to get pid of the last time slice. -- Gitee