From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Andi Kleen <ak@linux.intel.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] perf record: fix binding of AIO user space buffers to nodes
Date: Thu, 12 Mar 2020 11:31:52 -0300 [thread overview]
Message-ID: <20200312143152.GA28601@kernel.org> (raw)
In-Reply-To: <c7ea8ffe-1357-bf9e-3a89-1da1d8e9b75b@linux.intel.com>
Em Thu, Mar 12, 2020 at 03:21:45PM +0300, Alexey Budankov escreveu:
>
> Correct maxnode parameter value passed to mbind() syscall to be
> the amount of node mask bits to analyze plus 1. Dynamically allocate
> node mask memory depending on the index of node of cpu being profiled.
> Fixes: c44a8b44ca9f ("perf record: Bind the AIO user space buffers to nodes")
> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
> ---
> tools/perf/util/mmap.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c
> index 3b664fa673a6..6d604cd67a95 100644
> --- a/tools/perf/util/mmap.c
> +++ b/tools/perf/util/mmap.c
> @@ -98,20 +98,29 @@ static int perf_mmap__aio_bind(struct mmap *map, int idx, int cpu, int affinity)
> {
> void *data;
> size_t mmap_len;
> - unsigned long node_mask;
> + unsigned long *node_mask;
> + unsigned long node_index;
> + int err = 0;
>
> if (affinity != PERF_AFFINITY_SYS && cpu__max_node() > 1) {
> data = map->aio.data[idx];
> mmap_len = mmap__mmap_len(map);
> - node_mask = 1UL << cpu__get_node(cpu);
> - if (mbind(data, mmap_len, MPOL_BIND, &node_mask, 1, 0)) {
> - pr_err("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n",
> - data, data + mmap_len, cpu__get_node(cpu));
> + node_index = cpu__get_node(cpu);
> + node_mask = bitmap_alloc(node_index + 1);
> + if (!node_mask) {
> + pr_err("Failed to allocate node mask for mbind: error %m\n");
> return -1;
> }
> + set_bit(node_index, node_mask);
> + if (mbind(data, mmap_len, MPOL_BIND, node_mask, node_index + 1 + 1/*nr_bits + 1*/, 0)) {
^^^^^^^^^^^^^^
Leftover?
> + pr_err("Failed to bind [%p-%p] AIO buffer to node %lu: error %m\n",
> + data, data + mmap_len, node_index);
> + err = -1;
> + }
> + bitmap_free(node_mask);
> }
>
> - return 0;
> + return err;
> }
> #else /* !HAVE_LIBNUMA_SUPPORT */
> static int perf_mmap__aio_alloc(struct mmap *map, int idx)
> --
> 2.24.1
>
--
- Arnaldo
next prev parent reply other threads:[~2020-03-12 14:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 12:21 [PATCH v1] perf record: fix binding of AIO user space buffers to nodes Alexey Budankov
2020-03-12 14:31 ` Arnaldo Carvalho de Melo [this message]
2020-03-12 16:09 ` Alexey Budankov
2020-03-12 17:12 ` Arnaldo Carvalho de Melo
2020-03-12 17:54 ` Alexey Budankov
2020-03-19 14:10 ` [tip: perf/core] perf record: Fix " tip-bot2 for Alexey Budankov
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=20200312143152.GA28601@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexey.budankov@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.