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 tracepoint: Switch to using parse_events

Rather than manually configuring an evsel, switch to using
parse_events for greater commonality with the rest of the perf code.

Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/20250228222308.626803-12-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
f7cffbab 0dfcc7c8

+11 -12
+11 -12
tools/perf/python/tracepoint.py
··· 5 5 6 6 import perf 7 7 8 - class tracepoint(perf.evsel): 9 - def __init__(self, sys, name): 10 - config = perf.tracepoint(sys, name) 11 - perf.evsel.__init__(self, 12 - type = perf.TYPE_TRACEPOINT, 13 - config = config, 14 - freq = 0, sample_period = 1, wakeup_events = 1, 15 - sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU | perf.SAMPLE_RAW | perf.SAMPLE_TIME) 16 - 17 8 def main(): 18 - tp = tracepoint("sched", "sched_switch") 19 9 cpus = perf.cpu_map() 20 10 threads = perf.thread_map(-1) 11 + evlist = perf.parse_events("sched:sched_switch", cpus, threads) 12 + # Disable tracking of mmaps and similar that are unnecessary. 13 + for ev in evlist: 14 + ev.tracking = False 15 + # Configure evsels with default record options. 16 + evlist.config() 17 + # Simplify the sample_type and read_format of evsels 18 + for ev in evlist: 19 + ev.sample_type = ev.sample_type & ~perf.SAMPLE_IP 20 + ev.read_format = 0 21 21 22 - evlist = perf.evlist(cpus, threads) 23 - evlist.add(tp) 24 22 evlist.open() 25 23 evlist.mmap() 24 + evlist.enable(); 26 25 27 26 while True: 28 27 evlist.poll(timeout = -1)