From: Ian Rogers <irogers@google.com>
To: Joshua Martinez <joshuamart@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf top: Add cgroup support for perf top (-G)
Date: Wed, 23 Jun 2021 22:56:15 -0700 [thread overview]
Message-ID: <CAP-5=fVmCQHFEHVbzYp_CbO1phhzTB84=2dg-EM1VmDf8NNxWw@mail.gmail.com> (raw)
In-Reply-To: <20210616231829.3735671-1-joshuamart@google.com>
On Wed, Jun 16, 2021 at 4:18 PM Joshua Martinez <joshuamart@google.com> wrote:
>
> Added callback option (-G) to support cgroups for perf top.
> Added condition to make sure -cgroup and --all-cgroups aren't both enabled.
>
> Example:
> $perf top -e cycles -G system.slice/docker-6b95a5eb649c0d671eba3835f0d93973d05a088f3ae8602246bde37affb1ba3e.scope -a --stdio
>
> PerfTop: 3330 irqs/sec kernel:68.2% exact: 0.0% lost: 0/0 drop: 0/11075 [4000Hz cpu-clock], (all, 4 CPUs)
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
> 27.32% [unknown] [.] 0x00007f8ab7b69352
> 11.44% [kernel] [k] 0xffffffff968cd657
> 3.12% [kernel] [k] 0xffffffff96160e96
> 2.63% [kernel] [k] 0xffffffff96160eb0
> 1.96% [kernel] [k] 0xffffffff9615fcf6
> 1.42% [kernel] [k] 0xffffffff964ddfc7
> 1.09% [kernel] [k] 0xffffffff96160e90
> 0.81% [kernel] [k] 0xffffffff96160eb3
> 0.67% [kernel] [k] 0xffffffff9615fec1
> 0.57% [kernel] [k] 0xffffffff961ee1d0
> 0.53% [unknown] [.] 0x00007f8ab7b6666c
> 0.53% [kernel] [k] 0xffffffff96160e64
> 0.52% [kernel] [k] 0xffffffff9616c303
> 0.51% [kernel] [k] 0xffffffffc08e7d50
> ...
>
> Signed-off-by: Joshua Martinez <joshuamart@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks!
Ian
> ---
> tools/perf/Documentation/perf-top.txt | 12 ++++++++++++
> tools/perf/builtin-top.c | 8 ++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
> index bba5ffb05463..9898a32b8d9c 100644
> --- a/tools/perf/Documentation/perf-top.txt
> +++ b/tools/perf/Documentation/perf-top.txt
> @@ -277,6 +277,18 @@ Default is to monitor all CPUS.
> Record events of type PERF_RECORD_NAMESPACES and display it with the
> 'cgroup_id' sort key.
>
> +-G name::
> +--cgroup name::
> +monitor only in the container (cgroup) called "name". This option is available only
> +in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
> +container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
> +can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
> +to first event, second cgroup to second event and so on. It is possible to provide
> +an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
> +corresponding events, i.e., they always refer to events defined earlier on the command
> +line. If the user wants to track multiple events for a specific cgroup, the user can
> +use '-e e1 -e e2 -G foo,foo' or just use '-e e1 -e e2 -G foo'.
> +
> --all-cgroups::
> Record events of type PERF_RECORD_CGROUP and display it with the
> 'cgroup' sort key.
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 69cb3635f5ef..2d570bfe7a56 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -22,6 +22,7 @@
>
> #include "util/annotate.h"
> #include "util/bpf-event.h"
> +#include "util/cgroup.h"
> #include "util/config.h"
> #include "util/color.h"
> #include "util/dso.h"
> @@ -1558,6 +1559,8 @@ int cmd_top(int argc, const char **argv)
> OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"),
> OPT_UINTEGER(0, "num-thread-synthesize", &top.nr_threads_synthesize,
> "number of thread to run event synthesize"),
> + OPT_CALLBACK('G', "cgroup", &top.evlist, "name",
> + "monitor event in cgroup name only", parse_cgroups),
> OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces,
> "Record namespaces events"),
> OPT_BOOLEAN(0, "all-cgroups", &opts->record_cgroup,
> @@ -1646,6 +1649,11 @@ int cmd_top(int argc, const char **argv)
> goto out_delete_evlist;
> }
>
> + if (nr_cgroups > 0 && opts->record_cgroup) {
> + pr_err("--cgroup and --all-cgroups cannot be used together\n");
> + goto out_delete_evlist;
> + }
> +
> if (opts->branch_stack && callchain_param.enabled)
> symbol_conf.show_branchflag_count = true;
>
> --
> 2.32.0.272.g935e593368-goog
>
prev parent reply other threads:[~2021-06-24 5:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 23:18 [PATCH] perf top: Add cgroup support for perf top (-G) Joshua Martinez
2021-06-24 5:56 ` Ian Rogers [this message]
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='CAP-5=fVmCQHFEHVbzYp_CbO1phhzTB84=2dg-EM1VmDf8NNxWw@mail.gmail.com' \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=joshuamart@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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 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).