[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-e3d5911221f5cf71e1f0306256d4e42d34a365d2@git.kernel.org>
Date: Fri, 30 Jan 2015 10:32:43 -0800
From: tip-bot for Namhyung Kim <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: acme@...hat.com, andi@...stfloor.org, mail@...ianw.de,
eranian@...gle.com, adrian.hunter@...el.com, namhyung@...nel.org,
mingo@...nel.org, a.p.zijlstra@...llo.nl, fweisbec@...il.com,
jolsa@...nel.org, tglx@...utronix.de, dsahern@...il.com,
hpa@...or.com, linux-kernel@...r.kernel.org
Subject: [tip:perf/core] perf record: Show precise number of samples
Commit-ID: e3d5911221f5cf71e1f0306256d4e42d34a365d2
Gitweb: http://git.kernel.org/tip/e3d5911221f5cf71e1f0306256d4e42d34a365d2
Author: Namhyung Kim <namhyung@...nel.org>
AuthorDate: Thu, 29 Jan 2015 17:06:44 +0900
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 29 Jan 2015 16:37:20 -0300
perf record: Show precise number of samples
After perf record finishes, it prints file size and number of samples in
the file but this info is wrong since it assumes typical sample size of
24 bytes and divides file size by the value.
However as we post-process recorded samples for build-id, it can show
correct number like below. If build-id post-processing is not requested
just omit the wrong number of samples.
$ perf record noploop 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.159 MB perf.data (3989 samples) ]
$ perf report --stdio -n
# To display the perf.data header info, please use --header/--header-only options.
#
# Samples: 3K of event 'cycles'
# Event count (approx.): 3771330663
#
# Overhead Samples Command Shared Object Symbol
# ........ ............ ....... ................ ..........................
#
99.90% 3982 noploop noploop [.] main
0.09% 1 noploop ld-2.17.so [.] _dl_check_map_versions
0.01% 1 noploop [kernel.vmlinux] [k] setup_arg_pages
0.00% 5 noploop [kernel.vmlinux] [k] intel_pmu_enable_all
Reported-by: Milian Wolff <mail@...ianw.de>
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Reviewed-by: Jiri Olsa <jolsa@...nel.org>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: David Ahern <dsahern@...il.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Stephane Eranian <eranian@...gle.com>
Link: http://lkml.kernel.org/r/1422518843-25818-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-record.c | 51 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 1134de2..9900b43 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -190,6 +190,19 @@ out:
return rc;
}
+static int process_sample_event(struct perf_tool *tool,
+ union perf_event *event,
+ struct perf_sample *sample,
+ struct perf_evsel *evsel,
+ struct machine *machine)
+{
+ struct record *rec = container_of(tool, struct record, tool);
+
+ rec->samples++;
+
+ return build_id__mark_dso_hit(tool, event, sample, evsel, machine);
+}
+
static int process_buildids(struct record *rec)
{
struct perf_data_file *file = &rec->file;
@@ -212,7 +225,7 @@ static int process_buildids(struct record *rec)
*/
symbol_conf.ignore_vmlinux_buildid = true;
- return perf_session__process_events(session, &build_id__mark_dso_hit_ops);
+ return perf_session__process_events(session, &rec->tool);
}
static void perf_event__synthesize_guest_os(struct machine *machine, void *data)
@@ -503,19 +516,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
goto out_child;
}
- if (!quiet) {
+ if (!quiet)
fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
- /*
- * Approximate RIP event size: 24 bytes.
- */
- fprintf(stderr,
- "[ perf record: Captured and wrote %.3f MB %s (~%" PRIu64 " samples) ]\n",
- (double)rec->bytes_written / 1024.0 / 1024.0,
- file->path,
- rec->bytes_written / 24);
- }
-
out_child:
if (forks) {
int exit_status;
@@ -534,6 +537,9 @@ out_child:
} else
status = err;
+ /* this will be recalculated during process_buildids() */
+ rec->samples = 0;
+
if (!err && !file->is_pipe) {
rec->session->header.data_size += rec->bytes_written;
@@ -543,6 +549,20 @@ out_child:
file->fd, true);
}
+ if (!err && !quiet) {
+ char samples[128];
+
+ if (rec->samples)
+ scnprintf(samples, sizeof(samples),
+ " (%" PRIu64 " samples)", rec->samples);
+ else
+ samples[0] = '\0';
+
+ fprintf(stderr, "[ perf record: Captured and wrote %.3f MB %s%s ]\n",
+ perf_data_file__size(file) / 1024.0 / 1024.0,
+ file->path, samples);
+ }
+
out_delete_session:
perf_session__delete(session);
return status;
@@ -719,6 +739,13 @@ static struct record record = {
.default_per_cpu = true,
},
},
+ .tool = {
+ .sample = process_sample_event,
+ .fork = perf_event__process_fork,
+ .comm = perf_event__process_comm,
+ .mmap = perf_event__process_mmap,
+ .mmap2 = perf_event__process_mmap2,
+ },
};
#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: "
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists