Skip to contentSkip to conversation

perf tip: fails to convert comm

DISCUSSION David Ahern 5 participants 11 messages Nov 13, 2013 – Nov 20, 2013 perf events

lore
Share & tools
lore
#0 lore raw

Hi Namhyung and Frederic:

If you recall I mentioned noting a problem with the callchain series showing comm's. Well, it fails on acme's perf/core. git bisect points to:

$ git bisect bad
4dfced359fbc719a35527416f1b4b3999647f68b is the first bad commit
commit 4dfced359fbc719a35527416f1b4b3999647f68b
Author: Namhyung Kim <[email protected]>
Date:   Fri Sep 13 16:28:57 2013 +0900

perf tools: Get current comm instead of last one

At insert time, a hist entry should reference comm at the time
otherwise
it'll get the last comm anyway.

How to re-create:

Start point is tools/perf directory for 3.12 (Linus tree):

  $ perf sched record -o /tmp/perf.data -g -- make -j 16
  $ perf script -i /tmp/perf.data > /tmp/1

cd to Arnaldo's tree, make perf and use it to create /tmp/2:

  $ perf script -i /tmp/perf.data > /tmp/1
  $ diff -U3 /tmp/1 /tmp/2 | less

You'll see a number of comm's showing as :<pid> instead of make, etc.

David

#1 lore raw
Quoted 22 lines · David Ahern

Hi Namhyung and Frederic:

If you recall I mentioned noting a problem with the callchain series showing comm's. Well, it fails on acme's perf/core. git bisect points to:

$ git bisect bad
4dfced359fbc719a35527416f1b4b3999647f68b is the first bad commit
commit 4dfced359fbc719a35527416f1b4b3999647f68b
Author: Namhyung Kim <[email protected]>
Date:   Fri Sep 13 16:28:57 2013 +0900

perf tools: Get current comm instead of last one

At insert time, a hist entry should reference comm at the time
otherwise
it'll get the last comm anyway.

How to re-create:

Start point is tools/perf directory for 3.12 (Linus tree):

Quoted 8 lines
  $ perf sched record -o /tmp/perf.data -g -- make -j 16
  $ perf script -i /tmp/perf.data > /tmp/1

cd to Arnaldo's tree, make perf and use it to create /tmp/2:

  $ perf script -i /tmp/perf.data > /tmp/1
  $ diff -U3 /tmp/1 /tmp/2 | less

You'll see a number of comm's showing as :<pid> instead of make, etc.

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

#2 lore raw
Quoted 3 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

I've been thinking about moving the event dumping code from perf-script to perf-dump. In the process could add an argument to dump events -- similar to -D option for report/script, but more inline with the output that perf-script shows now.

David

#4 lore raw
In reply to Frederic Weisbecker

Em Wed, Nov 13, 2013 at 07:03:47PM +0100, Frederic Weisbecker escreveu:

Quoted 30 lines · David Ahern
Quoted 29 lines

Hi Namhyung and Frederic:

If you recall I mentioned noting a problem with the callchain series showing comm's. Well, it fails on acme's perf/core. git bisect points to:

$ git bisect bad
4dfced359fbc719a35527416f1b4b3999647f68b is the first bad commit
commit 4dfced359fbc719a35527416f1b4b3999647f68b
Author: Namhyung Kim <[email protected]>
Date:   Fri Sep 13 16:28:57 2013 +0900

perf tools: Get current comm instead of last one

At insert time, a hist entry should reference comm at the time
otherwise
it'll get the last comm anyway.

How to re-create:

Start point is tools/perf directory for 3.12 (Linus tree):

  $ perf sched record -o /tmp/perf.data -g -- make -j 16
  $ perf script -i /tmp/perf.data > /tmp/1

cd to Arnaldo's tree, make perf and use it to create /tmp/2:

  $ perf script -i /tmp/perf.data > /tmp/1
  $ diff -U3 /tmp/1 /tmp/2 | less
Quoted 5 lines
Quoted 1 line

You'll see a number of comm's showing as :<pid> instead of make, etc.

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

'perf record -D' not enough?

- Arnaldo

#5 lore raw
Quoted 31 lines · Arnaldo Carvalho de Melo

Em Wed, Nov 13, 2013 at 07:03:47PM +0100, Frederic Weisbecker escreveu:

Quoted 30 lines · David Ahern
Quoted 29 lines

Hi Namhyung and Frederic:

If you recall I mentioned noting a problem with the callchain series showing comm's. Well, it fails on acme's perf/core. git bisect points to:

$ git bisect bad
4dfced359fbc719a35527416f1b4b3999647f68b is the first bad commit
commit 4dfced359fbc719a35527416f1b4b3999647f68b
Author: Namhyung Kim <[email protected]>
Date:   Fri Sep 13 16:28:57 2013 +0900

perf tools: Get current comm instead of last one

At insert time, a hist entry should reference comm at the time
otherwise
it'll get the last comm anyway.

How to re-create:

Start point is tools/perf directory for 3.12 (Linus tree):

  $ perf sched record -o /tmp/perf.data -g -- make -j 16
  $ perf script -i /tmp/perf.data > /tmp/1

cd to Arnaldo's tree, make perf and use it to create /tmp/2:

  $ perf script -i /tmp/perf.data > /tmp/1
  $ diff -U3 /tmp/1 /tmp/2 | less
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

You'll see a number of comm's showing as :<pid> instead of make, etc.

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

'perf record -D' not enough?

