Re: [PATCH 1/2] perf events: Fix mmap offset determination

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Arnaldo Carvalho de Melo
Date: Tuesday, August 3, 2010 - 7:31 am

Em Tue, Aug 03, 2010 at 12:48:35PM +0100, Dave Martin escreveu:

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.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/2] perf events: Fix mmap offset determination, Arnaldo Carvalho de Melo, (Tue Aug 3, 7:31 am)
[tip:perf/core] perf events: Fix mmap offset determination, tip-bot for Dave Martin, (Thu Aug 5, 1:00 am)