Re: [PATCH v5 16/58] perf python: Add syscall name/id to convert syscall number and name

sashiko-bot
2026-04-24T17:19:03Z

Sashiko AI review found 1 potential issue(s):
- [Low] Linking the perf Python module fails with undefined references to `syscalltbl__name` and `syscalltbl__id` when built without libtraceevent.
--

commit bc598ef831f6053687cf5a98e1f88fb63ac39178
Author: Ian Rogers <irogers@google.com>

perf python: Add syscall name/id to convert syscall number and name

Use perf's syscalltbl support to convert syscall number to name assuming the
number is for the host machine. This avoids python libaudit support as
tools/perf/scripts/python/syscall-counts.py requires.

> diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
> index 35eda69a32e164..f240905e07d6c1 100644
> --- a/tools/perf/util/python.c
> +++ b/tools/perf/util/python.c
[ ... ]
> @@ -2635,6 +2637,36 @@ static int pyrf_session__setup_types(void)
> return PyType_Ready(&pyrf_session__type);
> }
>
> +static PyObject *pyrf__syscall_name(PyObject *self, PyObject *args)
> +{
> + const char *name;
> + int id;
> +
> + if (!PyArg_ParseTuple(args, "i", &id))
> + return NULL;
> +
> + name = syscalltbl__name(EM_HOST, id);
> + if (!name)
> + Py_RETURN_NONE;
> + return PyUnicode_FromString(name);
> +}
> +
> +static PyObject *pyrf__syscall_id(PyObject *self, PyObject *args)
> +{
> + const char *name;
> + int id;
> +
> + if (!PyArg_ParseTuple(args, "s", &name))
> + return NULL;
> +
> + id = syscalltbl__id(EM_HOST, name);

Will linking the perf Python module fail with undefined references to
syscalltbl__name and syscalltbl__id when built without libtraceevent?

In tools/perf/util/Build, syscalltbl.o is conditionally built depending on
CONFIG_TRACE (perf-util-$(CONFIG_TRACE) += syscalltbl.o), which is disabled
when perf is built without libtraceevent (e.g., via NO_LIBTRACEEVENT=1).

Since there are no stub implementations for these functions in syscalltbl.h,
it appears building the Python extension on systems lacking libtraceevent
will fail with linker errors.

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260424164721.2229025-1-irogers@google.com?part=16