Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp368774pxa; Fri, 14 Aug 2020 06:37:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1iQQWAyjDtMdk/JJZgsuWBAFil69KVj5VKyS87/ZFZavv1pzlaJvRoa5TSU6Bi7Aur5p8 X-Received: by 2002:a17:907:4064:: with SMTP id nl4mr2457286ejb.342.1597412279728; Fri, 14 Aug 2020 06:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412279; cv=none; d=google.com; s=arc-20160816; b=T2srv61T2AjGcXFEa1eQpKgtca1kgp1Ct4i/8fGdaEv+YjORluYCNcO9WAU86PGluI kYbXZvw6Osi2qOr/TyH9+VPe1toSmcN8mPIzQC8K2YoFGj4Iml8Jz/DrWslaFUiQg2rm NX4kZxrwruZNSeYRURJiKkzLtZiDzUUcbJanFCelhQQMF8BPDNNUTi0wSlMgLXtQ4Uy/ 6rpGKjLOnCaF81ttHTYMFzxkPDBL28b5jWawQVH0KzNHmEdEjZyoXDXccTVfNTCVEHL3 Vamio6MZaYcEXDUCEZ4ytvEmbq/JfAUpXCmAPFJ2ernMR8w4yEWUkVKi0CwbulfpVM3t zPNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dazhJ11T0mnp6/A++atFb2XsOLa8D+OiLtYHHhx/vr0=; b=EVhtHHcfXI7XniI2+702344uvG8GISSMr5SjOexTJaXrJwRK1UANwuAEqleARXxhFQ dkjvsm8i6eWqzo3yN250LnEMMNTXoGzviFOepXajy1wN0In7KWru1ruPkPC1tf8Iwb2Z p+v4uE6XS3IVnzAJ0YZDWAJFXYUUC6n+3HRqES2DqrW4bukM+aJgeN3tS8fX3Pb1tDYH Ds4mGhEFwUc7kNHg/HaYHqou/LabPcyUZ1lKdpekm7PiLGYYQwN8/CKTc93E8FTWbhfT 6TDpNEbYtO7erwW6WAD+/zQ77C/OB8ZprXg0fGW7PIPz60CqOMAeKjoWzCkrRpGUPeQL WRYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ceSENNIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si5254607eds.349.2020.08.14.06.37.36; Fri, 14 Aug 2020 06:37:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ceSENNIJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727081AbgHNMr0 (ORCPT + 99 others); Fri, 14 Aug 2020 08:47:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:53700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726209AbgHNMr0 (ORCPT ); Fri, 14 Aug 2020 08:47:26 -0400 Received: from quaco.ghostprotocols.net (177.207.136.251.dynamic.adsl.gvt.net.br [177.207.136.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D08E62087D; Fri, 14 Aug 2020 12:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597409245; bh=LWfEJo2yv51g1xPFjTHclS9PxlauBHm3nptze07V1nM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ceSENNIJg5elCC7plusVsTqf2rls5rYhUd9IVT966zuFXdNwGT+inVwKX9s/+Laty n4QLvW0aDtE4VeSxhmomfi9KMiVyS5P0n6teNR5H0uek57Llg7RcbnPE2+HrWd8L4J ACCBn/wcezUulZr8HZ+4uvZlvSmmGq8YVdvsIWiA= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id B720540D3D; Fri, 14 Aug 2020 09:47:22 -0300 (-03) Date: Fri, 14 Aug 2020 09:47:22 -0300 From: Arnaldo Carvalho de Melo To: Jin Yao 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 Message-ID: <20200814124722.GG13995@kernel.org> References: <20200814012120.16647-1-yao.jin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200814012120.16647-1-yao.jin@linux.intel.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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