From: Kan Liang <kan.li...@intel.com> Using UINT_MAX to indicate the default thread#, which is the number of online CPU.
Signed-off-by: Kan Liang <kan.li...@intel.com> --- tools/perf/Documentation/perf-record.txt | 4 ++++ tools/perf/builtin-record.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 68a1ffb..f759dc4 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -483,6 +483,10 @@ config terms. For example: 'cycles/overwrite/' and 'instructions/no-overwrite/'. Implies --tail-synthesize. +--num-thread-synthesize:: +The number of threads to run event synthesize. +By default, the number of threads equals to the online CPU number. + SEE ALSO -------- linkperf:perf-stat[1], linkperf:perf-list[1] diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index bbe8009..0b7873a 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -84,6 +84,7 @@ struct record { struct switch_output switch_output; unsigned long long samples; struct perf_data_file *synthesized_file; + unsigned int nr_threads_synthesize; }; static volatile int auxtrace_record__snapshot_started; @@ -709,10 +710,15 @@ static int record__multithread_synthesize(struct record *rec, struct perf_tool *tool, struct record_opts *opts) { - int i, err, nr_thread = sysconf(_SC_NPROCESSORS_ONLN); + int i, err, nr_thread; char name[PATH_MAX]; struct stat st; + if (rec->nr_threads_synthesize == UINT_MAX) + nr_thread = sysconf(_SC_NPROCESSORS_ONLN); + else + nr_thread = rec->nr_threads_synthesize; + if (nr_thread <= 1) return __machine__synthesize_threads(machine, tool, &opts->target, @@ -857,7 +863,7 @@ static int record__synthesize(struct record *rec, bool tail) } /* multithreading synthesize is only available for cpu monitoring */ - if (target__has_cpu(&opts->target)) + if (target__has_cpu(&opts->target) && (rec->nr_threads_synthesize > 1)) err = record__multithread_synthesize(rec, machine, tool, opts); else err = __machine__synthesize_threads(machine, tool, @@ -1542,6 +1548,7 @@ static struct record record = { .mmap2 = perf_event__process_mmap2, .ordered_events = true, }, + .nr_threads_synthesize = UINT_MAX, }; const char record_callchain_help[] = CALLCHAIN_RECORD_HELP @@ -1683,6 +1690,8 @@ static struct option __record_options[] = { "signal"), OPT_BOOLEAN(0, "dry-run", &dry_run, "Parse options then exit"), + OPT_UINTEGER(0, "num-thread-synthesize", &record.nr_threads_synthesize, + "number of thread to run event synthesize"), OPT_END() }; -- 2.7.4