From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Dave Martin <dave.martin@linaro.org>
Cc: linux-kernel@vger.kernel.org,
Nicolas Pitre <nicolas.pitre@linaro.org>,
kernel-team@lists.ubuntu.com, Will Deacon <Will.Deacon@arm.com>,
Linaro Dev <linaro-dev@lists.linaro.org>,
Anton Blanchard <anton@samba.org>
Subject: Re: [PATCH 1/2] perf events: Fix mmap offset determination
Date: Tue, 3 Aug 2010 11:31:15 -0300 [thread overview]
Message-ID: <20100803143115.GW29507@ghostprotocols.net> (raw)
In-Reply-To: <1280836116-6654-2-git-send-email-dave.martin@linaro.org>
Em Tue, Aug 03, 2010 at 12:48:35PM +0100, Dave Martin escreveu:
> Fix buggy-looking code which unnecessarily adjusts the file offset
> fields read from /proc/*/maps.
>
> This may have gone unnoticed since the offset is usually 0 (and the
> logic in util/symbol.c may work incorrectly for other offset values).
>
> I make assumptions about the intended design here. The cover note
> accompanying this patch contains a more detailed explanation.
>
> Signed-off-by: Dave Martin <dave.martin@linaro.org>
Doing some investigation here...
4af8b35d (Anton Blanchard 2010-04-03 164) pbf += 3;
4af8b35d (Anton Blanchard 2010-04-03 165) n = hex2u64(pbf, &vm_pgoff);
4af8b35d (Anton Blanchard 2010-04-03 166) /* pgoff is in bytes, not pages */
4af8b35d (Anton Blanchard 2010-04-03 167) if (n >= 0)
4af8b35d (Anton Blanchard 2010-04-03 168) ev.mmap.pgoff = vm_pgoff << getpagesize();
4af8b35d (Anton Blanchard 2010-04-03 169) else
4af8b35d (Anton Blanchard 2010-04-03 170) ev.mmap.pgoff = 0;
commit 4af8b35db6634dd1e0d616de689582b6c93550af
Author: Anton Blanchard <anton@samba.org>
Date: Sat Apr 3 22:53:31 2010 +1100
perf symbols: Fill in pgoff in mmap synthesized events
When we synthesize mmap events we need to fill in the pgoff field.
I wasn't able to test this completely since I couldn't find an
executable region with a non 0 offset. We will see it when we start
doing data profiling.
------------------------
Yeah, not reassuring comment, looking at fs/proc/task_mmu.c we see:
static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma)
{
struct mm_struct *mm = vma->vm_mm;
struct file *file = vma->vm_file;
int flags = vma->vm_flags;
unsigned long ino = 0;
unsigned long long pgoff = 0;
dev_t dev = 0;
int len;
if (file) {
struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
dev = inode->i_sb->s_dev;
ino = inode->i_ino;
pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
}
seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
vma->vm_start,
vma->vm_end,
flags & VM_READ ? 'r' : '-',
flags & VM_WRITE ? 'w' : '-',
flags & VM_EXEC ? 'x' : '-',
flags & VM_MAYSHARE ? 's' : 'p',
pgoff,
MAJOR(dev), MINOR(dev), ino, &len);
----------------------------------------------------------------------------
So yes, we're double shifting that, your patch is correct, applying it.
> ---
> tools/perf/util/event.c | 8 +-------
> 1 files changed, 1 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 6b0db55..db8a1d4 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -151,7 +151,6 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
> continue;
> pbf += n + 3;
> if (*pbf == 'x') { /* vm_exec */
> - u64 vm_pgoff;
> char *execname = strchr(bf, '/');
>
> /* Catch VDSO */
> @@ -162,12 +161,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
> continue;
>
> pbf += 3;
> - n = hex2u64(pbf, &vm_pgoff);
> - /* pgoff is in bytes, not pages */
> - if (n >= 0)
> - ev.mmap.pgoff = vm_pgoff << getpagesize();
> - else
> - ev.mmap.pgoff = 0;
> + n = hex2u64(pbf, &ev.mmap.pgoff);
>
> size = strlen(execname);
> execname[size - 1] = '\0'; /* Remove \n */
> --
> 1.7.0.4
next prev parent reply other threads:[~2010-08-03 14:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-03 11:48 [PATCH 0/2] perf: symbol offset breakage with separated debug Dave Martin
2010-08-03 11:48 ` [PATCH 1/2] perf events: Fix mmap offset determination Dave Martin
2010-08-03 14:31 ` Arnaldo Carvalho de Melo [this message]
2010-08-05 8:00 ` [tip:perf/core] " tip-bot for Dave Martin
2010-08-03 11:48 ` [PATCH 2/2] perf symbols: work around incorrect ET_EXEC symbol adjustment Dave Martin
2010-08-12 13:19 ` [PATCH v2] perf symbols: fix symbol offset breakage with separated debug Dave Martin
2010-08-13 9:27 ` [PATCH v3] " Dave Martin
2010-08-03 13:54 ` [PATCH 0/2] perf: " Arnaldo Carvalho de Melo
2010-08-04 8:29 ` Dave Martin
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=20100803143115.GW29507@ghostprotocols.net \
--to=acme@redhat.com \
--cc=Will.Deacon@arm.com \
--cc=anton@samba.org \
--cc=dave.martin@linaro.org \
--cc=kernel-team@lists.ubuntu.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.pitre@linaro.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