]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
perf stat: Support --all-kernel/--all-user
authorJin Yao <yao.jin@linux.intel.com>
Fri, 11 Oct 2019 05:05:45 +0000 (13:05 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 15 Oct 2019 11:39:42 +0000 (08:39 -0300)
'perf record' has supported --all-kernel / --all-user to configure all
used events to run in kernel space or run in user space. But 'perf stat'
doesn't support these options.

It would be useful to support these options in 'perf stat' too to keep
the same semantics available in both tools.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20191011050545.3899-1-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-stat.txt
tools/perf/builtin-stat.c
tools/perf/util/stat.c
tools/perf/util/stat.h

index 930c51c01201a8230fff0c28d5e17e15822f5e83..a9af4e440e80897cdb51126791f3ee7cf2ee3d8b 100644 (file)
@@ -323,6 +323,12 @@ The output is SMI cycles%, equals to (aperf - unhalted core cycles) / aperf
 
 Users who wants to get the actual value can apply --no-metric-only.
 
+--all-kernel::
+Configure all used events to run in kernel space.
+
+--all-user::
+Configure all used events to run in user space.
+
 EXAMPLES
 --------
 
index 468fc49420ce1848ba54616f9ee548c52c845524..c88d4e1184092942c814c5f802fd5870324840f4 100644 (file)
@@ -803,6 +803,12 @@ static struct option stat_options[] = {
        OPT_CALLBACK('M', "metrics", &evsel_list, "metric/metric group list",
                     "monitor specified metrics or metric groups (separated by ,)",
                     parse_metric_groups),
+       OPT_BOOLEAN_FLAG(0, "all-kernel", &stat_config.all_kernel,
+                        "Configure all used events to run in kernel space.",
+                        PARSE_OPT_EXCLUSIVE),
+       OPT_BOOLEAN_FLAG(0, "all-user", &stat_config.all_user,
+                        "Configure all used events to run in user space.",
+                        PARSE_OPT_EXCLUSIVE),
        OPT_END()
 };
 
index ebdd130557fb8e2ae6257bcfda8ac1de74ec197d..6822e4ffe22446b8d94a25afca5cded6b5a5abc6 100644 (file)
@@ -490,6 +490,16 @@ int create_perf_stat_counter(struct evsel *evsel,
        if (config->identifier)
                attr->sample_type = PERF_SAMPLE_IDENTIFIER;
 
+       if (config->all_user) {
+               attr->exclude_kernel = 1;
+               attr->exclude_user   = 0;
+       }
+
+       if (config->all_kernel) {
+               attr->exclude_kernel = 0;
+               attr->exclude_user   = 1;
+       }
+
        /*
         * Disabling all counters initially, they will be enabled
         * either manually by us or by kernel via enable_on_exec
index edbeb2f63e8dfb781ba79bbb2a3e298db17d54f7..081c4a5113c65362fc99fd4c4b6bb6548ff1474d 100644 (file)
@@ -106,6 +106,8 @@ struct perf_stat_config {
        bool                     big_num;
        bool                     no_merge;
        bool                     walltime_run_table;
+       bool                     all_kernel;
+       bool                     all_user;
        FILE                    *output;
        unsigned int             interval;
        unsigned int             timeout;