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 lock: Carefully combine lock stats for discarded entries

Stats from discarded entries should be omitted.

But a lock class may have both good and bad entries.

If the first entry was bad, we can zero-fill the stats and only add good
stats if any.

The entry can remove the discard state if it finds a good entry later.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220127000050.3011493-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
ea0ddc27 0d435bf8

+16
+16
tools/perf/builtin-lock.c
··· 295 295 ret = !!st->name - !!p->name; 296 296 297 297 if (ret == 0) { 298 + if (st->discard) 299 + goto out; 300 + 298 301 p->nr_acquired += st->nr_acquired; 299 302 p->nr_contended += st->nr_contended; 300 303 p->wait_time_total += st->wait_time_total; ··· 310 307 if (p->wait_time_max < st->wait_time_max) 311 308 p->wait_time_max = st->wait_time_max; 312 309 310 + /* now it got a new !discard record */ 311 + p->discard = 0; 312 + 313 + out: 313 314 st->combined = 1; 314 315 return; 315 316 } ··· 326 319 327 320 rb_link_node(&st->rb, parent, rb); 328 321 rb_insert_color(&st->rb, &sorted); 322 + 323 + if (st->discard) { 324 + st->nr_acquired = 0; 325 + st->nr_contended = 0; 326 + st->wait_time_total = 0; 327 + st->avg_wait_time = 0; 328 + st->wait_time_min = ULLONG_MAX; 329 + st->wait_time_max = 0; 330 + } 329 331 } 330 332 331 333 static void insert_to_result(struct lock_stat *st,