aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-04-26 01:15:17 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-02 14:20:30 -0400
commitfe9d18a71d2018f8021fd2bd2aaf5137954ef839 (patch)
treee0cb4b12af0a7660d97e7b2e1f2c341e524e8f07 /tools
parent20f946b4a49dfd89c1c4ddeb55c0632893332674 (diff)
perf top: Convert to struct perf_target
Use struct perf_target as it is introduced by previous patch. This is a preparation of further changes. Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Reviewed-by: David Ahern <dsahern@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1335417327-11796-4-git-send-email-namhyung.kim@lge.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-top.c33
-rw-r--r--tools/perf/util/top.c19
-rw-r--r--tools/perf/util/top.h6
3 files changed, 28 insertions, 30 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8ef59f8262bb..2c1c207627b4 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -588,7 +588,7 @@ static void *display_thread_tui(void *arg)
588 * via --uid. 588 * via --uid.
589 */ 589 */
590 list_for_each_entry(pos, &top->evlist->entries, node) 590 list_for_each_entry(pos, &top->evlist->entries, node)
591 pos->hists.uid_filter_str = top->uid_str; 591 pos->hists.uid_filter_str = top->target.uid_str;
592 592
593 perf_evlist__tui_browse_hists(top->evlist, help, 593 perf_evlist__tui_browse_hists(top->evlist, help,
594 perf_top__sort_new_samples, 594 perf_top__sort_new_samples,
@@ -1016,7 +1016,7 @@ static int __cmd_top(struct perf_top *top)
1016 if (ret) 1016 if (ret)
1017 goto out_delete; 1017 goto out_delete;
1018 1018
1019 if (top->target_tid || top->uid != UINT_MAX) 1019 if (top->target.tid || top->target.uid != UINT_MAX)
1020 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, 1020 perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
1021 perf_event__process, 1021 perf_event__process,
1022 &top->session->host_machine); 1022 &top->session->host_machine);
@@ -1154,7 +1154,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1154 struct perf_top top = { 1154 struct perf_top top = {
1155 .count_filter = 5, 1155 .count_filter = 5,
1156 .delay_secs = 2, 1156 .delay_secs = 2,
1157 .uid = UINT_MAX,
1158 .freq = 1000, /* 1 KHz */ 1157 .freq = 1000, /* 1 KHz */
1159 .mmap_pages = 128, 1158 .mmap_pages = 128,
1160 .sym_pcnt_filter = 5, 1159 .sym_pcnt_filter = 5,
@@ -1166,13 +1165,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1166 parse_events_option), 1165 parse_events_option),
1167 OPT_INTEGER('c', "count", &top.default_interval, 1166 OPT_INTEGER('c', "count", &top.default_interval,
1168 "event period to sample"), 1167 "event period to sample"),
1169 OPT_STRING('p', "pid", &top.target_pid, "pid", 1168 OPT_STRING('p', "pid", &top.target.pid, "pid",
1170 "profile events on existing process id"), 1169 "profile events on existing process id"),
1171 OPT_STRING('t', "tid", &top.target_tid, "tid", 1170 OPT_STRING('t', "tid", &top.target.tid, "tid",
1172 "profile events on existing thread id"), 1171 "profile events on existing thread id"),
1173 OPT_BOOLEAN('a', "all-cpus", &top.system_wide, 1172 OPT_BOOLEAN('a', "all-cpus", &top.target.system_wide,
1174 "system-wide collection from all CPUs"), 1173 "system-wide collection from all CPUs"),
1175 OPT_STRING('C', "cpu", &top.cpu_list, "cpu", 1174 OPT_STRING('C', "cpu", &top.target.cpu_list, "cpu",
1176 "list of cpus to monitor"), 1175 "list of cpus to monitor"),
1177 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 1176 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
1178 "file", "vmlinux pathname"), 1177 "file", "vmlinux pathname"),
@@ -1227,7 +1226,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1227 "Display raw encoding of assembly instructions (default)"), 1226 "Display raw encoding of assembly instructions (default)"),
1228 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", 1227 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
1229 "Specify disassembler style (e.g. -M intel for intel syntax)"), 1228 "Specify disassembler style (e.g. -M intel for intel syntax)"),
1230 OPT_STRING('u', "uid", &top.uid_str, "user", "user to profile"), 1229 OPT_STRING('u', "uid", &top.target.uid_str, "user", "user to profile"),
1231 OPT_END() 1230 OPT_END()
1232 }; 1231 };
1233 1232
@@ -1253,22 +1252,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1253 1252
1254 setup_browser(false); 1253 setup_browser(false);
1255 1254
1256 top.uid = parse_target_uid(top.uid_str, top.target_tid, top.target_pid); 1255 top.target.uid = parse_target_uid(top.target.uid_str, top.target.tid,
1257 if (top.uid_str != NULL && top.uid == UINT_MAX - 1) 1256 top.target.pid);
1257 if (top.target.uid_str != NULL && top.target.uid == UINT_MAX - 1)
1258 goto out_delete_evlist; 1258 goto out_delete_evlist;
1259 1259
1260 /* CPU and PID are mutually exclusive */ 1260 /* CPU and PID are mutually exclusive */
1261 if (top.target_tid && top.cpu_list) { 1261 if (top.target.tid && top.target.cpu_list) {
1262 printf("WARNING: PID switch overriding CPU\n"); 1262 printf("WARNING: PID switch overriding CPU\n");
1263 sleep(1); 1263 sleep(1);
1264 top.cpu_list = NULL; 1264 top.target.cpu_list = NULL;
1265 } 1265 }
1266 1266
1267 if (top.target_pid) 1267 if (top.target.pid)
1268 top.target_tid = top.target_pid; 1268 top.target.tid = top.target.pid;
1269 1269
1270 if (perf_evlist__create_maps(top.evlist, top.target_pid, 1270 if (perf_evlist__create_maps(top.evlist, top.target.pid,
1271 top.target_tid, top.uid, top.cpu_list) < 0) 1271 top.target.tid, top.target.uid,
1272 top.target.cpu_list) < 0)
1272 usage_with_options(top_usage, options); 1273 usage_with_options(top_usage, options);
1273 1274
1274 if (!top.evlist->nr_entries && 1275 if (!top.evlist->nr_entries &&
diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c
index 09fe579ccafb..abe0e8e95068 100644
--- a/tools/perf/util/top.c
+++ b/tools/perf/util/top.c
@@ -69,23 +69,24 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
69 69
70 ret += SNPRINTF(bf + ret, size - ret, "], "); 70 ret += SNPRINTF(bf + ret, size - ret, "], ");
71 71
72 if (top->target_pid) 72 if (top->target.pid)
73 ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %s", 73 ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %s",
74 top->target_pid); 74 top->target.pid);
75 else if (top->target_tid) 75 else if (top->target.tid)
76 ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %s", 76 ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %s",
77 top->target_tid); 77 top->target.tid);
78 else if (top->uid_str != NULL) 78 else if (top->target.uid_str != NULL)
79 ret += SNPRINTF(bf + ret, size - ret, " (uid: %s", 79 ret += SNPRINTF(bf + ret, size - ret, " (uid: %s",
80 top->uid_str); 80 top->target.uid_str);
81 else 81 else
82 ret += SNPRINTF(bf + ret, size - ret, " (all"); 82 ret += SNPRINTF(bf + ret, size - ret, " (all");
83 83
84 if (top->cpu_list) 84 if (top->target.cpu_list)
85 ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)", 85 ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)",
86 top->evlist->cpus->nr > 1 ? "s" : "", top->cpu_list); 86 top->evlist->cpus->nr > 1 ? "s" : "",
87 top->target.cpu_list);
87 else { 88 else {
88 if (top->target_tid) 89 if (top->target.tid)
89 ret += SNPRINTF(bf + ret, size - ret, ")"); 90 ret += SNPRINTF(bf + ret, size - ret, ")");
90 else 91 else
91 ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)", 92 ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)",
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index ce61cb2d1acf..33347ca89ee4 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -13,6 +13,7 @@ struct perf_session;
13struct perf_top { 13struct perf_top {
14 struct perf_tool tool; 14 struct perf_tool tool;
15 struct perf_evlist *evlist; 15 struct perf_evlist *evlist;
16 struct perf_target target;
16 /* 17 /*
17 * Symbols will be added here in perf_event__process_sample and will 18 * Symbols will be added here in perf_event__process_sample and will
18 * get out after decayed. 19 * get out after decayed.
@@ -23,10 +24,7 @@ struct perf_top {
23 u64 guest_us_samples, guest_kernel_samples; 24 u64 guest_us_samples, guest_kernel_samples;
24 int print_entries, count_filter, delay_secs; 25 int print_entries, count_filter, delay_secs;
25 int freq; 26 int freq;
26 const char *target_pid, *target_tid;
27 uid_t uid;
28 bool hide_kernel_symbols, hide_user_symbols, zero; 27 bool hide_kernel_symbols, hide_user_symbols, zero;
29 bool system_wide;
30 bool use_tui, use_stdio; 28 bool use_tui, use_stdio;
31 bool sort_has_symbols; 29 bool sort_has_symbols;
32 bool dont_use_callchains; 30 bool dont_use_callchains;
@@ -37,7 +35,6 @@ struct perf_top {
37 bool sample_id_all_missing; 35 bool sample_id_all_missing;
38 bool exclude_guest_missing; 36 bool exclude_guest_missing;
39 bool dump_symtab; 37 bool dump_symtab;
40 const char *cpu_list;
41 struct hist_entry *sym_filter_entry; 38 struct hist_entry *sym_filter_entry;
42 struct perf_evsel *sym_evsel; 39 struct perf_evsel *sym_evsel;
43 struct perf_session *session; 40 struct perf_session *session;
@@ -47,7 +44,6 @@ struct perf_top {
47 int realtime_prio; 44 int realtime_prio;
48 int sym_pcnt_filter; 45 int sym_pcnt_filter;
49 const char *sym_filter; 46 const char *sym_filter;
50 const char *uid_str;
51}; 47};
52 48
53size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size); 49size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size);