mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	David Ahern <dsahern@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Jeremy Eder <jeder@redhat.com>
Subject: Re: [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4)
Date: Tue, 13 Aug 2013 11:20:52 +0900	[thread overview]
Message-ID: <87r4dywcu3.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <20130809102306.GA1045@krava.brq.redhat.com> (Jiri Olsa's message of "Fri, 9 Aug 2013 12:23:06 +0200")

Hi Jiri and Jeremy,

On Fri, 9 Aug 2013 12:23:06 +0200, Jiri Olsa wrote:
> On Tue, Jul 30, 2013 at 06:18:57PM +0900, Namhyung Kim wrote:
>> This patchset implements a front-end tool for kernel's ftrace.  It
>> uses function_graph tracer by default and normal function tracer is
>> also supported.  (Of course you need to enable those tracers in your
>> kernel first.)
>> 
>> v4 changes:
>>  * use pid instead of tid for -p option (David)
>>  * not to poll() for reading ftrace pipes (Jiri)
>>  * rename to create_perf_header() (Jiri)
>>  * canonicalize directory name (Jiri)
>>  * show more info when -D option was given (Jiri)
>>  * update documentation (Jiri)
>>  * and few more bug fixes
>> 
>> I pushed it out to 'perf/ftrace-v4' branch on my tree at:
>> 
>>   git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git
>
> got following for record:
>
> [root@dhcp-26-214 perf]# ./perf ftrace record kill
> usage: kill [ -s signal | -p ] [ -a ] pid ...
>        kill -l [ signal ]
> recorder failed for some reason on cpu0
> recorder failed for some reason on cpu1

It seems like an empty trace pipe returns EAGAIN after child exited - I
expected an EOF.  I don't know why I didn't meet this on my system (FYI
I'm running F17 and this patch tested on that kernel mostly).  Maybe
recent kernel changed the behavior.

Anyway I added a check and printed error message on other cases.  Could
you please test whether the patch below works?

>
>
> afterwards 'perf ftrace report' gets stuck with 2 processes:
>
> [jolsa@dhcp-26-214 perf]$ sudo pstack 1470
> #0  0x00007f23ab61e997 in munmap () from /lib64/libc.so.6
> #1  0x000000000047b5f7 in __perf_session__process_events ()
> #2  0x000000000043f230 in do_ftrace_report ()
> #3  0x0000000000440555 in cmd_ftrace ()
> #4  0x000000000041aad3 in run_builtin ()
> #5  0x000000000041a379 in main ()

Hmm.. this repeated munmap() calls are fixed also.


> [jolsa@dhcp-26-214 perf]$ sudo pstack 1471
> #0  0x00007f23ab61b623 in __select_nocancel () from /lib64/libc.so.6
> #1  0x000000000046a337 in pager_preexec ()
> #2  0x000000000045f5a3 in start_command ()
> #3  0x000000000046a4ab in setup_pager ()
> #4  0x0000000000440535 in cmd_ftrace ()
> #5  0x000000000041aad3 in run_builtin ()
> #6  0x000000000041a379 in main ()



------------8<-------------
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 9e78ec19caeb..10590b794cae 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -555,17 +555,25 @@ sleep:
 	while (true) {
 		int n = read(trace_fd, buf, sizeof(buf));
 
-		if (n < 0)
-			goto out_close;
-		if (n == 0)
+		if (n < 0) {
+			if (errno == EINTR || errno == EAGAIN)
+				break;
+			perror("flush read");
+			goto out_close2;
+		} else if (n == 0)
 			break;
-		if (write(output_fd, buf, n) != n)
-			goto out_close;
+
+		if (write(output_fd, buf, n) != n) {
+			perror("flush write");
+			goto out_close2;
+		}
 
 		byte_written += n;
 	}
 	fra->state = RECORD_STATE__DONE;
 
+out_close2:
+	close(output_fd);
 out_close:
 	close(trace_fd);
 out:
@@ -579,6 +587,8 @@ out:
 		pthread_cond_signal(&recorder_ready_cond);
 		pthread_mutex_unlock(&recorder_mutex);
 	}
+
+	pr_debug2("done with %ld bytes\n", (long)byte_written);
 	return fra;
 }
 