No because it's not easy to correlate with perf script event output. Although it could be if we simply dump the time the same way in both.

#3 lore raw
In reply to David Ahern
Quoted 9 lines · David Ahern
Quoted 3 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

I've been thinking about moving the event dumping code from perf-script to perf-dump. In the process could add an argument to dump events -- similar to -D option for report/script, but more inline with the output that perf-script shows now.

Yeah indeed,sounds good!

#6 lore raw
In reply to Frederic Weisbecker

HI Frederic:

Quoted 4 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

Any progress on a solution? This is a regression in 3.13.

David

#7 lore raw
Quoted 9 lines · David Ahern

HI Frederic:

Quoted 4 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

Any progress on a solution? This is a regression in 3.13.

So the problem is that when a thread overrides its default ":%pid" comm, we forget to tag the thread comm as overriden. Hence, this overriden comm is not inherited on future forks.

So here is a fix. Tell me if you see more issue, I'll cook a proper changelog and resend if everyting looks good.

Thanks.

tools/perf/util/thread.c +5 -6
index cd8e2f5..49eaf1d 100644
@@ -70,14 +70,13 @@ int thread__set_comm(struct thread *thread, const char *str, u64 timestamp)
 	/* Override latest entry if it had no specific time coverage */
 	if (!curr->start) {
 		comm__override(curr, str, timestamp);
-		return 0;
+	} else {
+		new = comm__new(str, timestamp);
+		if (!new)
+			return -ENOMEM;
+		list_add(&new->list, &thread->comm_list);
 	}
 
-	new = comm__new(str, timestamp);
-	if (!new)
-		return -ENOMEM;
-
-	list_add(&new->list, &thread->comm_list);
 	thread->comm_set = true;
 
 	return 0;
maintainer
#8 lore raw

Hi Frederic,

2013-11-16 (토), 02:02 +0100, Frederic Weisbecker:

Quoted 34 lines · David Ahern
Quoted 9 lines

HI Frederic:

Quoted 4 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

Any progress on a solution? This is a regression in 3.13.

So the problem is that when a thread overrides its default ":%pid" comm, we forget to tag the thread comm as overriden. Hence, this overriden comm is not inherited on future forks.

So here is a fix. Tell me if you see more issue, I'll cook a proper changelog and resend if everyting looks good.

Thanks.

tools/perf/util/thread.c +5 -1
index cd8e2f5..49eaf1d 100644
@@ -70,14 +70,13 @@ int thread__set_comm(struct thread *thread, const char *str, u64 timestamp)
 	/* Override latest entry if it had no specific time coverage */
 	if (!curr->start) {
 		comm__override(curr, str, timestamp);
-		return 0;
+	} else {
+		new = comm__new(str, timestamp);
+		if (!new)
+			return -ENOMEM;
+		list_add(&new->list, &thread->comm_list);

tools/perf/util/thread.c int thread__set_comm(struct thread *thread, const char *str, u64 timestamp) · line 82

Quoted 10 lines
tools/perf/util/thread.c +0 -5
 	}
 
-	new = comm__new(str, timestamp);
-	if (!new)
-		return -ENOMEM;
-
-	list_add(&new->list, &thread->comm_list);
 	thread->comm_set = true;
 
 	return 0;

Looks good to me.

Thanks for the fix.
Namhyung

author Tested-by
#9 lore raw
In reply to Frederic Weisbecker
Quoted 9 lines · Frederic Weisbecker
Quoted 8 lines · David Ahern

HI Frederic:

Quoted 4 lines · Frederic Weisbecker

I see. I can reproduce, I'll check and see what happens. It would be nice if we could have an option to dump internal perf events like comm events as well in the perf script stream.

Quoted 8 lines
Quoted 1 line

Any progress on a solution? This is a regression in 3.13.

So the problem is that when a thread overrides its default ":%pid" comm, we forget to tag the thread comm as overriden. Hence, this overriden comm is not inherited on future forks.

So here is a fix. Tell me if you see more issue, I'll cook a proper changelog and resend if everyting looks good.

That works for me. Thank you.

#10 lore raw

[tip:perf/urgent] perf tools: Tag thread comm as overriden

In reply to Frederic Weisbecker
perf tools: Tag thread comm as overriden
Commit-ID:  a5285ad9e30fd90b88a11adcab97bd4c3ffe44eb
Gitweb:     http://git.kernel.org/tip/a5285ad9e30fd90b88a11adcab97bd4c3ffe44eb
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Sat, 16 Nov 2013 02:02:09 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 19 Nov 2013 10:33:29 -0300

perf tools: Tag thread comm as overriden

The problem is that when a thread overrides its default ":%pid" comm, we forget to tag the thread comm as overriden. Hence, this overriden comm is not inherited on future forks. Fix it.

---
 tools/perf/util/thread.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
tools/perf/util/thread.c +5 -6
index cd8e2f5..49eaf1d 100644
@@ -70,14 +70,13 @@ int thread__set_comm(struct thread *thread, const char *str, u64 timestamp)
 	/* Override latest entry if it had no specific time coverage */
 	if (!curr->start) {
 		comm__override(curr, str, timestamp);
-		return 0;
+	} else {
+		new = comm__new(str, timestamp);
+		if (!new)
+			return -ENOMEM;
+		list_add(&new->list, &thread->comm_list);
 	}
 
-	new = comm__new(str, timestamp);
-	if (!new)
-		return -ENOMEM;
-
-	list_add(&new->list, &thread->comm_list);
 	thread->comm_set = true;
 
 	return 0;