linux-kernel.vger.kernel.org archive mirror
 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 <peterz@infradead.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Ian Rogers <irogers@google.com>
Subject: Re: [PATCH] perf record: Synthesize cgroup events only if needed
Date: Fri, 27 Nov 2020 16:45:57 +0100	[thread overview]
Message-ID: <20201127154557.GB2729821@krava> (raw)
In-Reply-To: <20201127054356.405481-1-namhyung@kernel.org>

On Fri, Nov 27, 2020 at 02:43:56PM +0900, Namhyung Kim wrote:
> It didn't check the tool->cgroup_events bit which is set when
> the --all-cgroups option is given.  Without it, samples will not have
> cgroup info so no reason to synthesize.
> 
> We can check the PERF_RECORD_CGROUP records after running perf record
> *WITHOUT* the --all-cgroups option:
> 
> Before:
>   $ perf report -D | grep CGROUP
>   0 0 0x8430 [0x38]: PERF_RECORD_CGROUP cgroup: 1 /
>           CGROUP events:          1
>           CGROUP events:          0
>           CGROUP events:          0
> 
> After:
>   $ perf report -D | grep CGROUP
>           CGROUP events:          0
>           CGROUP events:          0
>           CGROUP events:          0
> 
> Fixes: 8fb4b67939e16 ("perf record: Add --all-cgroups option")
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/synthetic-events.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index 8a23391558cf..d9c624377da7 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -563,6 +563,9 @@ int perf_event__synthesize_cgroups(struct perf_tool *tool,
>  	char cgrp_root[PATH_MAX];
>  	size_t mount_len;  /* length of mount point in the path */
>  
> +	if (!tool || !tool->cgroup_events)
> +		return 0;

can !tool actually happen here? or it's just being extra cautious

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> +
>  	if (cgroupfs_find_mountpoint(cgrp_root, PATH_MAX, "perf_event") < 0) {
>  		pr_debug("cannot find cgroup mount point\n");
>  		return -1;
> -- 
> 2.29.2.454.gaff20da3a2-goog
> 


  reply	other threads:[~2020-11-27 15:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27  5:43 [PATCH] perf record: Synthesize cgroup events only if needed Namhyung Kim
2020-11-27 15:45 ` Jiri Olsa [this message]
2020-11-27 17:30   ` Arnaldo Carvalho de Melo
2020-11-30 13:27     ` Namhyung Kim
2020-11-30 13:26   ` 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=20201127154557.GB2729821@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --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 \
    --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).