]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf: sched map skips redundant lines with cpu filters
authorFernand Sieber <sieberf@amazon.com>
Fri, 14 Jun 2024 07:35:17 +0000 (09:35 +0200)
committerNamhyung Kim <namhyung@kernel.org>
Sun, 16 Jun 2024 04:03:50 +0000 (21:03 -0700)
perf sched map supports cpu filter.
However, even with cpu filters active, any context switch currently
corresponds to a separate line.
As result, context switches on irrelevant cpus result to redundant lines,
which makes the output particlularly difficult to read on wide
architectures.

Fix it by skipping printing for irrelevant CPUs.

Example snippet of output before fix:

  *B0       1.461147 secs
   B0
   B0
   B0
  *G0       1.517139 secs

After fix:

  *B0       1.461147 secs
  *G0       1.517139 secs

Signed-off-by: Fernand Sieber <sieberf@amazon.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-and-tested-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240614073517.94974-1-sieberf@amazon.com
tools/perf/builtin-sched.c

index 5977c49ae2c76beabc57ee830fb6bde106a9d4b2..8cdf18139a7e6b9d784ea91b5da108ee7b772881 100644 (file)
@@ -1594,8 +1594,6 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
 
        sched->curr_thread[this_cpu.cpu] = thread__get(sched_in);
 
-       printf("  ");
-
        new_shortname = 0;
        if (!tr->shortname[0]) {
                if (!strcmp(thread__comm_str(sched_in), "swapper")) {
@@ -1622,6 +1620,11 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
                new_shortname = 1;
        }
 
+       if (sched->map.cpus && !perf_cpu_map__has(sched->map.cpus, this_cpu))
+               goto out;
+
+       printf("  ");
+
        for (i = 0; i < cpus_nr; i++) {
                struct perf_cpu cpu = {
                        .cpu = sched->map.comp ? sched->map.comp_cpus[i].cpu : i,
@@ -1656,9 +1659,6 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
                        color_fprintf(stdout, color, "   ");
        }
 
-       if (sched->map.cpus && !perf_cpu_map__has(sched->map.cpus, this_cpu))
-               goto out;
-
        timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp));
        color_fprintf(stdout, color, "  %12s secs ", stimestamp);
        if (new_shortname || tr->comm_changed || (verbose > 0 && thread__tid(sched_in))) {
@@ -1675,9 +1675,9 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,
        if (sched->map.comp && new_cpu)
                color_fprintf(stdout, color, " (CPU %d)", this_cpu);
 
-out:
        color_fprintf(stdout, color, "\n");
 
+out:
        thread__put(sched_in);
 
        return 0;