Skip to contentSkip to conversation

perf stat: Set child_pid after perf_evlist__prepare_workload()

PATCH In review Namhyung Kim 4 participants 5 messages Sep 30, 2013 – Oct 8, 2013 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf stat: Set child_pid after perf_evlist__prepare_workload()

From: Namhyung Kim <[email protected]>

The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/ start_workload()") converted to use the function but forgot to update child_pid. Fix it.

Cc David Ahern <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +1 -0
index f686d5ff594e..5098f144b92d 100644
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
 			perror("failed to prepare workload");
 			return -1;
 		}
+		child_pid = evsel_list->workload.pid;
 	}
 
 	if (group)
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 19 lines · Namhyung Kim

From: Namhyung Kim <[email protected]>

The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/ start_workload()") converted to use the function but forgot to update child_pid. Fix it.

Cc David Ahern <[email protected]>
Cc Stephane Eranian <[email protected]>
---
  tools/perf/builtin-stat.c | 1 +
  1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +0 -0
index f686d5ff594e..5098f144b92d 100644

tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char **argv) · line 463

Quoted 7 lines
tools/perf/builtin-stat.c +1 -0
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
  			perror("failed to prepare workload");
  			return -1;
  		}
+		child_pid = evsel_list->workload.pid;
  	}
 
  	if (group)

Interesting. I can't find a test case where is matters ... perhaps a convenience of waitpid taking -1.

David

#2 lore raw

Em Mon, Sep 30, 2013 at 07:47:25AM -0600, David Ahern escreveu:

Quoted 25 lines · Namhyung Kim
Quoted 24 lines

From: Namhyung Kim <[email protected]>

The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/ start_workload()") converted to use the function but forgot to update child_pid. Fix it.

Cc David Ahern <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +1 -0
index f686d5ff594e..5098f144b92d 100644
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
 			perror("failed to prepare workload");
 			return -1;
 		}
+		child_pid = evsel_list->workload.pid;
 	}
 
Quoted 5 lines

tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char **argv) · line 463

Quoted 2 lines
tools/perf/builtin-stat.c +0 -0
 	if (group)

Interesting. I can't find a test case where is matters ... perhaps a convenience of waitpid taking -1.

Yeah, the interval part initially used the fork return, then after acf2892270dc used the default value of child_pid, -1, which is ok as it waits for any children, but I wonder what would happen in workloads with multiple children.

But for correctness acf2892270dc should have kept the existing semantics, even if using -1 could in the end be ok.

- Arnaldo

author maintainer
#3 lore raw
Quoted 32 lines · Arnaldo Carvalho de Melo

Em Mon, Sep 30, 2013 at 07:47:25AM -0600, David Ahern escreveu:

Quoted 25 lines · Namhyung Kim
Quoted 24 lines

From: Namhyung Kim <[email protected]>

The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/ start_workload()") converted to use the function but forgot to update child_pid. Fix it.

Cc David Ahern <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +1 -0
index f686d5ff594e..5098f144b92d 100644
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
 			perror("failed to prepare workload");
 			return -1;
 		}
+		child_pid = evsel_list->workload.pid;
 	}
 
Quoted 5 lines

tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char **argv) · line 463

Quoted 2 lines
tools/perf/builtin-stat.c +0 -0
 	if (group)

Interesting. I can't find a test case where is matters ... perhaps a convenience of waitpid taking -1.

Quoted 4 lines

Yeah, the interval part initially used the fork return, then after acf2892270dc used the default value of child_pid, -1, which is ok as it waits for any children, but I wonder what would happen in workloads with multiple children.

Hmm.. right. And in fact what I actually concern was when killing child if create_perf_stat_counter() failed.

	if (child_pid != -1)
		kill(child_pid, SIGTERM);
Quoted 3 lines

But for correctness acf2892270dc should have kept the existing semantics, even if using -1 could in the end be ok.

Agreed.

Thanks,
Namhyung

#4 lore raw
In reply to Namhyung Kim
perf stat: Set child_pid after perf_evlist__prepare_workload()
Commit-ID:  d20a47e70b57a77f4d1b0dba98a668e14c2f9bf9
Gitweb:     http://git.kernel.org/tip/d20a47e70b57a77f4d1b0dba98a668e14c2f9bf9
Author:     Namhyung Kim <[email protected]>
AuthorDate: Mon, 30 Sep 2013 18:01:11 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 4 Oct 2013 15:16:05 -0300

perf stat: Set child_pid after perf_evlist__prepare_workload()

The commit acf2892270dc ("perf stat: Use perf_evlist__prepare/ start_workload()") converted to use the function but forgot to update child_pid. Fix it.

---
 tools/perf/builtin-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-stat.c +1 -0
index f686d5f..5098f14 100644
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
 			perror("failed to prepare workload");
 			return -1;
 		}
+		child_pid = evsel_list->workload.pid;
 	}
 
 	if (group)