@@ -1139,12 +1149,12 @@ retry:
 		return record;
 	}
 
-	munmap(fra->map, pevent_get_page_size(ftrace->pevent));
-	fra->map = NULL;
-
 	if (fra->done)
 		return NULL;
 
+	munmap(fra->map, pevent_get_page_size(ftrace->pevent));
+	fra->map = NULL;
+
 	fra->offset += pevent_get_page_size(ftrace->pevent);
 	if (fra->offset >= fra->size) {
 		/* EOF */

  reply	other threads:[~2013-08-13  2:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30  9:18 Namhyung Kim
2013-07-30  9:18 ` [PATCH 01/17] perf util: Save pid-cmdline mapping into tracing header Namhyung Kim
2013-07-30 13:28   ` Arnaldo Carvalho de Melo
2013-07-31  0:51     ` Namhyung Kim
2013-07-31 14:07       ` Arnaldo Carvalho de Melo
2013-08-05  7:17         ` Namhyung Kim
2013-08-07 13:44           ` David Ahern
2013-08-09  5:51             ` Namhyung Kim
2013-07-30  9:18 ` [PATCH 02/17] perf util: Add more debug message on failure path Namhyung Kim
2013-07-30 13:33   ` Arnaldo Carvalho de Melo
2013-07-30  9:19 ` [PATCH 03/17] perf tools: Introduce new 'ftrace' tool Namhyung Kim
2013-07-30  9:19 ` [PATCH 04/17] perf ftrace: Add support for --pid option Namhyung Kim
2013-07-30  9:19 ` [PATCH 05/17] perf ftrace: Add support for -a and -C option Namhyung Kim
2013-07-30  9:19 ` [PATCH 06/17] perf ftrace: Split "live" sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 07/17] perf ftrace: Add 'record' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 08/17] perf ftrace: Add 'show' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 09/17] perf ftrace: Add 'report' sub-command Namhyung Kim
2013-07-30  9:19 ` [PATCH 10/17] perf ftrace: Add dump_printf() for low-level debugging Namhyung Kim
2013-07-30  9:19 ` [PATCH 11/17] perf ftrace: Use pager for displaying result Namhyung Kim
2013-07-30  9:19 ` [PATCH 12/17] perf ftrace: Cleanup using ftrace_setup/teardown() Namhyung Kim
2013-07-30  9:19 ` [PATCH 13/17] perf tools: Add document for perf-ftrace command Namhyung Kim
2013-07-30  9:19 ` [PATCH 14/17] perf ftrace: Add a signal handler for SIGSEGV Namhyung Kim
2013-07-30  9:19 ` [PATCH 15/17] perf ftrace: Add --clock option Namhyung Kim
2013-07-30  9:19 ` [PATCH 16/17] perf ftrace: Show leaf-functions as oneliner Namhyung Kim
2013-07-30  9:19 ` [PATCH 17/17] perf ftrace: Tidy up the function graph output of 'show' subcommand Namhyung Kim
2013-08-01 12:02 ` [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4) Jiri Olsa
2013-08-02  9:16   ` Ingo Molnar
2013-08-05  7:44     ` Namhyung Kim
     [not found]   ` <51FB2B90.6090602@gmail.com>
2013-08-02 13:33     ` [PATCH] perf tools: Renaming 'time' variable in perf_time_to_tsc due to name shadowing error Jiri Olsa
2013-08-03 19:23       ` Adrian Hunter
2013-08-05  7:47         ` Jiri Olsa
2013-08-09 10:23 ` [PATCHSET 00/17] perf tools: Introduce new 'ftrace' command (v4) Jiri Olsa
2013-08-13  2:20   ` Namhyung Kim [this message]
2013-08-28 14:57     ` Jeremy Eder
2013-08-29  2:56       ` Namhyung Kim
2013-08-09 10:25 ` Jiri Olsa
2013-08-09 10:30   ` 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=87r4dywcu3.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jeder@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.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

Powered by JetHome