From: Alexey Bayduraev <alexey.bayduraev@gmail.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Riccardo Mancini <rickyman7@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/3] perf record: Fix per-thread option.
Date: Wed, 13 Apr 2022 04:42:07 +0300 [thread overview]
Message-ID: <e1ce0d93-88cc-af79-e67e-d3c79d166ca6@gmail.com> (raw)
In-Reply-To: <20220412062133.2546080-1-irogers@google.com>
On 12.04.2022 09:21, Ian Rogers wrote:
> From: Alexey Bayduraev <alexey.bayduraev@gmail.com>
Thanks,
The tag
Signed-off-by: Alexey Bayduraev <alexey.bayduraev@gmail.com>
can be added to this patch.
Regards,
Alexey
>
> Per-thread mode doesn't have specific CPUs for events, add checks for
> this case.
>
> Minor fix to a pr_debug by Ian Rogers <irogers@google.com> to avoid an
> out of bound array access.
>
> Reported-by: Ian Rogers <irogers@google.com>
> Fixes: 7954f71689f9 ("perf record: Introduce thread affinity and mmap masks")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/builtin-record.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index ba74fab02e62..069825c48d40 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -989,8 +989,11 @@ static int record__thread_data_init_maps(struct record_thread *thread_data, stru
> struct mmap *overwrite_mmap = evlist->overwrite_mmap;
> struct perf_cpu_map *cpus = evlist->core.user_requested_cpus;
>
> - thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits,
> - thread_data->mask->maps.nbits);
> + if (cpu_map__is_dummy(cpus))
> + thread_data->nr_mmaps = nr_mmaps;
> + else
> + thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits,
> + thread_data->mask->maps.nbits);
> if (mmap) {
> thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *));
> if (!thread_data->maps)
> @@ -1007,16 +1010,17 @@ static int record__thread_data_init_maps(struct record_thread *thread_data, stru
> thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps);
>
> for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) {
> - if (test_bit(cpus->map[m].cpu, thread_data->mask->maps.bits)) {
> + if (cpu_map__is_dummy(cpus) ||
> + test_bit(cpus->map[m].cpu, thread_data->mask->maps.bits)) {
> if (thread_data->maps) {
> thread_data->maps[tm] = &mmap[m];
> pr_debug2("thread_data[%p]: cpu%d: maps[%d] -> mmap[%d]\n",
> - thread_data, cpus->map[m].cpu, tm, m);
> + thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m);
> }
> if (thread_data->overwrite_maps) {
> thread_data->overwrite_maps[tm] = &overwrite_mmap[m];
> pr_debug2("thread_data[%p]: cpu%d: ow_maps[%d] -> ow_mmap[%d]\n",
> - thread_data, cpus->map[m].cpu, tm, m);
> + thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m);
> }
> tm++;
> }
> @@ -3329,6 +3333,9 @@ static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_c
> {
> int c;
>
> + if (cpu_map__is_dummy(cpus))
> + return;
> +
> for (c = 0; c < cpus->nr; c++)
> set_bit(cpus->map[c].cpu, mask->bits);
> }
> @@ -3680,6 +3687,11 @@ static int record__init_thread_masks(struct record *rec)
> if (!record__threads_enabled(rec))
> return record__init_thread_default_masks(rec, cpus);
>
> + if (cpu_map__is_dummy(cpus)) {
> + pr_err("--per-thread option is mutually exclusive to parallel streaming mode.\n");
> + return -EINVAL;
> + }
> +
> switch (rec->opts.threads_spec) {
> case THREAD_SPEC__CPU:
> ret = record__init_thread_cpu_masks(rec, cpus);
>
next prev parent reply other threads:[~2022-04-13 1:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 6:21 [PATCH 1/3] perf record: Fix per-thread option Ian Rogers
2022-04-12 6:21 ` [PATCH 2/3] perf cpumap: Switch to using perf_cpu_map API Ian Rogers
2022-04-12 6:21 ` [PATCH 3/3] perf test: Add basic perf record tests Ian Rogers
2022-04-13 20:13 ` Namhyung Kim
2022-04-13 1:42 ` Alexey Bayduraev [this message]
2022-04-14 1:31 ` [PATCH 1/3] perf record: Fix per-thread option Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1ce0d93-88cc-af79-e67e-d3c79d166ca6@gmail.com \
--to=alexey.bayduraev@gmail.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexey.v.bayduraev@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).