[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180109153522.14116-46-jolsa@kernel.org>
Date: Tue, 9 Jan 2018 16:35:18 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 45/49] perf record: Add --threads option
Allows to assign number to record::threads_cnt and thus
to create multiple threads. At this point we don't allow
to specify number of threads, instead we assign it number
of evlist's mmaps to have a single thread for each.
Link: http://lkml.kernel.org/n/tip-ijl786fsk46q6g01is378a5t@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/builtin-record.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 22307796f84d..ba72aed6a411 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -102,6 +102,7 @@ struct record {
unsigned long long samples;
struct record_thread *threads;
int threads_cnt;
+ bool threads_set;
int threads_signal_cnt;
pthread_mutex_t threads_signal_mutex;
pthread_cond_t threads_signal_cond;
@@ -1102,11 +1103,38 @@ record__threads_create(struct record *rec)
return threads ? 0 : -ENOMEM;
}
+static int record__threads_cnt(struct record *rec)
+{
+ struct perf_evlist *evlist = rec->evlist;
+ int cnt;
+
+ if (rec->threads_set) {
+ if (rec->threads_cnt) {
+ pr_err("failed: Can't specify number of threads yet.\n");
+ return -EINVAL;
+ }
+ if (evlist->overwrite_mmap) {
+ pr_err("failed: Can't use multiple threads with overwrite mmaps yet.\n");
+ return -EINVAL;
+ }
+ cnt = evlist->nr_mmaps;
+ } else {
+ cnt = 1;
+ }
+
+ rec->threads_cnt = cnt;
+ return 0;
+}
+
static int
record__threads_config(struct record *rec)
{
int ret;
+ ret = record__threads_cnt(rec);
+ if (ret)
+ goto out;
+
ret = record__threads_create(rec);
if (ret)
goto out;
@@ -2067,6 +2095,8 @@ static struct option __record_options[] = {
"Parse options then exit"),
OPT_BOOLEAN(0, "index", &record.opts.index,
"make index for sample data to speed-up processing"),
+ OPT_INTEGER_OPTARG_SET(0, "threads", &record.threads_cnt, &record.threads_set,
+ "count", "Enabled threads (count)", 0),
OPT_END()
};
@@ -2224,6 +2254,12 @@ int cmd_record(int argc, const char **argv)
goto out;
}
+ /*
+ * Threads need index data file.
+ */
+ if (record.threads_set)
+ record.opts.index = true;
+
if (rec->opts.index) {
if (!rec->opts.sample_time) {
pr_err("Sample timestamp is required for indexing\n");
--
2.13.6
Powered by blists - more mailing lists