提交 fe9d18a7 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

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: NNamhyung Kim <namhyung.kim@lge.com>
Reviewed-by: NDavid 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 20f946b4
...@@ -588,7 +588,7 @@ static void *display_thread_tui(void *arg) ...@@ -588,7 +588,7 @@ static void *display_thread_tui(void *arg)
* via --uid. * via --uid.
*/ */
list_for_each_entry(pos, &top->evlist->entries, node) list_for_each_entry(pos, &top->evlist->entries, node)
pos->hists.uid_filter_str = top->uid_str; pos->hists.uid_filter_str = top->target.uid_str;
perf_evlist__tui_browse_hists(top->evlist, help, perf_evlist__tui_browse_hists(top->evlist, help,
perf_top__sort_new_samples, perf_top__sort_new_samples,
...@@ -1016,7 +1016,7 @@ static int __cmd_top(struct perf_top *top) ...@@ -1016,7 +1016,7 @@ static int __cmd_top(struct perf_top *top)
if (ret) if (ret)
goto out_delete; goto out_delete;
if (top->target_tid || top->uid != UINT_MAX) if (top->target.tid || top->target.uid != UINT_MAX)
perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
perf_event__process, perf_event__process,
&top->session->host_machine); &top->session->host_machine);
...@@ -1154,7 +1154,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1154,7 +1154,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
struct perf_top top = { struct perf_top top = {
.count_filter = 5, .count_filter = 5,
.delay_secs = 2, .delay_secs = 2,
.uid = UINT_MAX,
.freq = 1000, /* 1 KHz */ .freq = 1000, /* 1 KHz */
.mmap_pages = 128, .mmap_pages = 128,
.sym_pcnt_filter = 5, .sym_pcnt_filter = 5,
...@@ -1166,13 +1165,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1166,13 +1165,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
parse_events_option), parse_events_option),
OPT_INTEGER('c', "count", &top.default_interval, OPT_INTEGER('c', "count", &top.default_interval,
"event period to sample"), "event period to sample"),
OPT_STRING('p', "pid", &top.target_pid, "pid", OPT_STRING('p', "pid", &top.target.pid, "pid",
"profile events on existing process id"), "profile events on existing process id"),
OPT_STRING('t', "tid", &top.target_tid, "tid", OPT_STRING('t', "tid", &top.target.tid, "tid",
"profile events on existing thread id"), "profile events on existing thread id"),
OPT_BOOLEAN('a', "all-cpus", &top.system_wide, OPT_BOOLEAN('a', "all-cpus", &top.target.system_wide,
"system-wide collection from all CPUs"), "system-wide collection from all CPUs"),
OPT_STRING('C', "cpu", &top.cpu_list, "cpu", OPT_STRING('C', "cpu", &top.target.cpu_list, "cpu",
"list of cpus to monitor"), "list of cpus to monitor"),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"), "file", "vmlinux pathname"),
...@@ -1227,7 +1226,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1227,7 +1226,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
"Display raw encoding of assembly instructions (default)"), "Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
"Specify disassembler style (e.g. -M intel for intel syntax)"), "Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_STRING('u', "uid", &top.uid_str, "user", "user to profile"), OPT_STRING('u', "uid", &top.target.uid_str, "user", "user to profile"),
OPT_END() OPT_END()
}; };
...@@ -1253,22 +1252,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1253,22 +1252,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
setup_browser(false); setup_browser(false);
top.uid = parse_target_uid(top.uid_str, top.target_tid, top.target_pid); top.target.uid = parse_target_uid(top.target.uid_str, top.target.tid,
if (top.uid_str != NULL && top.uid == UINT_MAX - 1) top.target.pid);
if (top.target.uid_str != NULL && top.target.uid == UINT_MAX - 1)
goto out_delete_evlist; goto out_delete_evlist;
/* CPU and PID are mutually exclusive */ /* CPU and PID are mutually exclusive */
if (top.target_tid && top.cpu_list) { if (top.target.tid && top.target.cpu_list) {
printf("WARNING: PID switch overriding CPU\n"); printf("WARNING: PID switch overriding CPU\n");
sleep(1); sleep(1);
top.cpu_list = NULL; top.target.cpu_list = NULL;
} }
if (top.target_pid) if (top.target.pid)
top.target_tid = top.target_pid; top.target.tid = top.target.pid;
if (perf_evlist__create_maps(top.evlist, top.target_pid, if (perf_evlist__create_maps(top.evlist, top.target.pid,
top.target_tid, top.uid, top.cpu_list) < 0) top.target.tid, top.target.uid,
top.target.cpu_list) < 0)
usage_with_options(top_usage, options); usage_with_options(top_usage, options);
if (!top.evlist->nr_entries && if (!top.evlist->nr_entries &&
......
...@@ -69,23 +69,24 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size) ...@@ -69,23 +69,24 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
ret += SNPRINTF(bf + ret, size - ret, "], "); ret += SNPRINTF(bf + ret, size - ret, "], ");
if (top->target_pid) if (top->target.pid)
ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %s", ret += SNPRINTF(bf + ret, size - ret, " (target_pid: %s",
top->target_pid); top->target.pid);
else if (top->target_tid) else if (top->target.tid)
ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %s", ret += SNPRINTF(bf + ret, size - ret, " (target_tid: %s",
top->target_tid); top->target.tid);
else if (top->uid_str != NULL) else if (top->target.uid_str != NULL)
ret += SNPRINTF(bf + ret, size - ret, " (uid: %s", ret += SNPRINTF(bf + ret, size - ret, " (uid: %s",
top->uid_str); top->target.uid_str);
else else
ret += SNPRINTF(bf + ret, size - ret, " (all"); ret += SNPRINTF(bf + ret, size - ret, " (all");
if (top->cpu_list) if (top->target.cpu_list)
ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)", ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)",
top->evlist->cpus->nr > 1 ? "s" : "", top->cpu_list); top->evlist->cpus->nr > 1 ? "s" : "",
top->target.cpu_list);
else { else {
if (top->target_tid) if (top->target.tid)
ret += SNPRINTF(bf + ret, size - ret, ")"); ret += SNPRINTF(bf + ret, size - ret, ")");
else else
ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)", ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)",
......
...@@ -13,6 +13,7 @@ struct perf_session; ...@@ -13,6 +13,7 @@ struct perf_session;
struct perf_top { struct perf_top {
struct perf_tool tool; struct perf_tool tool;
struct perf_evlist *evlist; struct perf_evlist *evlist;
struct perf_target target;
/* /*
* Symbols will be added here in perf_event__process_sample and will * Symbols will be added here in perf_event__process_sample and will
* get out after decayed. * get out after decayed.
...@@ -23,10 +24,7 @@ struct perf_top { ...@@ -23,10 +24,7 @@ struct perf_top {
u64 guest_us_samples, guest_kernel_samples; u64 guest_us_samples, guest_kernel_samples;
int print_entries, count_filter, delay_secs; int print_entries, count_filter, delay_secs;
int freq; int freq;
const char *target_pid, *target_tid;
uid_t uid;
bool hide_kernel_symbols, hide_user_symbols, zero; bool hide_kernel_symbols, hide_user_symbols, zero;
bool system_wide;
bool use_tui, use_stdio; bool use_tui, use_stdio;
bool sort_has_symbols; bool sort_has_symbols;
bool dont_use_callchains; bool dont_use_callchains;
...@@ -37,7 +35,6 @@ struct perf_top { ...@@ -37,7 +35,6 @@ struct perf_top {
bool sample_id_all_missing; bool sample_id_all_missing;
bool exclude_guest_missing; bool exclude_guest_missing;
bool dump_symtab; bool dump_symtab;
const char *cpu_list;
struct hist_entry *sym_filter_entry; struct hist_entry *sym_filter_entry;
struct perf_evsel *sym_evsel; struct perf_evsel *sym_evsel;
struct perf_session *session; struct perf_session *session;
...@@ -47,7 +44,6 @@ struct perf_top { ...@@ -47,7 +44,6 @@ struct perf_top {
int realtime_prio; int realtime_prio;
int sym_pcnt_filter; int sym_pcnt_filter;
const char *sym_filter; const char *sym_filter;
const char *uid_str;
}; };
size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size); size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册