From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Chang Hyun Park <heartinpiece@gmail.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 2/8] perf trace: Fix mmap return address truncation to 32-bit
Date: Wed, 1 Oct 2014 16:50:37 -0300 [thread overview]
Message-ID: <1412193043-15493-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1412193043-15493-1-git-send-email-acme@kernel.org>
From: Chang Hyun Park <heartinpiece@gmail.com>
Using 'perf trace' for mmap is truncating return values by stripping the
top 32 bits, actually printing only the lower 32 bits.
This was because the ret value was of an 'int' type and not a 'long'
type.
The Problem:
991258501.244 ( 0.004 ms): mmap(len: 40001536, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1) = 0x56691000
991258501.257 ( 0.000 ms): minfault [_int_malloc+0x1038] => //anon@0x7fa056691008 //(d.)
The first line shows an mmap, which succeeds and returns 0x56691000.
However the next line shows a memory access to that virtual memory area,
specifically to 0x7fa056691008. The upper 32 bit is lost due to the
problem mentioned above, and thus mmap's return value didn't have the
upper 0x7fa0.
Tested on 3.17-rc5 from the linus's tree, and the HEAD of tip/master
Signed-off-by: Chang Hyun Park <heartinpiece@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1411736041-8017-1-git-send-email-heartinpiece@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-trace.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index c70e69ea1c5d..09bcf2393910 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1695,7 +1695,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
union perf_event *event __maybe_unused,
struct perf_sample *sample)
{
- int ret;
+ long ret;
u64 duration = 0;
struct thread *thread;
int id = perf_evsel__sc_tp_uint(evsel, id, sample);
@@ -1748,7 +1748,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
if (sc->fmt == NULL) {
signed_print:
- fprintf(trace->output, ") = %d", ret);
+ fprintf(trace->output, ") = %ld", ret);
} else if (ret < 0 && sc->fmt->errmsg) {
char bf[STRERR_BUFSIZE];
const char *emsg = strerror_r(-ret, bf, sizeof(bf)),
@@ -1758,7 +1758,7 @@ signed_print:
} else if (ret == 0 && sc->fmt->timeout)
fprintf(trace->output, ") = 0 Timeout");
else if (sc->fmt->hexret)
- fprintf(trace->output, ") = %#x", ret);
+ fprintf(trace->output, ") = %#lx", ret);
else
goto signed_print;
--
1.9.3
next prev parent reply other threads:[~2014-10-01 19:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 19:50 [GIT PULL 0/8] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 1/8] perf tools: Refactor unit and scale function parameters Arnaldo Carvalho de Melo
2014-10-01 19:50 ` Arnaldo Carvalho de Melo [this message]
2014-10-01 19:50 ` [PATCH 3/8] perf bench futex: Support operations for shared futexes Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 4/8] perf bench futex: Sanitize -q option in requeue Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 5/8] perf symbols: Encapsulate dsos list head into struct dsos Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 6/8] perf symbols: Improve DSO long names lookup speed with rbtree Arnaldo Carvalho de Melo
2014-10-14 9:09 ` Jiri Olsa
2014-10-14 17:34 ` Arnaldo Carvalho de Melo
2014-10-14 18:03 ` Arnaldo Carvalho de Melo
2014-10-15 10:05 ` [tip:perf/urgent] perf machine: Add missing dsos-> root rbtree root initialization tip-bot for Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 7/8] perf tools: Fix build breakage on arm64 targets Arnaldo Carvalho de Melo
2014-10-01 19:50 ` [PATCH 8/8] perf record: Fix error message for --filter option not coming after tracepoint Arnaldo Carvalho de Melo
2014-10-03 3:31 ` [GIT PULL 0/8] perf/core improvements and fixes Ingo Molnar
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=1412193043-15493-3-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=heartinpiece@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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).