From: Don Zickus <dzickus@redhat.com>
To: peterz@infradead.org
Cc: eranian@google.com, jmario@redhat.com, jolsa@redhat.com,
acme@redhat.com, linux-kernel@vger.kernel.org,
lwoodman@redhat.com
Subject: perf MMAP2 interface and COW faults
Date: Thu, 13 Mar 2014 16:03:52 -0400 [thread overview]
Message-ID: <20140313200352.GU25953@redhat.com> (raw)
Hi Peter,
So we found another corner case with MMAP2 interface. I don't think it is
a big hurdle to overcome, just wanted a suggestion.
Joe ran specjbb2013 (which creates about 10,000 java threads across 9
processes) and our c2c tool turned up some cacheline collision data on
libjvm.so. This didn't make sense because you shouldn't be able to write
to a shared library.
Even worse, our tool said it affected all the java process and a majority
of the threads. Which again didn't make sense because this shared library
should be local to each pid's memory.
Anyway, what we determined is that the shared library had mmap data that
was non-zero (because it was backed by a file, libjvm.so). So the
assumption was if the major, minor, inode and inode generation numbers
were non-zero, this memory segment was shared across processes.
So perf setup its map files for the mmap area and then started sampling data
addresses. A few hundred HITMs were to a virtual address that fell into
the libjvm.so memory segment (which was assumed to be mmap'd across
processes).
Coalescing all the data suggested that multiple pids/tids were contending
for a cacheline in a shared library.
After talking with Larry Woodman, we realized when you write to a 'data' or
'bss' segment of a shared library, you incur a COW fault that maps to an
anonymous page in the pid's memory. However, perf doesn't see this.
So when all the tids start writing to this 'data' or 'bss' segment they
generate HITMs within their pid (which is fine). However the tool thinks
it affects other pids (which is not fine).
My question is, how can our tool determine if a virtual address is private
to a pid or not? Originally it had to have a zero for maj, min, ino, and
ino gen. But for file map'd libraries this doesn't always work because we
don't see COW faults in perf (and we may not want too :-) ).
Is there another technique we can use? Perhaps during the reading of
/proc/<pid>/maps, if the protection is marked 'p' for private, we just tell
the sort algorithm to sort locally to the process but a 's' for shared can
be sorted globally based on data addresses?
Or something else that tells us that a virtual address has changed its
mapping? Thoughts?
Cheers,
Don
next reply other threads:[~2014-03-13 20:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 20:03 Don Zickus [this message]
2014-03-14 11:17 ` perf MMAP2 interface and COW faults Peter Zijlstra
2014-03-14 12:58 ` Don Zickus
2014-03-14 13:24 ` Peter Zijlstra
2014-03-14 13:37 ` Don Zickus
2014-03-17 15:37 ` Don Zickus
2014-03-17 15:41 ` Don Zickus
2014-03-17 16:16 ` Peter Zijlstra
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=20140313200352.GU25953@redhat.com \
--to=dzickus@redhat.com \
--cc=acme@redhat.com \
--cc=eranian@google.com \
--cc=jmario@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lwoodman@redhat.com \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).