public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung.kim@lge.com>
Subject: Re: [PATCH 0/8] perf: add ability to sample physical data addresses
Date: Mon, 8 Jul 2013 10:19:19 +0200	[thread overview]
Message-ID: <20130708081919.GV23916@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBSfkg+rPw4A=n8wmPg=iwn1Qf8PdYA4ycxxooOv3GrvmA@mail.gmail.com>

On Sat, Jul 06, 2013 at 12:48:48AM +0200, Stephane Eranian wrote:
> So, I tried on an example using shmat(). I map the same shared segment twice
> in the same process. Then I fork(): I see  this in /proc/PID/maps:
> 
> 7f80fce28000-7f80fce29000 rw-s 00000000 00:04 1376262
>   /SYSV00000000 (deleted)
> 7f80fce29000-7f80fce2a000 rw-s 00000000 00:04 1343491
>   /SYSV00000000 (deleted)
> 7f80fce2a000-7f80fce2b000 rw-s 00000000 00:04 1343491
>   /SYSV00000000 (deleted)
> 
> The segment at 1343491 is the one mapped twice. So that number (shmid)
> can be used to identify identical mappings. It appears the same way in both
> processes. The other 1376262 mapping is just to verify that each segment
> gets a different number.

Right, that's the inode number; I think you also need to add the
blockdev id (00:04) in this case as inode numbers are per device, not
global.

> So it looks possible to use this approach across process to identify identical
> physical mappings. However, this is not very practical.
> 
> The first reason is that perf_event does not capture shmat() mappings in MMAP
> records.

oops, that would be something we'd definitely need to fix.

ipc/shm.c:SYSCALL_DEFINE3(shmat)
  do_shmat()
    do_mmap_pgoff()
      mmap_region()
        perf_event_mmap()

So why isn't it logging them? If its a non-exec map we need
attr::mmap_data but I suppose you have that enabled?

> The second is is that if you rely on /proc/PID/maps, you will have to
> have the tool
> constantly poll that file for new shared mappings. This is not how
> perf works today,
> not even in system-wide mode. /proc/PID/maps is swept only once when perf
> record -a is started.

Ahh. We don't put the useful bits in the mmap event; we'll need to fix
that too then ;-)

Doing so is going to be a bit of a bother since we use the tail of
PERF_RECORD_MMAP for filenames and thus aren't particularly extensible.

This would mean doing something like PERF_RECORD_MMAP2 and some means
for userspace to requrest the new events instead of the old one.

Didn't you already have patches to change the event layout? Can this
piggy back on that?

> Ingo is proposing a ioctl() to flush the mappings. But then, when is a
> good time to do this
> from the tool?

Yeah, that's not going to help with this; that's only to get rid of the
initial /proc/$pid/maps reading. Not to keep up with changes.

> So my approach with PERF_SAMPLE_PHYS_ADDR looks easier on the tools which
> if I recall is the philosophy behind perf_events.

Physical addresses are always going to cause problems, don't ever use
them.



  reply	other threads:[~2013-07-08  8:19 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 14:20 [PATCH 0/8] perf: add ability to sample physical data addresses Stephane Eranian
2013-06-21 14:20 ` [PATCH 1/8] perf,x86: disable PEBS-LL in intel_pmu_pebs_disable() Stephane Eranian
2013-06-24  8:44   ` Peter Zijlstra
2013-06-26  7:35     ` Stephane Eranian
2013-06-27  9:01   ` [tip:perf/core] perf/x86: Disable " tip-bot for Stephane Eranian
2013-06-21 14:20 ` [PATCH 2/8] perf,x86: drop event->flags and use hw.constraint->flags Stephane Eranian
2013-06-24  8:45   ` Peter Zijlstra
2013-06-26  7:36     ` Stephane Eranian
2013-06-26 10:36       ` Peter Zijlstra
2013-06-27 10:23         ` Stephane Eranian
2013-06-27 10:48           ` Peter Zijlstra
2013-06-27 11:01             ` Stephane Eranian
2013-06-27 11:14               ` Peter Zijlstra
2013-06-27 12:33                 ` Stephane Eranian
2013-06-27 14:10                   ` Peter Zijlstra
2013-06-21 14:20 ` [PATCH 3/8] perf,x86: add uvirt_to_phys_nmi helper function Stephane Eranian
2013-06-21 14:20 ` [PATCH 4/8] perf: add PERF_SAMPLE_PHYS_ADDR sample type Stephane Eranian
2013-06-21 14:20 ` [PATCH 5/8] perf,x86: add support for PERF_SAMPLE_PHYS_ADDR for PEBS-LL Stephane Eranian
2013-06-21 14:20 ` [PATCH 6/8] perf tools: add infrastructure to handle PERF_SAMPLE_PHYS_ADDR Stephane Eranian
2013-06-21 14:20 ` [PATCH 7/8] perf record: add option to sample physical load/store addresses Stephane Eranian
2013-06-21 14:20 ` [PATCH 8/8] perf mem: add physical addr sampling support Stephane Eranian
2013-06-23 21:58 ` [PATCH 0/8] perf: add ability to sample physical data addresses Jiri Olsa
2013-06-24  8:16   ` Stephane Eranian
2013-06-24  8:45     ` Jiri Olsa
2013-06-24  8:43 ` Peter Zijlstra
2013-06-25  9:59   ` Stephane Eranian
2013-06-25 10:47     ` Peter Zijlstra
2013-06-25 10:51       ` Ingo Molnar
2013-06-26 10:33         ` Peter Zijlstra
2013-06-26 19:10           ` Stephane Eranian
2013-06-28  9:58             ` Peter Zijlstra
2013-07-05 22:48               ` Stephane Eranian
2013-07-08  8:19                 ` Peter Zijlstra [this message]
2013-07-09  6:02                   ` Stephane Eranian
2013-07-30  8:02                   ` Stephane Eranian
2013-07-30  8:37                     ` Peter Zijlstra
2013-07-30  8:51                       ` Stephane Eranian
2013-07-30  9:02                         ` Peter Zijlstra
2013-07-30 13:09                           ` Stephane Eranian
2013-07-30 14:21                             ` Stephane Eranian
2013-07-30 14:50                               ` David Ahern
2013-07-30 14:53                                 ` Stephane Eranian
2013-07-30 14:59                                   ` David Ahern
2013-07-30 15:52                               ` Peter Zijlstra
2013-07-30 16:09                                 ` Stephane Eranian
2013-07-30 16:16                                   ` Peter Zijlstra
2013-06-26 13:29       ` 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=20130708081919.GV23916@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    /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