lkml.org 
[lkml]   [2018]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 45/49] perf record: Add --threads option
Date
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@kernel.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
\
 
 \ /
  Last update: 2018-01-14 23:19    [W:0.201 / U:0.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site