diff options
| author | Ian Rogers <[email protected]> | 2025-02-28 22:23:05 +0000 |
|---|---|---|
| committer | Namhyung Kim <[email protected]> | 2025-03-12 01:55:38 +0000 |
| commit | 9e9472c148b8c61ed5eb50eea3277e779bf601fe (patch) | |
| tree | 32bfa31e21395bcf6d5d91b2d36800c474addc90 /tools/perf/util/python.c | |
| parent | perf python: Update ungrouped evsel leader in clone (diff) | |
| download | kernel-9e9472c148b8c61ed5eb50eea3277e779bf601fe.tar.gz kernel-9e9472c148b8c61ed5eb50eea3277e779bf601fe.zip | |
perf python: Avoid duplicated code in get_tracepoint_field
The code replicates computations done in evsel__tp_format, reuse
evsel__tp_format to simplify the python C code.
Reviewed-by: Howard Chu <[email protected]>
Signed-off-by: Ian Rogers <[email protected]>
Reviewed-by: Arnaldo Carvalho de Melo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Diffstat (limited to 'tools/perf/util/python.c')
| -rw-r--r-- | tools/perf/util/python.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index e244cc74f16d..7f2513ffe866 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -342,23 +342,14 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name) { const char *str = _PyUnicode_AsString(PyObject_Str(attr_name)); struct evsel *evsel = pevent->evsel; + struct tep_event *tp_format = evsel__tp_format(evsel); struct tep_format_field *field; - if (!evsel->tp_format) { - struct tep_event *tp_format; - - tp_format = trace_event__tp_format_id(evsel->core.attr.config); - if (IS_ERR_OR_NULL(tp_format)) - return NULL; - - evsel->tp_format = tp_format; - } - - field = tep_find_any_field(evsel->tp_format, str); - if (!field) + if (IS_ERR_OR_NULL(tp_format)) return NULL; - return tracepoint_field(pevent, field); + field = tep_find_any_field(tp_format, str); + return field ? tracepoint_field(pevent, field) : NULL; } #endif /* HAVE_LIBTRACEEVENT */ |
