Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <howardchu95@gmail.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250228222308.626803-9-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
9e9472c1 07fc2316

+4 -13
+4 -13
tools/perf/util/python.c
··· 342 342 { 343 343 const char *str = _PyUnicode_AsString(PyObject_Str(attr_name)); 344 344 struct evsel *evsel = pevent->evsel; 345 + struct tep_event *tp_format = evsel__tp_format(evsel); 345 346 struct tep_format_field *field; 346 347 347 - if (!evsel->tp_format) { 348 - struct tep_event *tp_format; 349 - 350 - tp_format = trace_event__tp_format_id(evsel->core.attr.config); 351 - if (IS_ERR_OR_NULL(tp_format)) 352 - return NULL; 353 - 354 - evsel->tp_format = tp_format; 355 - } 356 - 357 - field = tep_find_any_field(evsel->tp_format, str); 358 - if (!field) 348 + if (IS_ERR_OR_NULL(tp_format)) 359 349 return NULL; 360 350 361 - return tracepoint_field(pevent, field); 351 + field = tep_find_any_field(tp_format, str); 352 + return field ? tracepoint_field(pevent, field) : NULL; 362 353 } 363 354 #endif /* HAVE_LIBTRACEEVENT */ 364 355