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.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 821c1586a22b..9ac05aafd9b2 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -202,9 +202,20 @@ static struct thread_stat *thread_stat_findnew_first(u32 tid)
202SINGLE_KEY(nr_acquired) 202SINGLE_KEY(nr_acquired)
203SINGLE_KEY(nr_contended) 203SINGLE_KEY(nr_contended)
204SINGLE_KEY(wait_time_total) 204SINGLE_KEY(wait_time_total)
205SINGLE_KEY(wait_time_min)
206SINGLE_KEY(wait_time_max) 205SINGLE_KEY(wait_time_max)
207 206
207static int lock_stat_key_wait_time_min(struct lock_stat *one,
208 struct lock_stat *two)
209{
210 u64 s1 = one->wait_time_min;
211 u64 s2 = two->wait_time_min;
212 if (s1 == ULLONG_MAX)
213 s1 = 0;
214 if (s2 == ULLONG_MAX)
215 s2 = 0;
216 return s1 > s2;
217}
218
208struct lock_key { 219struct lock_key {
209 /* 220 /*
210 * name: the value for specify by user 221 * name: the value for specify by user
@@ -782,9 +793,9 @@ static void print_result(void)
782 pr_info("%10u ", st->nr_acquired); 793 pr_info("%10u ", st->nr_acquired);
783 pr_info("%10u ", st->nr_contended); 794 pr_info("%10u ", st->nr_contended);
784 795
785 pr_info("%15llu ", st->wait_time_total); 796 pr_info("%15" PRIu64 " ", st->wait_time_total);
786 pr_info("%15llu ", st->wait_time_max); 797 pr_info("%15" PRIu64 " ", st->wait_time_max);
787 pr_info("%15llu ", st->wait_time_min == ULLONG_MAX ? 798 pr_info("%15" PRIu64 " ", st->wait_time_min == ULLONG_MAX ?
788 0 : st->wait_time_min); 799 0 : st->wait_time_min);
789 pr_info("\n"); 800 pr_info("\n");
790 } 801 }
@@ -834,35 +845,33 @@ static void dump_info(void)
834 die("Unknown type of information\n"); 845 die("Unknown type of information\n");
835} 846}
836 847
837static int process_sample_event(event_t *self, struct perf_session *s) 848static int process_sample_event(union perf_event *event,
849 struct perf_sample *sample,
850 struct perf_evsel *evsel __used,
851 struct perf_session *s)
838{ 852{
839 struct sample_data data; 853 struct thread *thread = perf_session__findnew(s, sample->tid);
840 struct thread *thread;
841 854
842 bzero(&data, sizeof(data));
843 event__parse_sample(self, s->sample_type, &data);
844
845 thread = perf_session__findnew(s, data.tid);
846 if (thread == NULL) { 855 if (thread == NULL) {
847 pr_debug("problem processing %d event, skipping it.\n", 856 pr_debug("problem processing %d event, skipping it.\n",
848 self->header.type); 857 event->header.type);
849 return -1; 858 return -1;
850 } 859 }
851 860
852 process_raw_event(data.raw_data, data.cpu, data.time, thread); 861 process_raw_event(sample->raw_data, sample->cpu, sample->time, thread);
853 862
854 return 0; 863 return 0;
855} 864}
856 865
857static struct perf_event_ops eops = { 866static struct perf_event_ops eops = {
858 .sample = process_sample_event, 867 .sample = process_sample_event,
859 .comm = event__process_comm, 868 .comm = perf_event__process_comm,
860 .ordered_samples = true, 869 .ordered_samples = true,
861}; 870};
862 871
863static int read_events(void) 872static int read_events(void)
864{ 873{
865 session = perf_session__new(input_name, O_RDONLY, 0, false); 874 session = perf_session__new(input_name, O_RDONLY, 0, false, &eops);
866 if (!session) 875 if (!session)
867 die("Initializing perf session failed\n"); 876 die("Initializing perf session failed\n");
868 877
@@ -897,7 +906,7 @@ static const char * const report_usage[] = {
897 906
898static const struct option report_options[] = { 907static const struct option report_options[] = {
899 OPT_STRING('k', "key", &sort_key, "acquired", 908 OPT_STRING('k', "key", &sort_key, "acquired",
900 "key for sorting"), 909 "key for sorting (acquired / contended / wait_total / wait_max / wait_min)"),
901 /* TODO: type */ 910 /* TODO: type */
902 OPT_END() 911 OPT_END()
903}; 912};
@@ -947,6 +956,9 @@ static int __cmd_record(int argc, const char **argv)
947 rec_argc = ARRAY_SIZE(record_args) + argc - 1; 956 rec_argc = ARRAY_SIZE(record_args) + argc - 1;
948 rec_argv = calloc(rec_argc + 1, sizeof(char *)); 957 rec_argv = calloc(rec_argc + 1, sizeof(char *));
949 958
959 if (rec_argv == NULL)
960 return -ENOMEM;
961
950 for (i = 0; i < ARRAY_SIZE(record_args); i++) 962 for (i = 0; i < ARRAY_SIZE(record_args); i++)
951 rec_argv[i] = strdup(record_args[i]); 963 rec_argv[i] = strdup(record_args[i]);
952 964
@@ -982,9 +994,9 @@ int cmd_lock(int argc, const char **argv, const char *prefix __used)
982 usage_with_options(report_usage, report_options); 994 usage_with_options(report_usage, report_options);
983 } 995 }
984 __cmd_report(); 996 __cmd_report();
985 } else if (!strcmp(argv[0], "trace")) { 997 } else if (!strcmp(argv[0], "script")) {
986 /* Aliased to 'perf trace' */ 998 /* Aliased to 'perf script' */
987 return cmd_trace(argc, argv, prefix); 999 return cmd_script(argc, argv, prefix);
988 } else if (!strcmp(argv[0], "info")) { 1000 } else if (!strcmp(argv[0], "info")) {
989 if (argc) { 1001 if (argc) {
990 argc = parse_options(argc, argv, 1002 argc = parse_options(argc, argv,