From: Jiri Olsa <jolsa@kernel.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>, Ingo Molnar <mingo@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Ahern <dsahern@gmail.com>, Andi Kleen <ak@linux.intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andy Lutomirski <luto@amacapital.net>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: [PATCH 21/21] perf report: Add --stats=ud option to display user data debug info
Date: Wed, 24 Jan 2018 12:51:43 +0100 [thread overview]
Message-ID: <20180124115143.14322-22-jolsa@kernel.org> (raw)
In-Reply-To: <20180124115143.14322-1-jolsa@kernel.org>
Adding --stats=ud option to display user data
debug info, like:
$ perf report --no-children --tasks=ud
# sample event match drop pid tid ppid comm
0 0 0 0 0 0 -1 |swapper
503 437 503 0 23985 23985 -1 |sched-messaging
594 520 594 0 24064 24064 23985 | sched-messaging
624 345 622 2 24320 24320 23985 | sched-messaging
567 514 566 1 24065 24065 23985 | sched-messaging
470 298 467 3 24321 24321 23985 | sched-messaging
388 266 387 1 24066 24066 23985 | sched-messaging
...
The --tasks output is useful for displaying thread
related stats. More stats can be added by adding
new argument to --stats=<arg> option.
Link: http://lkml.kernel.org/n/tip-3wcrngoibk5l96nqyhp0nbkm@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-report.c | 51 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 45 insertions(+), 6 deletions(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 82b2368d208a..2cd00055d517 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -54,6 +54,11 @@
#include <unistd.h>
#include <linux/mman.h>
+enum {
+ TASKS_STAT__USER_NONE = 0,
+ TASKS_STAT__USER_DATA,
+};
+
struct report {
struct perf_tool tool;
struct perf_session *session;
@@ -83,6 +88,7 @@ struct report {
int socket_filter;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
struct branch_type_stat brtype_stat;
+ int tasks_stat;
};
static int report__config(const char *var, const char *value, void *cb)
@@ -839,6 +845,11 @@ static void tasks_setup(struct report *rep)
rep->tool.exit = perf_event__process_exit;
rep->tool.fork = perf_event__process_fork;
rep->tool.no_warn = true;
+
+ if (rep->tasks_stat == TASKS_STAT__USER_DATA) {
+ rep->tool.sample = process_sample_event;
+ rep->tool.user_data = process_user_data_event;
+ }
}
struct task {
@@ -898,11 +909,24 @@ static int map_groups__fprintf_task(struct map_groups *mg, int indent, FILE *fp)
return printed;
}
-static void task__print_level(struct task *task, FILE *fp, int level)
+static void task__print_level(struct task *task, FILE *fp, int level,
+ struct report *rep)
{
struct thread *thread = task->thread;
struct task *child;
- int comm_indent = fprintf(fp, " %8d %8d %8d |%*s",
+ int comm_indent;
+
+ comm_indent = fprintf(fp, " ");
+
+ if (rep->tasks_stat == TASKS_STAT__USER_DATA) {
+ comm_indent += fprintf(fp, "%8" PRIu64 " %8" PRIu64 " %8" PRIu64 " %8" PRIu64,
+ thread->stats.user_data_sample,
+ thread->stats.user_data_event,
+ thread->stats.user_data_match,
+ thread->stats.user_data_drop);
+ }
+
+ comm_indent += fprintf(fp, "%8d %8d %8d |%*s",
thread->pid_, thread->tid, thread->ppid,
level, "");
@@ -912,7 +936,7 @@ static void task__print_level(struct task *task, FILE *fp, int level)
if (!list_empty(&task->children)) {
list_for_each_entry(child, &task->children, list)
- task__print_level(child, fp, level + 1);
+ task__print_level(child, fp, level + 1, rep);
}
}
@@ -973,10 +997,15 @@ static int tasks_print(struct report *rep, FILE *fp)
list_add_tail(&task->list, &list);
}
- fprintf(fp, "# %8s %8s %8s %s\n", "pid", "tid", "ppid", "comm");
+ fprintf(fp, "#");
+
+ if (rep->tasks_stat == TASKS_STAT__USER_DATA)
+ fprintf(fp, "%8s %8s %8s %8s", "sample", "event", "match", "drop");
+
+ fprintf(fp, "%8s %8s %8s %s\n", "pid", "tid", "ppid", "comm");
list_for_each_entry(task, &list, list)
- task__print_level(task, fp, 0);
+ task__print_level(task, fp, 0, rep);
free(tasks);
return 0;
@@ -1154,6 +1183,7 @@ int cmd_report(int argc, const char **argv)
"perf report [<options>]",
NULL
};
+ const char *tasks_stat;
struct report report = {
.tool = {
.sample = process_sample_event,
@@ -1189,7 +1219,8 @@ int cmd_report(int argc, const char **argv)
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_BOOLEAN(0, "stats", &report.stats_mode, "Display event stats"),
- OPT_BOOLEAN(0, "tasks", &report.tasks_mode, "Display recorded tasks"),
+ OPT_STRING_OPTARG_SET(0, "tasks", &tasks_stat, &report.tasks_mode,
+ "ud", "Display recorded tasks", "(none)"),
OPT_BOOLEAN(0, "mmaps", &report.mmaps_mode, "Display recorded tasks memory maps"),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
@@ -1341,6 +1372,14 @@ int cmd_report(int argc, const char **argv)
if (report.mmaps_mode)
report.tasks_mode = true;
+ if (report.tasks_mode) {
+ if (!strcmp(tasks_stat, "ud")) {
+ report.tasks_stat = TASKS_STAT__USER_DATA;
+ /* force --no-children */
+ symbol_conf.cumulate_callchain = false;
+ }
+ }
+
if (quiet)
perf_quiet_option();
--
2.13.6
next prev parent reply other threads:[~2018-01-24 11:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 11:51 [RFC 00/21] perf tools: Add perf_evsel__is_sample_bit function Jiri Olsa
2018-01-24 11:51 ` [PATCH 01/21] " Jiri Olsa
2018-01-24 11:51 ` [PATCH 02/21] perf tools: Add perf_sample__process function Jiri Olsa
2018-01-24 11:51 ` [PATCH 03/21] perf tools: Add callchain__printf for pure callchain dump Jiri Olsa
2018-01-24 11:51 ` [PATCH 04/21] perf tools: Add perf_sample__copy|free functions Jiri Olsa
2018-01-24 11:51 ` [PATCH 05/21] perf: Add TIF_PERF_USER_DATA bit Jiri Olsa
2018-01-24 11:51 ` [PATCH 06/21] perf: Add PERF_RECORD_USER_DATA event processing Jiri Olsa
2018-01-24 11:51 ` [PATCH 07/21] perf: Add PERF_SAMPLE_USER_DATA_ID sample type Jiri Olsa
2018-01-24 11:51 ` [PATCH 08/21] perf: Add PERF_SAMPLE_CALLCHAIN to user data event Jiri Olsa
2018-01-24 11:51 ` [PATCH 09/21] perf: Export running sample length values through debugfs Jiri Olsa
2018-01-24 11:51 ` [PATCH 10/21] perf tools: Sync perf_event.h uapi header Jiri Olsa
2018-01-24 11:51 ` [PATCH 11/21] perf tools: Add perf_sample__parse function Jiri Olsa
2018-01-24 11:51 ` [PATCH 12/21] perf tools: Add struct parse_args arg to perf_sample__parse Jiri Olsa
2018-01-24 11:51 ` [PATCH 13/21] perf tools: Add support to parse user data event Jiri Olsa
2018-01-24 11:51 ` [PATCH 14/21] perf tools: Add support to dump user data event info Jiri Olsa
2018-01-24 11:51 ` [PATCH 15/21] perf report: Add delayed user data event processing Jiri Olsa
2018-01-24 11:51 ` [PATCH 16/21] perf record: Enable delayed user data events Jiri Olsa
2018-01-24 11:51 ` [PATCH 17/21] perf script: Add support to display " Jiri Olsa
2018-01-24 11:51 ` [PATCH 18/21] perf script: Add support to display user data ID Jiri Olsa
2018-01-24 11:51 ` [PATCH 19/21] perf script: Display USER_DATA misc char for sample Jiri Olsa
2018-01-24 11:51 ` [PATCH 20/21] perf report: Add user data processing stats Jiri Olsa
2018-01-24 11:51 ` Jiri Olsa [this message]
2018-01-24 12:11 ` [RFC 00/21] perf tools: Add user data delayed processing 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=20180124115143.14322-22-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.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.