public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com,
	alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org,
	ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com,
	like.xu@linux.intel.com
Subject: Re: [PATCH v3] perf parse-events: Set exclude_guest=1 for user-space counting
Date: Fri, 14 Aug 2020 09:47:22 -0300	[thread overview]
Message-ID: <20200814124722.GG13995@kernel.org> (raw)
In-Reply-To: <20200814012120.16647-1-yao.jin@linux.intel.com>

Em Fri, Aug 14, 2020 at 09:21:20AM +0800, Jin Yao escreveu:
> Currently if we run 'perf record -e cycles:u', exclude_guest=0.
> 
> But it doesn't make sense in most cases that we request for
> user-space counting but we also get the guest report.
> 
> Of course, we also need to consider perf kvm usage case that
> authorized perf users on the host may only want to count guest
> user space events. For example,
> 
> perf kvm --guest record -e cycles:u

Ok, probably this works, but what if I want to record guest user samples
without using 'perf kvm'?

Can we have a 'U' modifier, perhaps, for that?

I.e.

perf record -e cycles:uU would not set exclude_host not exclude_guest,
cycles:u excludes guest user, cycles:U excludes host user, would that be
possible?

Anyway, I think that with what we have, your patch makes sense, having a
way to, without using 'perf kvm' still be able to sample the guest can
be done on top. of this.

Xu, can we get your Reviewed-by if this addresses your concerns?

- Arnaldo
 
> When we have 'exclude_guest=1' for perf kvm usage, we may get
> nothing from guest events.
> 
> To keep perf semantics consistent and clear, this patch sets
> exclude_guest=1 for user-space counting but except for perf
> kvm usage.
> 
> Before:
>   perf record -e cycles:u ./div
>   perf evlist -v
>   cycles:u: ..., exclude_kernel: 1, exclude_hv: 1, ...
> 
> After:
>   perf record -e cycles:u ./div
>   perf evlist -v
>   cycles:u: ..., exclude_kernel: 1, exclude_hv: 1,  exclude_guest: 1, ...
> 
> Before:
>   perf kvm --guest record -e cycles:u -vvv
> 
> perf_event_attr:
>   size                             120
>   { sample_period, sample_freq }   4000
>   sample_type                      IP|TID|TIME|ID|CPU|PERIOD
>   read_format                      ID
>   disabled                         1
>   inherit                          1
>   exclude_kernel                   1
>   exclude_hv                       1
>   freq                             1
>   sample_id_all                    1
> 
> After:
>   perf kvm --guest record -e cycles:u -vvv
> 
> perf_event_attr:
>   size                             120
>   { sample_period, sample_freq }   4000
>   sample_type                      IP|TID|TIME|ID|CPU|PERIOD
>   read_format                      ID
>   disabled                         1
>   inherit                          1
>   exclude_kernel                   1
>   exclude_hv                       1
>   freq                             1
>   sample_id_all                    1
> 
> For Before/After, exclude_guest are both 0 for perf kvm usage.
> 
> perf test 6
>  6: Parse event definition strings             : Ok
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  v3:
>  ---
>  For perf kvm, if we have 'exclude_guest=1', we can't get guest
>  events. So we don't set 'exclude_guest=1' for perf kvm.
> 
>  v2:
>  ---
>  Fix the 'perf test 6' failure.
> 
>  tools/perf/tests/parse-events.c | 4 ++--
>  tools/perf/util/parse-events.c  | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index 7f9f87a470c3..aae0fd9045c1 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -719,7 +719,7 @@ static int test__group2(struct evlist *evlist)
>  	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
>  	TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
>  	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
> -	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
> +	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
>  	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
>  	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
>  	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
> @@ -842,7 +842,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)
>  	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
>  	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
>  	TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
> -	TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
> +	TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
>  	TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
>  	TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
>  	TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 9f7260e69113..ff4c23d2a0f3 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -37,6 +37,7 @@
>  #include "util/evsel_config.h"
>  #include "util/event.h"
>  #include "util/pfm.h"
> +#include "perf.h"
>  
>  #define MAX_NAME_LEN 100
>  
> @@ -1794,6 +1795,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
>  		if (*str == 'u') {
>  			if (!exclude)
>  				exclude = eu = ek = eh = 1;
> +			if (!exclude_GH && !perf_guest)
> +				eG = 1;
>  			eu = 0;
>  		} else if (*str == 'k') {
>  			if (!exclude)
> -- 
> 2.17.1
> 

-- 

- Arnaldo

  reply	other threads:[~2020-08-14 12:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14  1:21 [PATCH v3] perf parse-events: Set exclude_guest=1 for user-space counting Jin Yao
2020-08-14 12:47 ` Arnaldo Carvalho de Melo [this message]
2020-08-17  2:32   ` Jin, Yao
2020-08-19  3:05     ` Like Xu
2020-08-25  7:54       ` Jin, Yao
2020-08-25 16:42         ` Arnaldo Carvalho de Melo

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=20200814124722.GG13995@kernel.org \
    --to=acme@kernel.org \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=like.xu@linux.intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@intel.com \
    --cc=yao.jin@linux.intel.com \
    /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