From 9af55a4e8b4737b9a56da8c1416fc18fceb7182e Mon Sep 17 00:00:00 2001 From: wuying39 Date: Mon, 24 Nov 2025 20:45:36 +0800 Subject: [PATCH] add min_latency verification in SPE mode --- include/pcerrc.h | 1 + pmu/pmu.cpp | 4 ++++ python/modules/kperf/perror.py | 1 + util/pcerr.cpp | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/pcerrc.h b/include/pcerrc.h index bebe235..71efd6e 100644 --- a/include/pcerrc.h +++ b/include/pcerrc.h @@ -129,6 +129,7 @@ extern "C" { #define LIBPERF_ERR_BUFFER_CORRUPTED 1082 #define LIBPERF_ERR_NOT_SUPPORT_HWMETRIC 1083 #define LIBPERF_ERR_INVALID_HWMETRIC_ATTR 1084 +#define LIBPERF_ERR_INVALID_MIN_LATENCY 1085 #define UNKNOWN_ERROR 9999 diff --git a/pmu/pmu.cpp b/pmu/pmu.cpp index 259a3b9..012822b 100644 --- a/pmu/pmu.cpp +++ b/pmu/pmu.cpp @@ -255,6 +255,10 @@ static int CheckCollectTypeConfig(enum PmuTaskType collectType, struct PmuAttr * New(LIBPERF_ERR_INVALID_CGROUP_LIST, "SPE mode only support one cgroup"); return LIBPERF_ERR_INVALID_CGROUP_LIST; } + if (collectType == SPE_SAMPLING && (attr->minLatency > 4095 || attr->minLatency < 0)) { + New(LIBPERF_ERR_INVALID_MIN_LATENCY, "Invalid min_latency: value must be between 0 and 4095"); + return LIBPERF_ERR_INVALID_MIN_LATENCY; + } return SUCCESS; } diff --git a/python/modules/kperf/perror.py b/python/modules/kperf/perror.py index ccdaba9..8c29f5a 100644 --- a/python/modules/kperf/perror.py +++ b/python/modules/kperf/perror.py @@ -128,6 +128,7 @@ class Error: LIBPERF_ERR_BUFFER_CORRUPTED = 1082 LIBPERF_ERR_NOT_SUPPORT_HWMETRIC = 1083 LIBPERF_ERR_INVALID_HWMETRIC_ATTR = 1084 + LIBPERF_ERR_INVALID_MIN_LATENCY = 1085 UNKNOWN_ERROR = 9999 diff --git a/util/pcerr.cpp b/util/pcerr.cpp index 9cf3f64..24f69d3 100644 --- a/util/pcerr.cpp +++ b/util/pcerr.cpp @@ -67,7 +67,8 @@ namespace pcerr { {LIBPERF_ERR_CHECK_USER_ACCESS, "Check user access failed!"}, {LIBPERF_ERR_INVALID_BPF_PARAM, "check bpf mode failed"}, {LIBPERF_ERR_BPF_ACT_FAILED, "failed to execute bpf obj action"}, - {LIBPERF_ERR_NULL_POINTER, "the input pointer cannot be null"} + {LIBPERF_ERR_NULL_POINTER, "the input pointer cannot be null"}, + {LIBPERF_ERR_INVALID_MIN_LATENCY, "invalid min latency"} }; static std::unordered_map warnMsgs = { {LIBPERF_WARN_CTXID_LOST, "Some SPE context packets are not found in the traces."}, -- Gitee