linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: acme@redhat.com, jolsa@redhat.com, peterz@infradead.org,
	mingo@elte.hu, namhyung@kernel.org, dsahern@gmail.com
Subject: [PATCH] perf tools: fix processing of pid/tid for mmap records
Date: Mon, 21 Apr 2014 18:06:55 +0200	[thread overview]
Message-ID: <20140421160655.GA4201@quad> (raw)

perf tools: fix processing of pid/tid for mmap records
    
Mmaps are global to a process (always). Processing them
per-thread was causing some serious issues in case mmaps
would overlap. The overlap fixups would only occur in the
context of the thread which generated the overlapping
mmap. But that was cause issues later on when a sample
from another thread would fall into that overlapping
mmap.

The solution to the problem is to handle ALL mmaps as
occurring in the master thread (pid = tid) and then to
lookup for thread map using pid as the tid argument.
This is how samples are looking up for the thread map
already (notice pid passed twice):
    
int perf_event__preprocess_sample(const union perf_event *event,
                                  struct machine *machine,
                                  struct addr_location *al,
                                  struct perf_sample *sample)
{
        struct thread *thread = machine__findnew_thread(machine, sample->pid,
                                                        sample->pid);
}
    
Without this fix, some samples in overlapping regions
may not be symbolized.
    
Signed-off-by: Stephane Eranian <eranian@google.com>

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a53cd0b..43cdc0a 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1025,9 +1025,9 @@ int machine__process_mmap2_event(struct machine *machine,
 			goto out_problem;
 		return 0;
 	}
-
+	/* only look by pid for mmap events */
 	thread = machine__findnew_thread(machine, event->mmap2.pid,
-					event->mmap2.tid);
+					event->mmap2.pid);
 	if (thread == NULL)
 		goto out_problem;
 
@@ -1073,9 +1073,9 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
 			goto out_problem;
 		return 0;
 	}
-
+	/* only look by pid for mmap events */
 	thread = machine__findnew_thread(machine, event->mmap.pid,
-					 event->mmap.tid);
+					 event->mmap.pid);
 	if (thread == NULL)
 		goto out_problem;
 

             reply	other threads:[~2014-04-21 16:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 16:06 Stephane Eranian [this message]
2014-04-22 13:32 ` [PATCH] perf tools: fix processing of pid/tid for mmap records Jiri Olsa
2014-04-22 13:37   ` Stephane Eranian
2014-04-22 19:40 ` Don Zickus
2014-04-22 19:50   ` Stephane Eranian
2014-04-22 20:45     ` Don Zickus
2014-04-23 12:52       ` Stephane Eranian
2014-04-23 13:30         ` Don Zickus
2014-04-23 15:06           ` Stephane Eranian
2014-04-23 15:42             ` Jiri Olsa

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=20140421160655.GA4201@quad \
    --to=eranian@google.com \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@kernel.org \
    --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).