From: tip-bot for Namhyung Kim <namhyung.kim@lge.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
mingo@redhat.com, hpa@zytor.com, mingo@kernel.org,
a.p.zijlstra@chello.nl, namhyung.kim@lge.com, namhyung@gmail.com,
dsahern@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf stat: Convert to struct perf_target
Date: Thu, 10 May 2012 23:28:48 -0700 [thread overview]
Message-ID: <tip-20f946b4a49dfd89c1c4ddeb55c0632893332674@git.kernel.org> (raw)
In-Reply-To: <1335417327-11796-3-git-send-email-namhyung.kim@lge.com>
Commit-ID: 20f946b4a49dfd89c1c4ddeb55c0632893332674
Gitweb: http://git.kernel.org/tip/20f946b4a49dfd89c1c4ddeb55c0632893332674
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Thu, 26 Apr 2012 14:15:16 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 2 May 2012 15:19:17 -0300
perf stat: Convert to struct perf_target
Use struct perf_target as it is introduced by previous patch.
This is a preparation of further changes.
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1335417327-11796-3-git-send-email-namhyung.kim@lge.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-stat.c | 47 +++++++++++++++++++++-----------------------
1 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index dde9e17..1ca767d 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -175,22 +175,19 @@ static struct perf_event_attr very_very_detailed_attrs[] = {
static struct perf_evlist *evsel_list;
-static bool system_wide = false;
-static int run_idx = 0;
+static struct perf_target target;
+static int run_idx = 0;
static int run_count = 1;
static bool no_inherit = false;
static bool scale = true;
static bool no_aggr = false;
-static const char *target_pid;
-static const char *target_tid;
static pid_t child_pid = -1;
static bool null_run = false;
static int detailed_run = 0;
static bool sync_run = false;
static bool big_num = true;
static int big_num_opt = -1;
-static const char *cpu_list;
static const char *csv_sep = NULL;
static bool csv_output = false;
static bool group = false;
@@ -293,10 +290,10 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
attr->inherit = !no_inherit;
- if (system_wide)
+ if (target.system_wide)
return perf_evsel__open_per_cpu(evsel, evsel_list->cpus,
group, group_fd);
- if (!target_pid && !target_tid && (!group || evsel == first)) {
+ if (!target.pid && !target.tid && (!group || evsel == first)) {
attr->disabled = 1;
attr->enable_on_exec = 1;
}
@@ -446,7 +443,7 @@ static int run_perf_stat(int argc __used, const char **argv)
exit(-1);
}
- if (!target_tid && !target_pid && !system_wide)
+ if (!target.tid && !target.pid && !target.system_wide)
evsel_list->threads->map[0] = child_pid;
/*
@@ -476,7 +473,7 @@ static int run_perf_stat(int argc __used, const char **argv)
error("You may not have permission to collect %sstats.\n"
"\t Consider tweaking"
" /proc/sys/kernel/perf_event_paranoid or running as root.",
- system_wide ? "system-wide " : "");
+ target.system_wide ? "system-wide " : "");
} else {
error("open_counter returned with %d (%s). "
"/bin/dmesg may provide additional information.\n",
@@ -968,14 +965,14 @@ static void print_stat(int argc, const char **argv)
if (!csv_output) {
fprintf(output, "\n");
fprintf(output, " Performance counter stats for ");
- if (!target_pid && !target_tid) {
+ if (!target.pid && !target.tid) {
fprintf(output, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
fprintf(output, " %s", argv[i]);
- } else if (target_pid)
- fprintf(output, "process id \'%s", target_pid);
+ } else if (target.pid)
+ fprintf(output, "process id \'%s", target.pid);
else
- fprintf(output, "thread id \'%s", target_tid);
+ fprintf(output, "thread id \'%s", target.tid);
fprintf(output, "\'");
if (run_count > 1)
@@ -1049,11 +1046,11 @@ static const struct option options[] = {
"event filter", parse_filter),
OPT_BOOLEAN('i', "no-inherit", &no_inherit,
"child tasks do not inherit counters"),
- OPT_STRING('p', "pid", &target_pid, "pid",
+ OPT_STRING('p', "pid", &target.pid, "pid",
"stat events on existing process id"),
- OPT_STRING('t', "tid", &target_tid, "tid",
+ OPT_STRING('t', "tid", &target.tid, "tid",
"stat events on existing thread id"),
- OPT_BOOLEAN('a', "all-cpus", &system_wide,
+ OPT_BOOLEAN('a', "all-cpus", &target.system_wide,
"system-wide collection from all CPUs"),
OPT_BOOLEAN('g', "group", &group,
"put the counters into a counter group"),
@@ -1072,7 +1069,7 @@ static const struct option options[] = {
OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL,
"print large numbers with thousands\' separators",
stat__set_big_num),
- OPT_STRING('C', "cpu", &cpu_list, "cpu",
+ OPT_STRING('C', "cpu", &target.cpu_list, "cpu",
"list of cpus to monitor in system-wide"),
OPT_BOOLEAN('A', "no-aggr", &no_aggr,
"disable CPU count aggregation"),
@@ -1190,13 +1187,13 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
} else if (big_num_opt == 0) /* User passed --no-big-num */
big_num = false;
- if (!argc && !target_pid && !target_tid)
+ if (!argc && !target.pid && !target.tid)
usage_with_options(stat_usage, options);
if (run_count <= 0)
usage_with_options(stat_usage, options);
/* no_aggr, cgroup are for system-wide only */
- if ((no_aggr || nr_cgroups) && !system_wide) {
+ if ((no_aggr || nr_cgroups) && !target.system_wide) {
fprintf(stderr, "both cgroup and no-aggregation "
"modes only available in system-wide mode\n");
@@ -1206,18 +1203,18 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
if (add_default_attributes())
goto out;
- if (target_pid)
- target_tid = target_pid;
+ if (target.pid)
+ target.tid = target.pid;
- evsel_list->threads = thread_map__new_str(target_pid,
- target_tid, UINT_MAX);
+ evsel_list->threads = thread_map__new_str(target.pid,
+ target.tid, UINT_MAX);
if (evsel_list->threads == NULL) {
pr_err("Problems finding threads of monitor\n");
usage_with_options(stat_usage, options);
}
- if (system_wide)
- evsel_list->cpus = cpu_map__new(cpu_list);
+ if (target.system_wide)
+ evsel_list->cpus = cpu_map__new(target.cpu_list);
else
evsel_list->cpus = cpu_map__dummy_new();
next prev parent reply other threads:[~2012-05-11 6:29 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 5:15 [RFC PATCHSET 00/13] perf tools: Fix cpu/thread map handling v2 Namhyung Kim
2012-04-26 5:15 ` [PATCH 01/13] perf tools: Introduce struct perf_target Namhyung Kim
2012-05-11 6:27 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 02/13] perf stat: Convert to " Namhyung Kim
2012-05-11 6:28 ` tip-bot for Namhyung Kim [this message]
2012-04-26 5:15 ` [PATCH 03/13] perf top: " Namhyung Kim
2012-05-11 6:29 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 04/13] perf tools: Introduce perf_target__validate() helper Namhyung Kim
2012-05-11 6:30 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 05/13] perf tools: Make perf_evlist__create_maps() take struct perf_target Namhyung Kim
2012-05-11 6:31 ` [tip:perf/core] perf evlist: Make create_maps() " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 06/13] perf tools: Check more combinations of PID/TID, UID and CPU switches Namhyung Kim
2012-05-11 6:32 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 07/13] perf evlist: Fix creation of cpu map Namhyung Kim
2012-04-26 15:05 ` David Ahern
2012-04-26 21:12 ` Namhyung Kim
2012-04-26 21:22 ` David Ahern
2012-04-27 0:16 ` Namhyung Kim
2012-04-27 15:08 ` Arnaldo Carvalho de Melo
2012-04-27 15:32 ` David Ahern
2012-04-27 16:00 ` Arnaldo Carvalho de Melo
2012-04-27 16:05 ` David Ahern
2012-04-27 16:09 ` Arnaldo Carvalho de Melo
2012-05-02 18:40 ` Arnaldo Carvalho de Melo
2012-05-04 4:05 ` Namhyung Kim
2012-05-04 13:37 ` Arnaldo Carvalho de Melo
2012-05-04 13:53 ` Namhyung Kim
2012-04-26 5:15 ` [PATCH 08/13] perf target: Split out perf_target handling code Namhyung Kim
2012-05-02 18:30 ` Arnaldo Carvalho de Melo
2012-05-03 14:39 ` Namhyung Kim
2012-05-03 15:27 ` Arnaldo Carvalho de Melo
2012-05-03 15:30 ` Namhyung Kim
2012-05-11 6:33 ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-04-26 5:15 ` [PATCH 09/13] perf target: Introduce perf_target_errno Namhyung Kim
2012-05-02 18:59 ` Arnaldo Carvalho de Melo
2012-05-03 14:47 ` Namhyung Kim
2012-05-03 20:34 ` David Ahern
2012-05-03 20:42 ` Arnaldo Carvalho de Melo
2012-05-03 20:49 ` David Ahern
2012-04-26 5:15 ` [PATCH 10/13] perf target: Introduce perf_target__parse_uid() Namhyung Kim
2012-04-26 5:15 ` [PATCH 11/13] perf tools: Introduce perf_target__strerror() Namhyung Kim
2012-04-26 5:15 ` [PATCH 12/13] perf target: Consolidate target task/cpu checking Namhyung Kim
2012-04-26 5:15 ` [PATCH 13/13] perf stat: Use perf_evlist__create_maps 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=tip-20f946b4a49dfd89c1c4ddeb55c0632893332674@git.kernel.org \
--to=namhyung.kim@lge.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).