All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Stephane Eranian <eranian@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>, Ian Rogers <irogers@google.com>
Subject: Re: [PATCH 1/4] perf evsel: Add evsel__clone() function
Date: Thu, 10 Sep 2020 10:59:26 +0200	[thread overview]
Message-ID: <20200910085926.GC1627030@krava> (raw)
In-Reply-To: <20200908044228.61197-2-namhyung@kernel.org>

On Tue, Sep 08, 2020 at 01:42:25PM +0900, Namhyung Kim wrote:
> The evsel__clone() is to create an exactly same evsel from same
> attributes.  Note that metric events will be handled by later patch.
> 
> It will be used by perf stat to generate separate events for each
> cgroup.
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/evsel.c | 57 +++++++++++++++++++++++++++++++++++++++++
>  tools/perf/util/evsel.h |  1 +
>  2 files changed, 58 insertions(+)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index fd865002cbbd..4f50f9499973 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -331,6 +331,63 @@ struct evsel *evsel__new_cycles(bool precise)
>  	goto out;
>  }
>  
> +/**
> + * evsel__clone - create a new evsel copied from @orig
> + * @orig: original evsel
> + *
> + * The assumption is that @orig is not configured nor opened yet.
> + * So we only care about the attributes that can be set while it's parsed.
> + */
> +struct evsel *evsel__clone(struct evsel *orig)
> +{
> +	struct evsel *evsel;
> +	struct evsel_config_term *pos, *tmp;
> +
> +	BUG_ON(orig->core.fd);
> +
> +	evsel = evsel__new(&orig->core.attr);
> +	if (evsel == NULL)
> +		return NULL;
> +
> +	*evsel = *orig;

this seems wild ;-) I saw that assumption above,
but I wonder we could add some check or zero/init
the rest of the fields fields

jirka


  reply	other threads:[~2020-09-10  8:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  4:42 [PATCHSET 0/4] perf stat: Add --multiply-cgroup option Namhyung Kim
2020-09-08  4:42 ` [PATCH 1/4] perf evsel: Add evsel__clone() function Namhyung Kim
2020-09-10  8:59   ` Jiri Olsa [this message]
2020-09-10 13:18     ` Namhyung Kim
2020-09-08  4:42 ` [PATCH 2/4] perf stat: Add --multiply-cgroup option Namhyung Kim
2020-09-08  4:42 ` [PATCH 3/4] perf tools: Copy metric events properly when multiply cgroups Namhyung Kim
2020-09-23  9:14   ` [perf tools] 77b66fd551: perf-sanity-tests.'import_perf'_in_python.fail kernel test robot
2020-09-23  9:14     ` kernel test robot
2020-09-24  3:04     ` Namhyung Kim
2020-09-24  3:04       ` Namhyung Kim
2020-09-25 11:55       ` Arnaldo Carvalho de Melo
2020-09-25 11:55         ` Arnaldo Carvalho de Melo
2020-09-08  4:42 ` [PATCH 4/4] perf test: Add multiply cgroup event test Namhyung Kim
2020-09-10  9:15 ` [PATCHSET 0/4] perf stat: Add --multiply-cgroup option Jiri Olsa
2020-09-10 11:10   ` Arnaldo Carvalho de Melo
2020-09-10 13:32     ` Namhyung Kim
2020-09-10 15:57 ` Andi Kleen
2020-09-10 17:11   ` Ian Rogers
2020-09-11  2:54     ` Namhyung Kim
2020-09-11  2:35   ` Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2020-09-16  6:31 [PATCHSET v2 0/4] perf stat: Expand events for each cgroup Namhyung Kim
2020-09-16  6:31 ` [PATCH 1/4] perf evsel: Add evsel__clone() function Namhyung Kim
2020-09-18 13:31   ` Jiri Olsa
2020-09-21  5:44     ` 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=20200910085926.GC1627030@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andi@firstfloor.org \
    --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 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.