From 74fab9266ac3a65ba888ca4f9bbd6a8da94275d0 Mon Sep 17 00:00:00 2001 From: "lijindong (C)" <2220386943@qq.com> Date: Fri, 14 Nov 2025 16:37:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=96=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/C_C++_API.md | 7 +++++-- docs/Details_Usage.md | 8 ++++---- docs/Go_API.md | 8 ++++++-- docs/Python_API.md | 6 +++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/C_C++_API.md b/docs/C_C++_API.md index d9782a6..12b57ec 100644 --- a/docs/C_C++_API.md +++ b/docs/C_C++_API.md @@ -20,7 +20,11 @@ * unsigned numCpu 采集cpu核的个数 * struct EvtAttr *evtAttr - 事件分组列表,和evtList搭配使用,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + 用于对各事件做单独属性定义的列表 + * groupId 事件分组ID,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + * period 如果PmuAttr中useFreq=True则为采样频率,否则为采样间隔 + * excludeUser 排除对用户态数据的采集 + * excludeKernel 排除对内核态数据的采集 * unsigned numGroup 参与分组的事件个数 * union @@ -157,7 +161,6 @@ * unsigned long event 事件ID * unsigned short lat 调度操作到执行操作的周期数 * unsigned short source 记录加载或存储操作的数据来源 - * unsigned short branchRecords brbe数据 * struct * unsigned long nr branchRecords的数量 * struct BranchSampleRecord *branchRecords branch指针数组 diff --git a/docs/Details_Usage.md b/docs/Details_Usage.md index 494ea73..80ec245 100644 --- a/docs/Details_Usage.md +++ b/docs/Details_Usage.md @@ -979,11 +979,11 @@ perf stat -e "{inst_retired,inst_spec,cycles}","{inst_retired,cycles}" char *evtList[5] = {"inst_retired", "inst_spec", "cycles", "inst_retired", "cycles"}; // 指定事件分组编号,前三个事件为一组,后两个事件为一组。设置groupId=-1表示对应事件不参与分组。 // 当事件数量numEvt超过指定事件分组数量numGroup时,超过分组数量的事件的groupId默认为-1,即不参与分组。 -EvtAttr groupId[5] = {1,1,1,2,2}; +EvtAttr attrList[5] = {{1},{1},{1},{2},{2}}; PmuAttr attr = {0}; attr.evtList = evtList; attr.numEvt = 5; -attr.evtAttr = groupId; +attr.evtAttr = attrList; attr.numGroup = 5; int pd = PmuOpen(COUNTING, &attr); PmuEnable(pd); @@ -1010,7 +1010,7 @@ from collections import defaultdict evtList = ["inst_retired", "inst_spec", "cycles", "inst_retired", "cycles"] # 指定事件分组编号,前三个事件为一组,后两个事件为一组。 -evtAttrList = [1,1,1,2,2] +evtAttrList = [kperf.EvtAttr(1),kperf.EvtAttr(1),kperf.EvtAttr(1),kperf.EvtAttr(2),kperf.EvtAttr(2)] pmu_attr = kperf.PmuAttr(evtList=evtList, evtAttr = evtAttrList) pd = kperf.open(kperf.PmuTaskType.COUNTING, pmu_attr) kperf.enable(pd) @@ -1036,7 +1036,7 @@ import "time" func main() { evtList := []string{"inst_retired", "inst_spec", "cycles", "inst_retired", "cycles"} - evtAttrList := []int{1,1,1,2,2} + evtAttrList := []kperf.EvtAttr{kperf.EvtAttr{1,0,false,false},kperf.EvtAttr{1,0,false,false},kperf.EvtAttr{1,0,false,false},kperf.EvtAttr{2,0,false,false},kperf.EvtAttr{2,0,false,false}} attr := kperf.PmuAttr{EvtList: evtList, EvtAttr: evtAttrList} pd, err := kperf.PmuOpen(kperf.COUNT, attr) if err != nil { diff --git a/docs/Go_API.md b/docs/Go_API.md index 6f471d0..d989f20 100644 --- a/docs/Go_API.md +++ b/docs/Go_API.md @@ -16,8 +16,12 @@ func PmuOpen(collectType C.enum_PmuTaskType, attr PmuAttr) (int, error) 采集的进程id列表 * CpuList []int 指定的使用cpu核采集列表,默认采集所有逻辑核 - * EvtAttr []int - 事件分组列表,和evtList搭配使用,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + * EvtAttr []EvtAttr + 用于对各事件做单独属性定义 + * GroupId 事件分组ID,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + * Period 如果PmuAttr中useFreq=True则为采样频率,否则为采样间隔 + * ExcludeUser 排除对用户态数据的采集 + * ExcludeKernel 排除对内核态数据的采集 * SampleRate uint32 采样频率,可通过/proc/sys/kernel/perf_event_max_sample_rate调整最大的采样频率 * UseFreq bool diff --git a/docs/Python_API.md b/docs/Python_API.md index cdccfb6..6a2760e 100644 --- a/docs/Python_API.md +++ b/docs/Python_API.md @@ -17,7 +17,11 @@ kperf.open(collector_type: kperf.PmuTaskType, pmu_attr: kperf.PmuAttr) * cpuList 指定的使用cpu核采集列表,默认采集所有逻辑核 * evtAttr - 事件分组列表,和evtList搭配使用,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + 用于对各事件做单独属性定义 + * groupId 事件分组ID,同组事件需要使用相同数字表示,不同组事件使用不同的数字代表,如果数字为-1,则不参与事件分组 + * period 如果PmuAttr中useFreq=True则为采样频率,否则为采样间隔 + * excludeUser 排除对用户态数据的采集 + * excludeKernel 排除对内核态数据的采集 * sampleRate 采样频率,可通过/proc/sys/kernel/perf_event_max_sample_rate调整最大的采样频率 * useFreq -- Gitee