diff --git a/docs/Details_Usage.md b/docs/Details_Usage.md index cf0b41075b8f79dade554dde85651597d6612575..b356b2b46157d9f71abe7868179d6f214644b46c 100644 --- a/docs/Details_Usage.md +++ b/docs/Details_Usage.md @@ -571,7 +571,7 @@ funcName: write elapsedTime: 0.00118 ms pid: 997235 tid: 997235 cpu: 110 comm: t 支持采集的系统调用函数列表,在查看/sys/kernel/tracing/events/syscalls/下所有系统调用对应的enter和exit文件,去掉相同的前缀就是对应的系统调用函数名称;也可以基于提供的PmuSysCallFuncList函数获取对应的系统调用函数列表。 ### 采集BRBE数据 -libkperf基于sampling的能力,增加了对branch sample stack数据的采集能力。 +libkperf基于sampling的能力,增加了对branch sample stack数据的采集能力,用于获取CPU的跳转记录, 通过branchSampleFilter可指定获取不同类型的分支跳转记录。 ```c++ char* evtList[1] = {"cycles"}; int* cpuList = nullptr; @@ -605,7 +605,7 @@ for (int i = 0; i < len; i++) for (int j = 0; j < pmuData.ext->nr; j++) { auto *rd = pmuData.ext->branchRecords; - std::cout << std::hex << rd[j].fromAddr << "->" << rd[j].toAddr << " " << rd[j].cycles << " " << rd[j].predicted << " " << rd[j].mispred << std::endl; + std::cout << std::hex << rd[j].fromAddr << "->" << rd[j].toAddr << " " << rd[j].cycles << std::endl; } } } @@ -614,11 +614,11 @@ PmuClose(pd); ``` 执行上述代码,输出的结果类似如下: ``` -ffff88f6065c->ffff88f60b0c 35 1 0 -ffff88f60aa0->ffff88f60618 1 1 0 -40065c->ffff88f60b00 1 1 0 -400824->400650 1 1 0 -400838->400804 1 1 0 +ffff88f6065c->ffff88f60b0c 35 +ffff88f60aa0->ffff88f60618 1 +40065c->ffff88f60b00 1 +400824->400650 1 +400838->400804 1 ``` ```python @@ -640,16 +640,13 @@ pmu_data = kperf.read(pd) for data in pmu_data.iter: if data.ext and data.ext.branchRecords: for item in data.ext.branchRecords.iter: - predicted = 'P' - if item.mispred: - predicted = 'M' - print(f"{hex(item.fromAddr)}->{hex(item.toAddr)} {item.cycles} {predicted}") + print(f"{hex(item.fromAddr)}->{hex(item.toAddr)} {item.cycles}") ``` 执行上述代码,输出的结果类似如下: ``` -0xffff88f6065c->0xffff88f60b0c 35 P -0xffff88f60aa0->0xffff88f60618 1 P -0x40065c->0xffff88f60b00 1 P -0x400824->0x400650 1 P -0x400838->0x400804 1 P +0xffff88f6065c->0xffff88f60b0c 35 +0xffff88f60aa0->0xffff88f60618 1 +0x40065c->0xffff88f60b00 1 +0x400824->0x400650 1 +0x400838->0x400804 1 ``` \ No newline at end of file diff --git a/include/pmu.h b/include/pmu.h index 68e2a5545c25b667998f7532d2dc773f71b72942..6ea3af13592138c84c85d8a0578a58fc3dec12c1 100644 --- a/include/pmu.h +++ b/include/pmu.h @@ -206,10 +206,6 @@ struct BranchSampleRecord { unsigned long fromAddr; unsigned long toAddr; unsigned long cycles; - unsigned long mispred; - unsigned long predicted; - unsigned long inTx; - unsigned long abort; }; struct PmuDataExt { diff --git a/pmu/sampler.cpp b/pmu/sampler.cpp index 04849a82d6daa68842f543c1cb2208a663d6a3a8..318ba7fd52219745a498fb3b3261c186a9eb2304 100644 --- a/pmu/sampler.cpp +++ b/pmu/sampler.cpp @@ -176,10 +176,6 @@ void KUNPENG_PMU::PerfSampler::ParseBranchSampleData(struct PmuData *pmuData, Pe records[i].fromAddr = branchItem.from; records[i].toAddr = branchItem.to; records[i].cycles = branchItem.cycles; - records[i].mispred = branchItem.mispred; - records[i].predicted = branchItem.predicted; - records[i].inTx = branchItem.in_tx; - records[i].abort = branchItem.abort; } branchExt->nr = branchData->bnr; branchExt->branchRecords = records; diff --git a/python/modules/_libkperf/Pmu.py b/python/modules/_libkperf/Pmu.py index 9e94b0c5114036aba69481131010d72536de9c54..eeeeeb48ac1971ce3d5337206469f6f6809fe22c 100644 --- a/python/modules/_libkperf/Pmu.py +++ b/python/modules/_libkperf/Pmu.py @@ -622,10 +622,6 @@ class CytpesBranchSampleRecord(ctypes.Structure): ("fromAddr", ctypes.c_ulong), ("toAddr", ctypes.c_ulong), ("cycles", ctypes.c_ulong), - ("mispred", ctypes.c_ulong), - ("predicted", ctypes.c_ulong), - ("inTx", ctypes.c_ulong), - ("abort", ctypes.c_ulong), ] @@ -642,19 +638,11 @@ class ImplBranchRecords(): def __init__(self, fromAddr: int=0, toAddr: int=0, - cycles: int=0, - mispred: int=0, - predicted: int=0, - inTx: int=0, - abort: int=0) -> None: + cycles: int=0) -> None: self.__c_branch_record = CytpesBranchSampleRecord( fromAddr=fromAddr, toAddr=toAddr, - cycles=cycles, - mispred=mispred, - predicted=predicted, - inTx=inTx, - abort=abort + cycles=cycles ) @property @@ -673,22 +661,6 @@ class ImplBranchRecords(): def cycles(self) -> int: return self.c_branch_record.cycles - @property - def mispred(self) -> int: - return self.c_branch_record.mispred - - @property - def predicted(self) -> int: - return self.c_branch_record.predicted - - @property - def inTx(self) -> int: - return self.c_branch_record.inTx - - @property - def abort(self) -> int: - return self.c_branch_record.abort - @classmethod def from_c_branch_record(cls, c_branch_record: CytpesBranchSampleRecord) -> 'ImplBranchRecords': branch_record = cls() diff --git a/python/tests/test_brbe.py b/python/tests/test_brbe.py index ebee8829bb12af57bb10577042fcdb8e10d2eb2a..3b3c7f1fd66cb59c861201644bb1b4d2dc606d45 100644 --- a/python/tests/test_brbe.py +++ b/python/tests/test_brbe.py @@ -18,10 +18,7 @@ def TestBrBe(): for data in pmu_data.iter: if data.ext and data.ext.branchRecords: for item in data.ext.branchRecords.iter: - predicted = 'P' - if item.mispred: - predicted = 'M' - print(f"{hex(item.fromAddr)}->{hex(item.toAddr)} {item.cycles} {predicted}") + print(f"{hex(item.fromAddr)}->{hex(item.toAddr)} {item.cycles}") if __name__ == "__main__": TestBrBe() diff --git a/test/test_perf/test_api.cpp b/test/test_perf/test_api.cpp index f869b35f721b21a31713afc3541dd9c8ca635392..6ae2eeacbcec400d483dffab4e22236ce40b2f7c 100644 --- a/test/test_perf/test_api.cpp +++ b/test/test_perf/test_api.cpp @@ -639,7 +639,7 @@ TEST_F(TestAPI, TestBrBe) for (int j = 0; j < pmuData.ext->nr; j++) { auto *rd = pmuData.ext->branchRecords; - std::cout << std::hex << rd[j].fromAddr << "->" << rd[j].toAddr << " " << rd[j].cycles << " " << rd[j].predicted << " " << rd[j].mispred << std::endl; + std::cout << std::hex << rd[j].fromAddr << "->" << rd[j].toAddr << " " << rd[j].cycles << std::endl; } } }