Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3491940pxj; Tue, 1 Jun 2021 06:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZatUPdzsutlH2o/htM6Jvni5VG+uZgFZIHNkN0PyeJ71e4+LoOl9C5G8rn+N93NKgZuW2 X-Received: by 2002:a17:907:1c25:: with SMTP id nc37mr11853994ejc.300.1622554590439; Tue, 01 Jun 2021 06:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622554590; cv=none; d=google.com; s=arc-20160816; b=HWzlc6dtlXZd1nDpkSCSG7OqPZIqZqW0AnDxIKp8ALLticbh/bDgCghBdz3Ls6OIdQ RxS/QtAyezZkGXSMkjL0/AovckAGYKeVCFv7Er6kWWvD7S144qTu0mYY9r0gkqH6nO6t 4lb3eg2A4ydTNJWkKyCnnT7epQh7us8EuKs2iEnE7XwSMyQBJ5cxM79xd6PEZUi1RCB/ 197dv8bb2jONeHYsKUiu0yNoz9OrnDo+6aqf/qpUN//bAhZNCOUrmmTT0XzCh6M5jzWV XkFLbJsEUI6sqn5iuHEkf8VA3HYYoDBAgd4uWh/LTE2gGaKTZkMLxp8TwGn5IT3p0cKq Qk5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yjI7usMfYxFbRmoP223UJshnBpPDninmCrngqYqVGMw=; b=Mzm4EkpazrgGmhyHIjvtyao0rYfuCeKR2omw2rw7fXRvl+gQRR/dYpjGazpk9MfSm8 A8brlyLWRtjcUlqLIU9C+JkYDmlYFUQDOB6c67ZjctDOo2b7V1sHb2J5/KccnzwbueLW 96Mtms/E/j/pzMCOT/3kPqOuly78AJvQbu7jEelnMUi3GLuqNJVs8k00n181DfQf4Boa Qalzl6/cK+qfEmMi/sc2eyNB0YC6x2itClUP0KF+CaoqBOCqUiBBZbrVoZEXiRbvK1L5 dZzan99hfKrCXiPcnFIiol9xJTu3bBRCwKawt6iuEWa3JgHnjZytREO3iW5+/MvTH7Bv syUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VO5EG9ul; 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 f12si14938853ejl.315.2021.06.01.06.35.48; Tue, 01 Jun 2021 06:36:30 -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=k20201202 header.b=VO5EG9ul; 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 S233981AbhFANgg (ORCPT + 99 others); Tue, 1 Jun 2021 09:36:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:54622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233797AbhFANgf (ORCPT ); Tue, 1 Jun 2021 09:36:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D8B861159; Tue, 1 Jun 2021 13:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622554494; bh=csoc1f4pPPdREvTk3g6EFKsFTV8ISl9/45FduPUi1BE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VO5EG9ul97MoVTLedsST7fxQ3BXlgx768xOE5p1DSWzCskpkzvHrbUhe1REhn11/q Pa8YWU20adH8y7z3r+DQSLXjmdqNB6XkGrcabuVqPZX5c6e5Dy/QzjQnxgNSQ8iJ7z CSRSliBGWh4lr6mThwIt8wC8gAWTt9IQ/4OrrDguEKAxV4GwFefEu6c+9tEUSJOoPD mLJVwvKfpxA15YzhGnvmKNips0S4sDNWz0rsAq14cqFhrZ99dwbx+238d+inALzsav 0u6s92GdyLmdN91LAQu218uINhMnEBMw18EL4DUkVIS9iBBcwDZKM/hpUEw5fuG8Q5 5oOkfW0+9pI5w== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 0965A4011C; Tue, 1 Jun 2021 10:34:52 -0300 (-03) Date: Tue, 1 Jun 2021 10:34:52 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Jiri Olsa , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , LKML , Andi Kleen , Ian Rogers Subject: Re: [PATCH] perf tools: Move probing cgroup sampling support Message-ID: References: <20210527182835.1634339-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jun 01, 2021 at 10:30:25AM -0300, Arnaldo Carvalho de Melo escreveu: > Em Thu, May 27, 2021 at 11:28:35AM -0700, Namhyung Kim escreveu: > > I found that checking cgroup sampling support using the missing > > features doesn't work on old kernels. Because it added both > > attr.cgroup bit and PERF_SAMPLE_CGROUP bit, it needs to check > > whichever comes first (usually the actual event, not dummy). > > > > But it only checks the attr.cgroup bit which is set only in the dummy > > event so cannot detect failtures due the sample bits. Also we don't > > ignore the missing feature and retry, it'd be better checking it with > > the API probing logic. > > > > Signed-off-by: Namhyung Kim > > --- > > tools/perf/builtin-record.c | 6 ++++++ > > tools/perf/util/evsel.c | 6 +----- > > tools/perf/util/evsel.h | 1 - > > tools/perf/util/perf_api_probe.c | 10 ++++++++++ > > tools/perf/util/perf_api_probe.h | 1 + > > 5 files changed, 18 insertions(+), 6 deletions(-) > > > > diff --git a/tools/perf/util/perf_api_probe.c b/tools/perf/util/perf_api_probe.c > > index 829af17a0867..020411682a3c 100644 > > --- a/tools/perf/util/perf_api_probe.c > > +++ b/tools/perf/util/perf_api_probe.c > > @@ -103,6 +103,11 @@ static void perf_probe_build_id(struct evsel *evsel) > > evsel->core.attr.build_id = 1; > > } > > > > +static void perf_probe_cgroup(struct evsel *evsel) > > +{ > > + evsel->core.attr.cgroup = 1; > > +} > > + > > bool perf_can_sample_identifier(void) > > { > > return perf_probe_api(perf_probe_sample_identifier); > > @@ -182,3 +187,8 @@ bool perf_can_record_build_id(void) > > { > > return perf_probe_api(perf_probe_build_id); > > } > > + > > +bool perf_can_record_cgroup(void) > > +{ > > + return perf_probe_api(perf_probe_cgroup); > > +} > > diff --git a/tools/perf/util/perf_api_probe.h b/tools/perf/util/perf_api_probe.h > > index f12ca55f509a..b104168efb15 100644 > > --- a/tools/perf/util/perf_api_probe.h > > +++ b/tools/perf/util/perf_api_probe.h > > @@ -12,5 +12,6 @@ bool perf_can_record_switch_events(void); > > bool perf_can_record_text_poke_events(void); > > bool perf_can_sample_identifier(void); > > bool perf_can_record_build_id(void); > > +bool perf_can_record_cgroup(void); > > > > #endif // __PERF_API_PROBE_H > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > > index bc3dd379eb67..71efe6573ee7 100644 > > --- a/tools/perf/builtin-record.c > > +++ b/tools/perf/builtin-record.c > > @@ -2733,6 +2733,12 @@ int cmd_record(int argc, const char **argv) > > rec->no_buildid = true; > > } > > > > + if (rec->opts.record_cgroup && !perf_can_record_cgroup()) { > > + pr_err("Kernel has no cgroup sampling support.\n"); > > + err = -EINVAL; > > + goto out_opts; > > + } > > + > > if (rec->opts.kcore) > > rec->data.is_dir = true; > > > > The above is perf/urgent material and should fix your issue, right? > > The part below is a separate patch and can be left for later, or maybe > remain in the codebase, as simple tools that use just one evsel and > request a cgroup will continue probing the kernel, etc. I.e. it > shouldn't get in the way for cases with dummies, etc. > > Simple tools then won't have to get that !perf_can_record_cgroup() call. I did it tentatively in my local branch, i.e. removed the removal of the fallback part, thus is just for it to be tested by the containers setup, etc, we can change this before it hits acme/perf/core externally. - Arnaldo