From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Stephane Eranian <eranian@google.com>,
Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>
Subject: Re: [PATCH 2/5] perf stat: Add --for-each-cgroup option
Date: Tue, 22 Sep 2020 23:40:33 +0200 [thread overview]
Message-ID: <20200922214033.GD2893484@krava> (raw)
In-Reply-To: <20200921094610.83736-3-namhyung@kernel.org>
On Mon, Sep 21, 2020 at 06:46:07PM +0900, Namhyung Kim wrote:
SNIP
> +int evlist__expand_cgroup(struct evlist *evlist, const char *str)
> +{
> + struct evlist *orig_list, *tmp_list;
> + struct evsel *pos, *evsel, *leader;
> + struct cgroup *cgrp = NULL;
> + const char *p, *e, *eos = str + strlen(str);
> + int ret = -1;
> +
> + if (evlist->core.nr_entries == 0) {
> + fprintf(stderr, "must define events before cgroups\n");
> + return -EINVAL;
> + }
> +
> + orig_list = evlist__new();
> + tmp_list = evlist__new();
> + if (orig_list == NULL || tmp_list == NULL) {
> + fprintf(stderr, "memory allocation failed\n");
> + return -ENOMEM;
> + }
> +
> + /* save original events and init evlist */
> + perf_evlist__splice_list_tail(orig_list, &evlist->core.entries);
> + evlist->core.nr_entries = 0;
> +
> + for (;;) {
> + p = strchr(str, ',');
> + e = p ? p : eos;
> +
> + /* allow empty cgroups, i.e., skip */
> + if (e - str) {
> + /* termination added */
> + char *name = strndup(str, e - str);
> + if (!name)
> + goto out_err;
> +
> + cgrp = cgroup__new(name);
> + free(name);
> + if (cgrp == NULL)
> + goto out_err;
> + } else {
> + cgrp = NULL;
> + }
> +
> + leader = NULL;
> + evlist__for_each_entry(orig_list, pos) {
> + evsel = evsel__clone(pos);
> + if (evsel == NULL)
> + goto out_err;
> +
> + cgroup__put(evsel->cgrp);
> + evsel->cgrp = cgroup__get(cgrp);
> +
> + if (evsel__is_group_leader(pos))
> + leader = evsel;
> + evsel->leader = leader;
hum, will this work if there's standalone event after group? like:
{cycles,instructions},cache-misses
cache-misses will get cycles as group leader no?
jirka
> +
> + evlist__add(tmp_list, evsel);
> + }
> + /* cgroup__new() has a refcount, release it here */
> + cgroup__put(cgrp);
> + nr_cgroups++;
SNIP
next prev parent reply other threads:[~2020-09-22 21:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 9:46 [PATCHSET v3 0/5] perf stat: Expand events for each cgroup Namhyung Kim
2020-09-21 9:46 ` [PATCH 1/5] perf evsel: Add evsel__clone() function Namhyung Kim
2020-09-21 9:46 ` [PATCH 2/5] perf stat: Add --for-each-cgroup option Namhyung Kim
2020-09-22 21:40 ` Jiri Olsa [this message]
2020-09-22 22:51 ` Namhyung Kim
2020-09-23 9:30 ` Jiri Olsa
2020-09-22 21:52 ` Stephane Eranian
2020-09-22 22:55 ` Namhyung Kim
2020-09-22 22:57 ` Namhyung Kim
2020-09-21 9:46 ` [PATCH 3/5] perf tools: Copy metric events properly when expand cgroups Namhyung Kim
2020-09-22 21:29 ` Jiri Olsa
2020-09-22 22:46 ` Namhyung Kim
2020-09-21 9:46 ` [PATCH 4/5] perf tools: Allow creation of cgroup without open Namhyung Kim
2020-09-21 9:46 ` [PATCH 5/5] perf test: Add expand cgroup event test Namhyung Kim
-- strict thread matches above, loose matches on Subject: below --
2020-09-23 1:59 [PATCHSET v4 0/5] perf stat: Expand events for each cgroup Namhyung Kim
2020-09-23 1:59 ` [PATCH 2/5] perf stat: Add --for-each-cgroup option Namhyung Kim
2020-09-24 12:44 [PATCHSET v5 0/5] perf stat: Expand events for each cgroup Namhyung Kim
2020-09-24 12:44 ` [PATCH 2/5] perf stat: Add --for-each-cgroup option 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=20200922214033.GD2893484@krava \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox