All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tools: Fix ppid for non-main thread
@ 2015-04-09 16:48 David Ahern
  2015-04-09 17:05 ` Don Zickus
  2015-04-11  6:36 ` [tip:perf/core] perf tools: Fix synthesizing fork_event.ppid " tip-bot for David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: David Ahern @ 2015-04-09 16:48 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, David Ahern, Don Zickus

Commit ca6c41c59b9 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events. This is correct
thing to do for new processes but not threads of a process. Fix
ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).

Reported-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: David Ahern <david.ahern@oracle.com>
Cc: Don Zickus <dzickus@redhat.com>
---
 tools/perf/util/event.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 186929a..ff866c4 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
 {
 	memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
 
-	event->fork.ppid = ppid;
-	event->fork.ptid = ppid;
+	/*
+	 * for main thread set parent to ppid from status file. For other
+	 * threads set parent pid to main thread. ie., assume main thread
+	 * spawns all threads in a process
+	*/
+	if (tgid == pid) {
+		event->fork.ppid = ppid;
+		event->fork.ptid = ppid;
+	} else {
+		event->fork.ppid = tgid;
+		event->fork.ptid = tgid;
+	}
 	event->fork.pid  = tgid;
 	event->fork.tid  = pid;
 	event->fork.header.type = PERF_RECORD_FORK;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf tools: Fix ppid for non-main thread
  2015-04-09 16:48 [PATCH] perf tools: Fix ppid for non-main thread David Ahern
@ 2015-04-09 17:05 ` Don Zickus
  2015-04-09 17:08   ` David Ahern
  2015-04-11  6:36 ` [tip:perf/core] perf tools: Fix synthesizing fork_event.ppid " tip-bot for David Ahern
  1 sibling, 1 reply; 4+ messages in thread
From: Don Zickus @ 2015-04-09 17:05 UTC (permalink / raw)
  To: David Ahern; +Cc: acme, linux-kernel

On Thu, Apr 09, 2015 at 12:48:27PM -0400, David Ahern wrote:
> Commit ca6c41c59b9 sets the ppid based on what is read from the
> /proc/pid/status file when synthesizing fork events. This is correct
> thing to do for new processes but not threads of a process. Fix
> ppid for threads to be the main thread when synthesizing fork events
> (ie., assume main thread spawned all sub-threads in a process).

That sounds right. :-)  Sorry I should have noticed that a couple of weeks
ago.

Acked-by: Don Zickus <dzickus@redhat.com>

> 
> Reported-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
> Signed-off-by: David Ahern <david.ahern@oracle.com>
> Cc: Don Zickus <dzickus@redhat.com>
> ---
>  tools/perf/util/event.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 186929a..ff866c4 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
>  {
>  	memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
>  
> -	event->fork.ppid = ppid;
> -	event->fork.ptid = ppid;
> +	/*
> +	 * for main thread set parent to ppid from status file. For other
> +	 * threads set parent pid to main thread. ie., assume main thread
> +	 * spawns all threads in a process
> +	*/
> +	if (tgid == pid) {
> +		event->fork.ppid = ppid;
> +		event->fork.ptid = ppid;
> +	} else {
> +		event->fork.ppid = tgid;
> +		event->fork.ptid = tgid;
> +	}
>  	event->fork.pid  = tgid;
>  	event->fork.tid  = pid;
>  	event->fork.header.type = PERF_RECORD_FORK;
> -- 
> 1.7.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf tools: Fix ppid for non-main thread
  2015-04-09 17:05 ` Don Zickus
@ 2015-04-09 17:08   ` David Ahern
  0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2015-04-09 17:08 UTC (permalink / raw)
  To: Don Zickus; +Cc: acme, linux-kernel

On 4/9/15 11:05 AM, Don Zickus wrote:
> On Thu, Apr 09, 2015 at 12:48:27PM -0400, David Ahern wrote:
>> >Commit ca6c41c59b9 sets the ppid based on what is read from the
>> >/proc/pid/status file when synthesizing fork events. This is correct
>> >thing to do for new processes but not threads of a process. Fix
>> >ppid for threads to be the main thread when synthesizing fork events
>> >(ie., assume main thread spawned all sub-threads in a process).
> That sounds right.:-)   Sorry I should have noticed that a couple of weeks
> ago.
>
> Acked-by: Don Zickus<dzickus@redhat.com>
>

I believe this explains the performance delta you noticed with 
specjbb/jvm. Arnaldo is the one that figured out the performance hit is 
from cloning maps; from that analysis I realized what the goof was.

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf tools: Fix synthesizing fork_event.ppid for non-main thread
  2015-04-09 16:48 [PATCH] perf tools: Fix ppid for non-main thread David Ahern
  2015-04-09 17:05 ` Don Zickus
@ 2015-04-11  6:36 ` tip-bot for David Ahern
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for David Ahern @ 2015-04-11  6:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: arnaldo.melo, mingo, david.ahern, linux-kernel, acme, hpa, dzickus, tglx

Commit-ID:  7764a385f60bd200304a33124bdb4e684caeabdf
Gitweb:     http://git.kernel.org/tip/7764a385f60bd200304a33124bdb4e684caeabdf
Author:     David Ahern <david.ahern@oracle.com>
AuthorDate: Thu, 9 Apr 2015 12:48:27 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 10 Apr 2015 10:10:55 -0300

perf tools: Fix synthesizing fork_event.ppid for non-main thread

Commit ca6c41c59b9 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events.

This is correct thing to do for new processes but not threads of a
process.

Fix ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).

Reported-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: David Ahern <david.ahern@oracle.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 5516236..9d09851 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
 {
 	memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
 
-	event->fork.ppid = ppid;
-	event->fork.ptid = ppid;
+	/*
+	 * for main thread set parent to ppid from status file. For other
+	 * threads set parent pid to main thread. ie., assume main thread
+	 * spawns all threads in a process
+	*/
+	if (tgid == pid) {
+		event->fork.ppid = ppid;
+		event->fork.ptid = ppid;
+	} else {
+		event->fork.ppid = tgid;
+		event->fork.ptid = tgid;
+	}
 	event->fork.pid  = tgid;
 	event->fork.tid  = pid;
 	event->fork.header.type = PERF_RECORD_FORK;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-11  6:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09 16:48 [PATCH] perf tools: Fix ppid for non-main thread David Ahern
2015-04-09 17:05 ` Don Zickus
2015-04-09 17:08   ` David Ahern
2015-04-11  6:36 ` [tip:perf/core] perf tools: Fix synthesizing fork_event.ppid " tip-bot for David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.