Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3488345pxj; Tue, 1 Jun 2021 06:31:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLXzYkKcNVa6JxTYmgjxBmiofgVNIDOKNIqp2gtD9hHWkWI9LGpBAMcPgy4bOtvuZ7SHEk X-Received: by 2002:a5d:8516:: with SMTP id q22mr21584066ion.173.1622554319023; Tue, 01 Jun 2021 06:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622554319; cv=none; d=google.com; s=arc-20160816; b=G/X22t++mn3KUacxd9JaRvmEBb4hJfFWqueHUqr9oa33+eGJkQkX1IyTkE3m2PtGb+ g1KsASCfzEX7FTFuC1+ml2DbRikYf2MlD8FdjpXNs7uerwLcTz/GtGtuQfsHsjEKGIbt GLLKDhy+HFk0YPkSeXm8tCvff2/QhCkQsr2dAHKD7dUFegzJa3xtP69F9Xy+YDOk+3zO LG8CigmRb9OUj0lUSnr092h+OveqLSGOcIQoG45dFqRdXXYPbNVdBFY13QaxqEZDqXkr Xu/T1kjZGOaNfLcJE6DQ8zANQInXeEpyDh8uSkNFs2wy0V9iqhFYbTmdVaYXp3s2T33o 5A4g== 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=bZub8Yydxw1PvaBBdtjWCYrH3INbyY9QDDBpqwrPcEw=; b=VMACSN3PBrpAeoJb69zMt4PAhb6o3bafxUtmPS1XeYw8XKT/1UMwypE5bhDcZJWsKG LQ0FBb7+iIXSi+aSmgaTVN3TJMh/pKwGx/UoTlQz3/h/S4BKcP/VZG70rthXaMgKyINp iGf//mXfgXvE8m/DAcnypJACc03hZXY1BObLiCNG+pxq6yvbigaYAsqAG5N6VleU5gJD rUO2NHOOqV/Hta7p1ekY1o4tBnZQcYxJRpHRaRsNCjf3TxengH+S/WZFSGMtJHR1Z8TD PsZtzxUdAgidXRWlsXDjZPtqbf1rWMLW15uu1OP4zWaBVNLdFzJZTueLOmfefje5Rrha PoOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M1KENGQC; 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 n8si17304151jam.34.2021.06.01.06.31.45; Tue, 01 Jun 2021 06:31: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=k20201202 header.b=M1KENGQC; 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 S234016AbhFANcP (ORCPT + 99 others); Tue, 1 Jun 2021 09:32:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234001AbhFANcJ (ORCPT ); Tue, 1 Jun 2021 09:32:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 31FCA613AB; Tue, 1 Jun 2021 13:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622554228; bh=u3ILEWTeiysuA4cfXkP54DqJof+Ly4Pxun8uzn4hxys=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M1KENGQC9GCnydeaUAPkpZ0e7xBL8BNiVn+zyL0/MQJDzedIqI18QjMGYEsxSkgKd rJQd7RHi48RHwNttJUwWNX/fNTSGrzBARDJJZ0MD//nPShggrDHEdDz5d5Wq5XvKz4 3rDmcEbrIPqFt66IHdhhXKpGyumEBPSVNgmG3Rm2Wm54Iaxw6DN0Wb7v8ddg9RXFyh fmXntPOLCG5OUW27JXDgArRoUXSdZe9XbHuVzal33xnvdBhLx+BTI7pohCTklyG4K7 zKei7vpv5wJ9XG74VJLRiu1T5vWJU98BXXD05lyrsZCCESv/e4Qn+wWMoc44WqzVIK xhXZYshmuNN4Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 695E74011C; Tue, 1 Jun 2021 10:30:25 -0300 (-03) Date: Tue, 1 Jun 2021 10:30:25 -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: <20210527182835.1634339-1-namhyung@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. - Arnaldo > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 4a3cd1b5bb33..2462584d0ee5 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1217,7 +1217,7 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts, > attr->namespaces = track; > > if (opts->record_cgroup) { > - attr->cgroup = track && !perf_missing_features.cgroup; > + attr->cgroup = track; > evsel__set_sample_bit(evsel, CGROUP); > } > > @@ -1933,10 +1933,6 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > perf_missing_features.data_page_size = true; > pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n"); > goto out_close; > - } else if (!perf_missing_features.cgroup && evsel->core.attr.cgroup) { > - perf_missing_features.cgroup = true; > - pr_debug2_peo("Kernel has no cgroup sampling support, bailing out\n"); > - goto out_close; > } else if (!perf_missing_features.branch_hw_idx && > (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX)) { > perf_missing_features.branch_hw_idx = true; > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h > index 75cf5dbfe208..fecf13c0e4da 100644 > --- a/tools/perf/util/evsel.h > +++ b/tools/perf/util/evsel.h > @@ -168,7 +168,6 @@ struct perf_missing_features { > bool bpf; > bool aux_output; > bool branch_hw_idx; > - bool cgroup; > bool data_page_size; > bool code_page_size; > bool weight_struct; > -- > 2.32.0.rc0.204.g9fa02ecfa5-goog > -- - Arnaldo