Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp46402pxb; Tue, 31 Aug 2021 14:47:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ6ThjrMT5CJRyy6lw1AREa+hPWKcC+R2cJtG5pinKb3xzJ7nw62ZWh6mIBwuZZHoug/X3 X-Received: by 2002:a05:6638:271e:: with SMTP id m30mr4777138jav.90.1630446454897; Tue, 31 Aug 2021 14:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630446454; cv=none; d=google.com; s=arc-20160816; b=KkqrBzLI1FxDF7JxfiCKvsdOT1+tbci7CKV6iJ7GrvJwWcqzntc2l2LgRPzG8Dfsee LvvRDby477lsyPdYJCCmGX1NtbXrfZF0mb8rsxz/lYUzfmg88N8JoYS3/yTG61Eq4+Ia jUKaM89ycZUFUZnPaav3x6mC7vez+hYjcF2FCydmQzz8wd6c9lpclYOvbqj6pitX7bRx btxgJlqZ9Wj0PpMceSnnV4+UFt+V+FiqNtd6JTMX0fHiLhKCfn0YTH6b92oeYaHLONEz GP21YEW9lYMTuXEK1l9V9sqLczZYSA5n7SKdMGPNCdBXDsgXP870xzfmDSxueu5n5swu OmCA== 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=0TF266S8VYeL4BJwRuiM35nEHkmTe9uiVMHMIk1jDjg=; b=XBzeJO3zkzv4Cb6ruZa/DKBxBsa5KRiT1QcWgNhtMVpWlmrdCbJR/og0fX038HZKZy gGlqwIPQpSd9aIrMNIBPuA+Andshs0sHHzGOvkc1xXqRpfxEoBbe46tvEDejlt/AcjNQ 8r0dKine9CKutjzalO0Xky67vLt8hkDwS5evACWEbin26676JOzg2bzzeQSOP/l4Vld2 c5OBe1jvBVgqygZao60eDloW5ozQTK8iEyYW/G4Du3WHBjZN9y7q1RZ/erCIJ1sauIqZ jVQ2NuHrMJShIMkgQpcuLPwaAe6Te1yUbqWcPhOerTv8CBeu9HxQHlbpbY4iABzxv9LM 9ePA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ciIY8fC9; 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 x9si18722842jaf.48.2021.08.31.14.47.19; Tue, 31 Aug 2021 14:47:34 -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=ciIY8fC9; 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 S240961AbhHaTkD (ORCPT + 99 others); Tue, 31 Aug 2021 15:40:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240905AbhHaTkD (ORCPT ); Tue, 31 Aug 2021 15:40:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3ABAD60F9E; Tue, 31 Aug 2021 19:39:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630438747; bh=x273xtouPAcHm91AALzS9Mid9ylyvIGOadJdw0nv7zg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ciIY8fC97m41MryMUSIsYfTaPWh6rWkzlHFAmlPQ5NpPrkgYAaqftwuGHE3LkGZvV lJWjgjiSGGzfpoqFD6XerG2w21O301dBpb4Fefe/QWt7rti1CIkRpHNj65J+q8nOwd ZcqVVBxCLD0tZDMLyQ6hfSKPI9mPRssr+VNvABpIjJrT4nRMIyMoqKIPSZVET+E7hL xMpbMFkApJw3NPXoYW+Rdy647/h6vlZI6bvL3mkF0klY9pOhtjlGBkRmb2aLnlXRa0 +AENoM906JBVtGdvShFDIB9ad4Pc/B60HktI3GZCsuwuDuNnD70L37kcqLiXrr5wDl txfIi4RAu7fAw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 9FA794007E; Tue, 31 Aug 2021 16:39:04 -0300 (-03) Date: Tue, 31 Aug 2021 16:39:04 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [RFC PATCH v1 19/37] perf evsel: separate missing feature detection from evsel__open_cpu Message-ID: References: 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 Sat, Aug 21, 2021 at 11:19:25AM +0200, Riccardo Mancini escreveu: > This is a preparatory patch for the following patches with the goal to > separate in evlist__open_cpu the actual opening, which could be > performed in parallel, from the existing fallback mechanisms, which > should be handled sequentially. > > This patch separates the missing feature detection in evsel__open_cpu > into a new evsel__detect_missing_features function. Thanks, applied. - Arnaldo > Signed-off-by: Riccardo Mancini > --- > tools/perf/util/evsel.c | 174 +++++++++++++++++++++------------------- > tools/perf/util/evsel.h | 1 + > 2 files changed, 92 insertions(+), 83 deletions(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 4e9a3e62075305f1..c393bd992322d925 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1841,6 +1841,96 @@ int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, > return err; > } > > +bool evsel__detect_missing_features(struct evsel *evsel) > +{ > + /* > + * Must probe features in the order they were added to the > + * perf_event_attr interface. > + */ > + if (!perf_missing_features.weight_struct && > + (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) { > + perf_missing_features.weight_struct = true; > + pr_debug2("switching off weight struct support\n"); > + return true; > + } else if (!perf_missing_features.code_page_size && > + (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) { > + perf_missing_features.code_page_size = true; > + pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n"); > + return false; > + } else if (!perf_missing_features.data_page_size && > + (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) { > + perf_missing_features.data_page_size = true; > + pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n"); > + return false; > + } 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"); > + return false; > + } 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; > + pr_debug2("switching off branch HW index support\n"); > + return true; > + } else if (!perf_missing_features.aux_output && evsel->core.attr.aux_output) { > + perf_missing_features.aux_output = true; > + pr_debug2_peo("Kernel has no attr.aux_output support, bailing out\n"); > + return false; > + } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) { > + perf_missing_features.bpf = true; > + pr_debug2_peo("switching off bpf_event\n"); > + return true; > + } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) { > + perf_missing_features.ksymbol = true; > + pr_debug2_peo("switching off ksymbol\n"); > + return true; > + } else if (!perf_missing_features.write_backward && evsel->core.attr.write_backward) { > + perf_missing_features.write_backward = true; > + pr_debug2_peo("switching off write_backward\n"); > + return false; > + } else if (!perf_missing_features.clockid_wrong && evsel->core.attr.use_clockid) { > + perf_missing_features.clockid_wrong = true; > + pr_debug2_peo("switching off clockid\n"); > + return true; > + } else if (!perf_missing_features.clockid && evsel->core.attr.use_clockid) { > + perf_missing_features.clockid = true; > + pr_debug2_peo("switching off use_clockid\n"); > + return true; > + } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FLAG_FD_CLOEXEC)) { > + perf_missing_features.cloexec = true; > + pr_debug2_peo("switching off cloexec flag\n"); > + return true; > + } else if (!perf_missing_features.mmap2 && evsel->core.attr.mmap2) { > + perf_missing_features.mmap2 = true; > + pr_debug2_peo("switching off mmap2\n"); > + return true; > + } else if (!perf_missing_features.exclude_guest && > + (evsel->core.attr.exclude_guest || evsel->core.attr.exclude_host)) { > + perf_missing_features.exclude_guest = true; > + pr_debug2_peo("switching off exclude_guest, exclude_host\n"); > + return true; > + } else if (!perf_missing_features.sample_id_all) { > + perf_missing_features.sample_id_all = true; > + pr_debug2_peo("switching off sample_id_all\n"); > + return true; > + } else if (!perf_missing_features.lbr_flags && > + (evsel->core.attr.branch_sample_type & > + (PERF_SAMPLE_BRANCH_NO_CYCLES | > + PERF_SAMPLE_BRANCH_NO_FLAGS))) { > + perf_missing_features.lbr_flags = true; > + pr_debug2_peo("switching off branch sample type no (cycles/flags)\n"); > + return true; > + } else if (!perf_missing_features.group_read && > + evsel->core.attr.inherit && > + (evsel->core.attr.read_format & PERF_FORMAT_GROUP) && > + evsel__is_group_leader(evsel)) { > + perf_missing_features.group_read = true; > + pr_debug2_peo("switching off group read\n"); > + return true; > + } else { > + return false; > + } > +} > + > static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > struct perf_thread_map *threads, > int start_cpu, int end_cpu) > @@ -1979,90 +2069,8 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > if (err != -EINVAL || cpu > 0 || thread > 0) > goto out_close; > > - /* > - * Must probe features in the order they were added to the > - * perf_event_attr interface. > - */ > - if (!perf_missing_features.weight_struct && > - (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) { > - perf_missing_features.weight_struct = true; > - pr_debug2("switching off weight struct support\n"); > + if (evsel__detect_missing_features(evsel)) > goto fallback_missing_features; > - } else if (!perf_missing_features.code_page_size && > - (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) { > - perf_missing_features.code_page_size = true; > - pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n"); > - goto out_close; > - } else if (!perf_missing_features.data_page_size && > - (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) { > - 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; > - pr_debug2("switching off branch HW index support\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.aux_output && evsel->core.attr.aux_output) { > - perf_missing_features.aux_output = true; > - pr_debug2_peo("Kernel has no attr.aux_output support, bailing out\n"); > - goto out_close; > - } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) { > - perf_missing_features.bpf = true; > - pr_debug2_peo("switching off bpf_event\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) { > - perf_missing_features.ksymbol = true; > - pr_debug2_peo("switching off ksymbol\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.write_backward && evsel->core.attr.write_backward) { > - perf_missing_features.write_backward = true; > - pr_debug2_peo("switching off write_backward\n"); > - goto out_close; > - } else if (!perf_missing_features.clockid_wrong && evsel->core.attr.use_clockid) { > - perf_missing_features.clockid_wrong = true; > - pr_debug2_peo("switching off clockid\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.clockid && evsel->core.attr.use_clockid) { > - perf_missing_features.clockid = true; > - pr_debug2_peo("switching off use_clockid\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FLAG_FD_CLOEXEC)) { > - perf_missing_features.cloexec = true; > - pr_debug2_peo("switching off cloexec flag\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.mmap2 && evsel->core.attr.mmap2) { > - perf_missing_features.mmap2 = true; > - pr_debug2_peo("switching off mmap2\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.exclude_guest && > - (evsel->core.attr.exclude_guest || evsel->core.attr.exclude_host)) { > - perf_missing_features.exclude_guest = true; > - pr_debug2_peo("switching off exclude_guest, exclude_host\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.sample_id_all) { > - perf_missing_features.sample_id_all = true; > - pr_debug2_peo("switching off sample_id_all\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.lbr_flags && > - (evsel->core.attr.branch_sample_type & > - (PERF_SAMPLE_BRANCH_NO_CYCLES | > - PERF_SAMPLE_BRANCH_NO_FLAGS))) { > - perf_missing_features.lbr_flags = true; > - pr_debug2_peo("switching off branch sample type no (cycles/flags)\n"); > - goto fallback_missing_features; > - } else if (!perf_missing_features.group_read && > - evsel->core.attr.inherit && > - (evsel->core.attr.read_format & PERF_FORMAT_GROUP) && > - evsel__is_group_leader(evsel)) { > - perf_missing_features.group_read = true; > - pr_debug2_peo("switching off group read\n"); > - goto fallback_missing_features; > - } > out_close: > if (err) > threads->err_thread = thread; > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h > index 58aa998e1814ac9e..a83fb7f69b1ead73 100644 > --- a/tools/perf/util/evsel.h > +++ b/tools/perf/util/evsel.h > @@ -288,6 +288,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, > void evsel__close(struct evsel *evsel); > int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, > struct perf_thread_map *threads); > +bool evsel__detect_missing_features(struct evsel *evsel); > > struct perf_sample; > > -- > 2.31.1 -- - Arnaldo