lkml.org 
[lkml]   [2018]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 44/48] perf record: Add --threads option
On Thu, Sep 13, 2018 at 02:54:46PM +0200, Jiri Olsa wrote:
> 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 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;

Ah, ok. You made it incompatible with the overwrite mode..

Thanks,
Namhyung


> + }
> + 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
>

\
 
 \ /
  Last update: 2018-09-17 13:37    [W:0.974 / U:1.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site