[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180913125450.21342-45-jolsa@kernel.org>
Date: Thu, 13 Sep 2018 14:54:46 +0200
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>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Andi Kleen <andi@...stfloor.org>,
Alexey Budankov <alexey.budankov@...ux.intel.com>
Subject: [PATCH 44/48] 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 fbca1d15b90d..ada6f795d492 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;
@@ -1133,11 +1134,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;
@@ -2119,6 +2147,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()
};
@@ -2267,6 +2297,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.17.1
Powered by blists - more mailing lists