public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] perf record: We should fork only if a program was specified to run
@ 2009-12-27 23:36 Arnaldo Carvalho de Melo
  2009-12-27 23:36 ` [PATCH 02/10] perf tools: Add missing header files to LIB_H Makefile variable Arnaldo Carvalho de Melo
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2009-12-27 23:36 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo,
	Frédéric Weisbecker, Mike Galbraith, Peter Zijlstra,
	Paul Mackerras

From: Arnaldo Carvalho de Melo <acme@redhat.com>

IOW: Now 'perf record -a' works, this was a bug introduced in:

856e96608a72412d319e498a3a7c557571f811bd
"perf record: Properly synchronize child creation"

Also fix the -C usage, i.e. allow for profiling all the tasks in one
CPU.

Reported-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 63136d0..2654253 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -402,7 +402,7 @@ static void atexit_header(void)
 	perf_header__write(&session->header, output, true);
 }
 
-static int __cmd_record(int argc __used, const char **argv)
+static int __cmd_record(int argc, const char **argv)
 {
 	int i, counter;
 	struct stat st;
@@ -411,6 +411,7 @@ static int __cmd_record(int argc __used, const char **argv)
 	int err;
 	unsigned long waking = 0;
 	int child_ready_pipe[2], go_pipe[2];
+	const bool forks = target_pid == -1 && argc > 0;
 	char buf;
 
 	page_size = sysconf(_SC_PAGE_SIZE);
@@ -422,7 +423,7 @@ static int __cmd_record(int argc __used, const char **argv)
 	signal(SIGCHLD, sig_handler);
 	signal(SIGINT, sig_handler);
 
-	if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) {
+	if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
 		perror("failed to create pipes");
 		exit(-1);
 	}
@@ -483,7 +484,7 @@ static int __cmd_record(int argc __used, const char **argv)
 
 	atexit(atexit_header);
 
-	if (target_pid == -1) {
+	if (forks) {
 		pid = fork();
 		if (pid < 0) {
 			perror("failed to fork");
@@ -550,7 +551,7 @@ static int __cmd_record(int argc __used, const char **argv)
 			return err;
 	}
 
-	if (!system_wide)
+	if (!system_wide && profile_cpu == -1)
 		event__synthesize_thread(pid, process_synthesized_event,
 					 session);
 	else
@@ -569,7 +570,8 @@ static int __cmd_record(int argc __used, const char **argv)
 	/*
 	 * Let the child rip
 	 */
-	close(go_pipe[1]);
+	if (forks)
+		close(go_pipe[1]);
 
 	for (;;) {
 		int hits = samples;
@@ -667,7 +669,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, options, record_usage,
 			    PARSE_OPT_STOP_AT_NON_OPTION);
-	if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1))
+	if (!argc && target_pid == -1 && !system_wide && profile_cpu == -1)
 		usage_with_options(record_usage, options);
 
 	symbol__init();
-- 
1.6.2.5


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

end of thread, other threads:[~2009-12-28  8:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-27 23:36 [PATCH 01/10] perf record: We should fork only if a program was specified to run Arnaldo Carvalho de Melo
2009-12-27 23:36 ` [PATCH 02/10] perf tools: Add missing header files to LIB_H Makefile variable Arnaldo Carvalho de Melo
2009-12-27 23:36 ` [PATCH 03/10] perf session: Move the event processing routines to session.c Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 04/10] perf tools: Move the map class definition to a separate header Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 05/10] perf session: Share the common trace sample_check routine as perf_session__has_traces Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 06/10] perf session: Remove sample_type_check from event_ops Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 07/10] perf session: Move total_unknown to perf_session->unknown events Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 08/10] perf session: Move full_paths config to symbol_conf Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 09/10] perf session: Remove redundant prefix & suffix from perf_event_ops Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 10/10] perf record: Introduce a symtab cache Arnaldo Carvalho de Melo
2009-12-27 23:40   ` Arnaldo Carvalho de Melo
2009-12-28  8:04     ` Ingo Molnar
2009-12-28  8:05 ` [PATCH 01/10] perf record: We should fork only if a program was specified to run Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox