Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2139402pxj; Sun, 30 May 2021 15:21:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqnd/ihz9BClrWsERr446AdTuWF2UJ/ro/Wl+7ruQD5fxQTwkVl3GgmgZnMWqg3HsWIN3y X-Received: by 2002:a92:640d:: with SMTP id y13mr14821957ilb.158.1622413261128; Sun, 30 May 2021 15:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622413261; cv=none; d=google.com; s=arc-20160816; b=eu/IdFDBXaT3LxLpk3c1QIAcAySHtXl5V3ZNwmnasGyGCfL6MRqGGAT45vQD9zwJ2P pxtIl+mxmMSOzLMnyvLZ5aw9S18BcJY3L90jNEk3cV9WUVgfNzizDe4Mv6N0XdOzyuFE VR72TKx3pQTM7sQGyqSd8XarUCWOF74ee/r+aAY1DdAMCzuSGzDveMSDwkkLYIyxKuZw uHmixGbPal+tzrUeDubxPgzEVGlW+b+t58tmaTzooGpHq7T1u7mG7isk4c402jbtdTMn Jr8KwIL9LjbMt1hN1y7t69rz89OECbrt8rVCDeySVKMkJPkL9mLXJICne0DoA/iOZ7pi FQRw== 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=GQnT8bnjaGzcDkrzr8sel+XgsVEtNq0qUeLfMEz/0yI=; b=fIBvkvHV+VMGSN3zbmH2LXeD7+DtVOr/fzNGIxj3HNo0g7+FvZvQLnR7wfKd8GhkoU bLhG5Odq/a0KElP3p+jutrmH++E7yuI/+up48gtLlWZG8MDoT2wCxupEY6SevQ6siTuk B8L3NHpiMXs4uwbW44xzeD9WiL+CQq9zcQUtoM6e3whCHJi6jU6Gmm3pAWdBBRc0PwTE 3J1IXPJ/WdxwSagJZqbJosdBR7/hWnMOfSFpxP1NywCyYuMIyf8zbsOGItkjsaUEJ3eY vplyDRUPcn7/MfMxHU52ez4fiOLP2sJ/k+w+1t+TeYr9d4vieRK8L6WEwnhTdtDuMDjh tNQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AVFBXsmU; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si13411683jaj.81.2021.05.30.15.20.48; Sun, 30 May 2021 15:21:01 -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=@redhat.com header.s=mimecast20190719 header.b=AVFBXsmU; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbhE3WQw (ORCPT + 99 others); Sun, 30 May 2021 18:16:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55634 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbhE3WQw (ORCPT ); Sun, 30 May 2021 18:16:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622412913; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GQnT8bnjaGzcDkrzr8sel+XgsVEtNq0qUeLfMEz/0yI=; b=AVFBXsmUg0BolnRM4xDZV+z5QAlj2K9HmLkHqXHTbbbdxujAlSOa9Ue6np1pYNtM5GQ5/1 owpVit+jDjB1NHkKI7bZqdJwWIV1UaaZfsnBST33C4ZkbSxMnWKuRlhbUzVzEafBUMPAFQ jGMsWHpS9DikDh7eRSa8s6/TmghhTXU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-aVtQwBKJMq6At3cW0sjyCQ-1; Sun, 30 May 2021 18:15:09 -0400 X-MC-Unique: aVtQwBKJMq6At3cW0sjyCQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 219D6107ACCA; Sun, 30 May 2021 22:15:08 +0000 (UTC) Received: from krava (unknown [10.40.192.48]) by smtp.corp.redhat.com (Postfix) with SMTP id 3197810016FE; Sun, 30 May 2021 22:15:06 +0000 (UTC) Date: Mon, 31 May 2021 00:15:05 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 27, 2021 at 11:28:35AM -0700, Namhyung Kim wrote: > 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 Acked-by: Jiri Olsa thanks, jirka > --- > 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/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; > > 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; > 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 > -- > 2.32.0.rc0.204.g9fa02ecfa5-goog >