From 8a4f55000ddec6b2bde393afa8d8d4800928d95c Mon Sep 17 00:00:00 2001 From: Zhao Mengmeng Date: Wed, 26 Jun 2024 10:50:35 +0800 Subject: [PATCH] pmu: spe_sampler: update pid list before read when running `bash build.sh test=true`, TestSPE.SpeProcCollectSubProc failed with: [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from TestSPE [ RUN ] TestSPE.SpeProcCollectSubProc +157827 ^157828 157827 157827 157827 157827 157827 157827 157827 157827 -157828 Cannot find pid: 157828 /root/libkperf/test/test_perf/test_spe.cpp:167: Failure Value of: FoundAllChildren(data, len, appPid) Actual: false Expected: true [ FAILED ] TestSPE.SpeProcCollectSubProc (2462 ms) [----------] 1 test from TestSPE (2462 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (2462 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] TestSPE.SpeProcCollectSubProc The root cause is procMap has only one pid, it won't get updated even there are new subprocess forked. Fix this by move UpdatePidList() before the if check. Besides, remove cnt which was not used here. --- pmu/spe_sampler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pmu/spe_sampler.cpp b/pmu/spe_sampler.cpp index 62c6d7f..c81ff0c 100644 --- a/pmu/spe_sampler.cpp +++ b/pmu/spe_sampler.cpp @@ -80,11 +80,10 @@ namespace KUNPENG_PMU { return Perrorno(); } + UpdatePidList(findSpe->second); // Fill pmu data from SPE collector. - auto cnt = data.size(); if (pid == -1) { // Loop over all tids in records and resolve module symbol for all pids. - UpdatePidList(findSpe->second); for (auto records : findSpe->second.GetAllRecords()) { if (records.first == -1 || records.first == 0) { continue; -- Gitee