diff options
| -rw-r--r-- | tools/perf/Documentation/perf-top.txt | 3 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/event.c | 5 | ||||
| -rw-r--r-- | tools/perf/util/top.h | 1 |
4 files changed, 16 insertions, 4 deletions
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index d864ea6fd367..4353262bc462 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt | |||
| @@ -240,6 +240,9 @@ Default is to monitor all CPUS. | |||
| 240 | --force:: | 240 | --force:: |
| 241 | Don't do ownership validation. | 241 | Don't do ownership validation. |
| 242 | 242 | ||
| 243 | --num-thread-synthesize:: | ||
| 244 | The number of threads to run when synthesizing events for existing processes. | ||
| 245 | By default, the number of threads equals to the number of online CPUs. | ||
| 243 | 246 | ||
| 244 | INTERACTIVE PROMPTING KEYS | 247 | INTERACTIVE PROMPTING KEYS |
| 245 | -------------------------- | 248 | -------------------------- |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index bc31b93cc1d8..477a8699f0b5 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -958,14 +958,16 @@ static int __cmd_top(struct perf_top *top) | |||
| 958 | if (perf_session__register_idle_thread(top->session) < 0) | 958 | if (perf_session__register_idle_thread(top->session) < 0) |
| 959 | goto out_delete; | 959 | goto out_delete; |
| 960 | 960 | ||
| 961 | perf_set_multithreaded(); | 961 | if (top->nr_threads_synthesize > 1) |
| 962 | perf_set_multithreaded(); | ||
| 962 | 963 | ||
| 963 | machine__synthesize_threads(&top->session->machines.host, &opts->target, | 964 | machine__synthesize_threads(&top->session->machines.host, &opts->target, |
| 964 | top->evlist->threads, false, | 965 | top->evlist->threads, false, |
| 965 | opts->proc_map_timeout, | 966 | opts->proc_map_timeout, |
| 966 | (unsigned int)sysconf(_SC_NPROCESSORS_ONLN)); | 967 | top->nr_threads_synthesize); |
| 967 | 968 | ||
| 968 | perf_set_singlethreaded(); | 969 | if (top->nr_threads_synthesize > 1) |
| 970 | perf_set_singlethreaded(); | ||
| 969 | 971 | ||
| 970 | if (perf_hpp_list.socket) { | 972 | if (perf_hpp_list.socket) { |
| 971 | ret = perf_env__read_cpu_topology_map(&perf_env); | 973 | ret = perf_env__read_cpu_topology_map(&perf_env); |
| @@ -1118,6 +1120,7 @@ int cmd_top(int argc, const char **argv) | |||
| 1118 | }, | 1120 | }, |
| 1119 | .max_stack = sysctl_perf_event_max_stack, | 1121 | .max_stack = sysctl_perf_event_max_stack, |
| 1120 | .sym_pcnt_filter = 5, | 1122 | .sym_pcnt_filter = 5, |
| 1123 | .nr_threads_synthesize = UINT_MAX, | ||
| 1121 | }; | 1124 | }; |
| 1122 | struct record_opts *opts = &top.record_opts; | 1125 | struct record_opts *opts = &top.record_opts; |
| 1123 | struct target *target = &opts->target; | 1126 | struct target *target = &opts->target; |
| @@ -1227,6 +1230,8 @@ int cmd_top(int argc, const char **argv) | |||
| 1227 | OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, | 1230 | OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, |
| 1228 | "Show entries in a hierarchy"), | 1231 | "Show entries in a hierarchy"), |
| 1229 | OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"), | 1232 | OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"), |
| 1233 | OPT_UINTEGER(0, "num-thread-synthesize", &top.nr_threads_synthesize, | ||
| 1234 | "number of thread to run event synthesize"), | ||
| 1230 | OPT_END() | 1235 | OPT_END() |
| 1231 | }; | 1236 | }; |
| 1232 | const char * const top_usage[] = { | 1237 | const char * const top_usage[] = { |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0e678dd6bdbe..47eff4767edb 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -790,7 +790,10 @@ int perf_event__synthesize_threads(struct perf_tool *tool, | |||
| 790 | if (n < 0) | 790 | if (n < 0) |
| 791 | return err; | 791 | return err; |
| 792 | 792 | ||
| 793 | thread_nr = nr_threads_synthesize; | 793 | if (nr_threads_synthesize == UINT_MAX) |
| 794 | thread_nr = sysconf(_SC_NPROCESSORS_ONLN); | ||
| 795 | else | ||
| 796 | thread_nr = nr_threads_synthesize; | ||
| 794 | 797 | ||
| 795 | if (thread_nr <= 1) { | 798 | if (thread_nr <= 1) { |
| 796 | err = __perf_event__synthesize_threads(tool, process, | 799 | err = __perf_event__synthesize_threads(tool, process, |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 9bdfb78a9a35..f4296e1e3bb8 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
| @@ -37,6 +37,7 @@ struct perf_top { | |||
| 37 | int sym_pcnt_filter; | 37 | int sym_pcnt_filter; |
| 38 | const char *sym_filter; | 38 | const char *sym_filter; |
| 39 | float min_percent; | 39 | float min_percent; |
| 40 | unsigned int nr_threads_synthesize; | ||
| 40 | }; | 41 | }; |
| 41 | 42 | ||
| 42 | #define CONSOLE_CLEAR "[H[2J" | 43 | #define CONSOLE_CLEAR "[H[2J" |
