aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-lock.c')
-rw-r--r--tools/perf/builtin-lock.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 972310cbeb63..6a9076f165f4 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -56,7 +56,9 @@ struct lock_stat {
56 56
57 unsigned int nr_readlock; 57 unsigned int nr_readlock;
58 unsigned int nr_trylock; 58 unsigned int nr_trylock;
59
59 /* these times are in nano sec. */ 60 /* these times are in nano sec. */
61 u64 avg_wait_time;
60 u64 wait_time_total; 62 u64 wait_time_total;
61 u64 wait_time_min; 63 u64 wait_time_min;
62 u64 wait_time_max; 64 u64 wait_time_max;
@@ -208,6 +210,7 @@ static struct thread_stat *thread_stat_findnew_first(u32 tid)
208 210
209SINGLE_KEY(nr_acquired) 211SINGLE_KEY(nr_acquired)
210SINGLE_KEY(nr_contended) 212SINGLE_KEY(nr_contended)
213SINGLE_KEY(avg_wait_time)
211SINGLE_KEY(wait_time_total) 214SINGLE_KEY(wait_time_total)
212SINGLE_KEY(wait_time_max) 215SINGLE_KEY(wait_time_max)
213 216
@@ -244,6 +247,7 @@ static struct rb_root result; /* place to store sorted data */
244struct lock_key keys[] = { 247struct lock_key keys[] = {
245 DEF_KEY_LOCK(acquired, nr_acquired), 248 DEF_KEY_LOCK(acquired, nr_acquired),
246 DEF_KEY_LOCK(contended, nr_contended), 249 DEF_KEY_LOCK(contended, nr_contended),
250 DEF_KEY_LOCK(avg_wait, avg_wait_time),
247 DEF_KEY_LOCK(wait_total, wait_time_total), 251 DEF_KEY_LOCK(wait_total, wait_time_total),
248 DEF_KEY_LOCK(wait_min, wait_time_min), 252 DEF_KEY_LOCK(wait_min, wait_time_min),
249 DEF_KEY_LOCK(wait_max, wait_time_max), 253 DEF_KEY_LOCK(wait_max, wait_time_max),
@@ -516,6 +520,7 @@ static int report_lock_acquired_event(struct perf_evsel *evsel,
516 520
517 seq->state = SEQ_STATE_ACQUIRED; 521 seq->state = SEQ_STATE_ACQUIRED;
518 ls->nr_acquired++; 522 ls->nr_acquired++;
523 ls->avg_wait_time = ls->nr_contended ? ls->wait_time_total/ls->nr_contended : 0;
519 seq->prev_event_time = sample->time; 524 seq->prev_event_time = sample->time;
520end: 525end:
521 return 0; 526 return 0;
@@ -570,6 +575,7 @@ static int report_lock_contended_event(struct perf_evsel *evsel,
570 575
571 seq->state = SEQ_STATE_CONTENDED; 576 seq->state = SEQ_STATE_CONTENDED;
572 ls->nr_contended++; 577 ls->nr_contended++;
578 ls->avg_wait_time = ls->wait_time_total/ls->nr_contended;
573 seq->prev_event_time = sample->time; 579 seq->prev_event_time = sample->time;
574end: 580end:
575 return 0; 581 return 0;
@@ -703,6 +709,7 @@ static void print_result(void)
703 pr_info("%10s ", "acquired"); 709 pr_info("%10s ", "acquired");
704 pr_info("%10s ", "contended"); 710 pr_info("%10s ", "contended");
705 711
712 pr_info("%15s ", "avg wait (ns)");
706 pr_info("%15s ", "total wait (ns)"); 713 pr_info("%15s ", "total wait (ns)");
707 pr_info("%15s ", "max wait (ns)"); 714 pr_info("%15s ", "max wait (ns)");
708 pr_info("%15s ", "min wait (ns)"); 715 pr_info("%15s ", "min wait (ns)");
@@ -734,6 +741,7 @@ static void print_result(void)
734 pr_info("%10u ", st->nr_acquired); 741 pr_info("%10u ", st->nr_acquired);
735 pr_info("%10u ", st->nr_contended); 742 pr_info("%10u ", st->nr_contended);
736 743
744 pr_info("%15" PRIu64 " ", st->avg_wait_time);
737 pr_info("%15" PRIu64 " ", st->wait_time_total); 745 pr_info("%15" PRIu64 " ", st->wait_time_total);
738 pr_info("%15" PRIu64 " ", st->wait_time_max); 746 pr_info("%15" PRIu64 " ", st->wait_time_max);
739 pr_info("%15" PRIu64 " ", st->wait_time_min == ULLONG_MAX ? 747 pr_info("%15" PRIu64 " ", st->wait_time_min == ULLONG_MAX ?
@@ -940,7 +948,7 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
940 }; 948 };
941 const struct option report_options[] = { 949 const struct option report_options[] = {
942 OPT_STRING('k', "key", &sort_key, "acquired", 950 OPT_STRING('k', "key", &sort_key, "acquired",
943 "key for sorting (acquired / contended / wait_total / wait_max / wait_min)"), 951 "key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
944 /* TODO: type */ 952 /* TODO: type */
945 OPT_END() 953 OPT_END()
946 }; 954 };