From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
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>
Subject: Re: [PATCH 09/15] perf ftrace: Add 'record' sub-command
Date: Wed, 15 May 2013 23:20:52 +0200 [thread overview]
Message-ID: <20130515212052.GA5814@krava.redhat.com> (raw)
In-Reply-To: <1368526439-31966-10-git-send-email-namhyung@kernel.org>
On Tue, May 14, 2013 at 07:13:53PM +0900, Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
>
> The ftrace record command is for saving raw ftrace buffer contents
> which can be get from per_cpu/cpuX/trace_pipe_raw.
>
> Since ftrace events are generated very frequently so single thread for
> recording mostly resulted in buffer overruns. Thus it uses per-cpu
> recorder thread to prevent such cases and they save the contents to
> their own files.
>
SNIP
> +
> + /* synthesize sample data */
> + list_for_each_entry(fra, &recorders, node) {
> + struct perf_evsel *evsel = perf_evlist__first(ftrace->evlist);
> + union perf_event event = {
> + .sample = {
> + .header = {
> + .type = PERF_RECORD_SAMPLE,
> + .misc = PERF_RECORD_MISC_KERNEL,
> + .size = sizeof(event.sample.header) +
> + evsel->sample_size,
> + },
> + },
> + };
> + struct perf_sample sample = {
> + .cpu = fra->cpu,
> + .period = 1,
> + };
> + void *raw_data;
> + u32 raw_size;
> + int orig_size;
> +
> + if (fra->state != RECORD_STATE__DONE) {
> + pr_warning("recorder failed for some reason on cpu%d\n",
> + fra->cpu);
> + continue;
> + }
> +
> + perf_event__synthesize_sample(&event, evsel->attr.sample_type,
> + &sample, false);
> +
> + raw_data = synthesize_raw_data(evsel);
> + if (raw_data == NULL) {
> + pr_err("synthesizing raw sample failed\n");
> + goto out_fra;
> + }
> +
> + /*
> + * start of raw data is the size of raw data excluding itself.
> + */
> + raw_size = sizeof(u32) + (*(u32 *) raw_data);
> +
> + orig_size = event.sample.header.size;
> + event.sample.header.size += raw_size;
> +
> + err = write(perf_fd, &event.sample, orig_size);
> + if (err != orig_size) {
> + pr_err("write error occurred\n");
> + goto out_fra;
> + }
> +
> + err = write(perf_fd, raw_data, raw_size);
> + if (err != (int)raw_size) {
> + pr_err("write error occurred\n");
> + goto out_fra;
> + }
missing free(raw_data) ?
jirka
> +
> + session->header.data_size += event.sample.header.size;
> + }
> +
> + perf_session__write_header(session, ftrace->evlist, perf_fd, true);
> +
> +out_fra:
> + list_for_each_entry_safe(fra, tmp, &recorders, node) {
> + list_del(&fra->node);
> + free(fra);
> + }
> +out_session:
> + free(session);
> +out_close:
> + close(perf_fd);
> +out_reset:
> + reset_tracing_files(ftrace);
> return done ? 0 : -1;
> }
>
next prev parent reply other threads:[~2013-05-15 21:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 10:13 [PATCHSET 00/15] perf tools: Introduce new 'ftrace' command (v2) Namhyung Kim
2013-05-14 10:13 ` [PATCH 01/15] perf util: Move debugfs/tracing helper functions to util.c Namhyung Kim
2013-05-14 10:13 ` [PATCH 02/15] perf util: Use evsel->name to get tracepoint_paths Namhyung Kim
2013-05-15 14:59 ` Jiri Olsa
2013-05-16 2:13 ` Namhyung Kim
2013-05-14 10:13 ` [PATCH 03/15] perf util: Save pid-cmdline mapping into tracing header Namhyung Kim
2013-05-15 21:21 ` Jiri Olsa
2013-05-16 2:51 ` Namhyung Kim
2013-05-14 10:13 ` [PATCH 04/15] perf util: Add more debug message on failure path Namhyung Kim
2013-05-14 10:13 ` [PATCH 05/15] perf tools: Introduce new 'ftrace' tool Namhyung Kim
2013-05-14 10:13 ` [PATCH 06/15] perf ftrace: Add support for --pid option Namhyung Kim
2013-05-14 10:13 ` [PATCH 07/15] perf ftrace: Add support for -a and -C option Namhyung Kim
2013-05-14 10:13 ` [PATCH 08/15] perf ftrace: Split "live" sub-command Namhyung Kim
2013-05-14 10:13 ` [PATCH 09/15] perf ftrace: Add 'record' sub-command Namhyung Kim
2013-05-15 21:20 ` Jiri Olsa [this message]
2013-05-16 2:24 ` Namhyung Kim
2013-05-15 21:21 ` Jiri Olsa
2013-05-16 2:43 ` Namhyung Kim
2013-05-14 10:13 ` [PATCH 10/15] perf ftrace: Add 'show' sub-command Namhyung Kim
2013-05-15 21:21 ` Jiri Olsa
2013-05-16 2:47 ` Namhyung Kim
2013-05-14 10:13 ` [PATCH 11/15] perf ftrace: Add 'report' sub-command Namhyung Kim
2013-05-14 10:13 ` [PATCH 12/15] perf ftrace: Use pager for displaying result Namhyung Kim
2013-05-14 10:13 ` [PATCH 13/15] perf ftrace: Cleanup using ftrace_setup/teardown() Namhyung Kim
2013-05-14 10:13 ` [PATCH 14/15] perf tools: Add document for perf-ftrace command Namhyung Kim
2013-05-14 10:13 ` [PATCH 15/15] perf ftrace: Add a signal handler for SIGSEGV Namhyung Kim
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=20130515212052.GA5814@krava.redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--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 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.