diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-02-13 10:08:14 +0100 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-02-17 22:00:50 -0800 |
| commit | f13bc61b2e37957bf6e693ab5650d93fd21523f4 (patch) | |
| tree | 4a38f76d74609dc76aa45e4c33bff6421cf04198 /tools/perf/util/machine.c | |
| parent | perf tools: Fix compile error on sample->user_regs (diff) | |
| download | linux-f13bc61b2e37957bf6e693ab5650d93fd21523f4.tar.gz linux-f13bc61b2e37957bf6e693ab5650d93fd21523f4.zip | |
perf report: Add machine parallelism
Add calculation of the current parallelism level (number of threads actively
running on CPUs). The parallelism level can be shown in reports on its own,
and to calculate latency overheads.
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Link: https://lore.kernel.org/r/0f8c1b8eb12619029e31b3d5c0346f4616a5aeda.1739437531.git.dvyukov@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/machine.c')
| -rw-r--r-- | tools/perf/util/machine.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 55d4977b9913..d96cbfd97ad8 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -94,6 +94,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) machine->comm_exec = false; machine->kernel_start = 0; machine->vmlinux_map = NULL; + /* There is no initial context switch in, so we start at 1. */ + machine->parallelism = 1; machine->root_dir = strdup(root_dir); if (machine->root_dir == NULL) @@ -677,8 +679,11 @@ int machine__process_aux_output_hw_id_event(struct machine *machine __maybe_unus int machine__process_switch_event(struct machine *machine __maybe_unused, union perf_event *event) { + bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; + if (dump_trace) perf_event__fprintf_switch(event, stdout); + machine->parallelism += out ? -1 : 1; return 0; } @@ -1880,6 +1885,8 @@ int machine__process_exit_event(struct machine *machine, union perf_event *event if (dump_trace) perf_event__fprintf_task(event, stdout); + /* There is no context switch out before exit, so we decrement here. */ + machine->parallelism--; if (thread != NULL) { if (symbol_conf.keep_exited_threads) thread__set_exited(thread, /*exited=*/true); |
