perf lock: Skip print_bad_events() if nothing bad
authorNamhyung Kim <namhyung@kernel.org>
Wed, 15 Jun 2022 16:32:18 +0000 (09:32 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Jul 2022 12:55:04 +0000 (09:55 -0300)
The debug output is meaningful when there are bad lock sequences.
Skip it unless there's one or -v option is given.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20220615163222.1275500-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-lock.c

index 118a036a81fba3916f0945526f8c153eb1677af3..2337b09dd2cd1da9a2a98f213302d5fd29fe0c8f 100644 (file)
@@ -858,9 +858,16 @@ static void print_bad_events(int bad, int total)
 {
        /* Output for debug, this have to be removed */
        int i;
+       int broken = 0;
        const char *name[4] =
                { "acquire", "acquired", "contended", "release" };
 
+       for (i = 0; i < BROKEN_MAX; i++)
+               broken += bad_hist[i];
+
+       if (broken == 0 && !verbose)
+               return;
+
        pr_info("\n=== output for debug===\n\n");
        pr_info("bad: %d, total: %d\n", bad, total);
        pr_info("bad rate: %.2f %%\n", (double)bad / (double)total * 100);