mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 12:13:51 -04:00
perf python: Add config file access
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@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alice Rogers <alice.mei.rogers@gmail.com> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Leo Yan <leo.yan@linux.dev> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "build-id.h"
|
||||
#include "callchain.h"
|
||||
#include "comm.h"
|
||||
#include "config.h"
|
||||
#include "counts.h"
|
||||
#include "data.h"
|
||||
#include "debug.h"
|
||||
@@ -3993,7 +3994,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,
|
||||
|
||||
Reference in New Issue
Block a user