[PATCH v6 19/59] perf python: Add config file access
Ian Rogers
irogers at google.com
Sat Apr 25 10:48:17 PDT 2026
Add perf.config_get(name) to expose the perf configuration system.
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <irogers at google.com>
---
tools/perf/util/python.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 70b5ad2b9b6f..b358852b3528 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -12,6 +12,7 @@
#include "build-id.h"
#include "callchain.h"
#include "comm.h"
+#include "config.h"
#include "counts.h"
#include "data.h"
#include "debug.h"
@@ -3229,7 +3230,26 @@ static PyObject *pyrf__syscall_id(PyObject *self, PyObject *args, PyObject *kwar
return PyLong_FromLong(id);
}
+static PyObject *pyrf__config_get(PyObject *self, PyObject *args)
+{
+ const char *config_name, *val;
+
+ if (!PyArg_ParseTuple(args, "s", &config_name))
+ return NULL;
+
+ val = perf_config_get(config_name);
+ if (!val)
+ Py_RETURN_NONE;
+ return PyUnicode_FromString(val);
+}
+
static PyMethodDef perf__methods[] = {
+ {
+ .ml_name = "config_get",
+ .ml_meth = (PyCFunction) pyrf__config_get,
+ .ml_flags = METH_VARARGS,
+ .ml_doc = PyDoc_STR("Get a perf config value.")
+ },
{
.ml_name = "metrics",
.ml_meth = (PyCFunction) pyrf__metrics,
--
2.54.0.545.g6539524ca2-goog
More information about the linux-arm-kernel
mailing list