From: Namhyung Kim <namhyung@kernel.org>
To: Robert Richter <rric@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Borislav Petkov <bp@alien8.de>, Jiri Olsa <jolsa@redhat.com>,
linux-kernel@vger.kernel.org,
Robert Richter <robert.richter@calxeda.com>
Subject: Re: [PATCH 4/4] perf tools: Retry mapping buffers readonly on EACCES
Date: Fri, 14 Jun 2013 11:08:40 +0900 [thread overview]
Message-ID: <87ip1h30lz.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1369991785-10499-5-git-send-email-rric@kernel.org> (Robert Richter's message of "Fri, 31 May 2013 11:16:25 +0200")
Hi Robert,
On Fri, 31 May 2013 11:16:25 +0200, Robert Richter wrote:
> From: Robert Richter <robert.richter@calxeda.com>
>
> Persistent event buffers may only be mmapped readonly. Thus, retry
> mapping it readonly if mmap returns EACCES after trying to mmap
> writable.
>
> Signed-off-by: Robert Richter <robert.richter@calxeda.com>
> ---
> tools/perf/builtin-record.c | 7 ++++++-
> tools/perf/builtin-top.c | 8 ++++++--
> tools/perf/perf.h | 1 +
> 3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index cdf58ec..916776d 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -255,7 +255,12 @@ try_again:
> goto out;
> }
>
> - if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
> +try_again2:
> + if (perf_evlist__mmap(evlist, opts->mmap_pages, opts->mmap_ro) < 0) {
> + if (!opts->mmap_ro && errno == EACCES) {
> + opts->mmap_ro = true;
> + goto try_again2;
> + }
> if (errno == EPERM) {
> pr_err("Permission error mapping pages.\n"
> "Consider increasing "
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 67bdb9f..2a5757d 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -899,8 +899,12 @@ try_again:
> goto out_err;
> }
> }
> -
> - if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) {
> +try_again2:
> + if (perf_evlist__mmap(evlist, opts->mmap_pages, opts->mmap_ro) < 0) {
> + if (!opts->mmap_ro && errno == EACCES) {
> + opts->mmap_ro = true;
> + goto try_again2;
> + }
> ui__error("Failed to mmap with %d (%s)\n",
> errno, strerror(errno));
> goto out_err;
You will need this also:
@@ -161,7 +161,8 @@ static int perf_record__mmap_read(struct perf_record *rec,
}
md->prev = old;
- perf_mmap__write_tail(md, old);
+ if (!rec->opts.mmap_ro)
+ perf_mmap__write_tail(md, old);
out:
return rc;
--
Thanks,
Namhyung
next prev parent reply other threads:[~2013-06-14 2:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 9:16 [PATCH 0/4] perf tools: Persistent events, changes for perf tool integration Robert Richter
2013-05-31 9:16 ` [PATCH 1/4] perf tools: Rename flex conditions to avoid name conflicts Robert Richter
2013-05-31 9:16 ` [PATCH 2/4] perf tools: Modify event parser to update event attribute by index Robert Richter
2013-05-31 9:16 ` [PATCH 3/4] perf tools: Add attr<num> syntax to event parser Robert Richter
2013-06-03 13:54 ` Jiri Olsa
2013-06-07 14:17 ` Robert Richter
2013-05-31 9:16 ` [PATCH 4/4] perf tools: Retry mapping buffers readonly on EACCES Robert Richter
2013-06-14 2:08 ` Namhyung Kim [this message]
2013-06-14 7:29 ` Robert Richter
2013-05-31 12:07 ` [PATCH 0/4] perf tools: Persistent events, changes for perf tool integration Ingo Molnar
2013-05-31 12:24 ` Borislav Petkov
2013-05-31 12:48 ` Ingo Molnar
2013-05-31 13:44 ` Robert Richter
2013-05-31 15:31 ` Borislav Petkov
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=87ip1h30lz.fsf@sejong.aot.lge.com \
--to=namhyung@kernel.org \
--cc=acme@ghostprotocols.net \
--cc=bp@alien8.de \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=robert.richter@calxeda.com \
--cc=rric@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome