Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp44271pxb; Tue, 31 Aug 2021 14:42:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRiKH9ph6x0muZfRsKHKumF3gcpe+yye27KSMSZ+jgUX5uZxmiE/YQRTxGtY5d6X157o7a X-Received: by 2002:a92:d282:: with SMTP id p2mr20619095ilp.259.1630446174683; Tue, 31 Aug 2021 14:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630446174; cv=none; d=google.com; s=arc-20160816; b=i2A/DuLJkoO8wMPgU1fmr8NiYwCn4sHA3OKl9JjZF6L6RQXIE71SbmJmf4/7uszdMD ZkCeAP11chPWVnLA80iL/hJurzyd1J1r+qZLnzZqofls/sSWKp3vFJ6myZfWC6HLO+DX hLheBBddC9/R6AO04hOSmMzV/MsZ1mbSBUJVh1MhJRicZ/BoSwx5G6pSZQDDwGL0nCej ZPenONSdExP1a2zyztHhsJ/tbP3g3mqtenQ0NtyeKDuHFAXfWC8NAzJqBWkVtoKEA0mt Oc0qsp5OHU90P85hUUFNID/SsiQ5cUiAVfWlam2mFI44BtTiI7GGAN9ntj4J/5G671HM jC2w== 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=Gsqw4qcGE1PoZchPBmPOFfnzaF1MsMP6x76F4R0mNtU=; b=zGH7k8J2YSGzWjWvigCDX/mNJpf0Lf1m3v0AlVvQNdzubbkWMD+SKBnAlk0hu6Aeqs fI2NzAmjKRbfFV1WyYorR5dqWdGMoAaHbQVhIrA/4yipGfLtbNJUvWyBWHV+ktfVBq6u fGy1Kw6smkvSPzX94/RJN7vYaErG84XsMQiYqgD1m4t9MZkIN81SMWDVMpdbobhFEOSr zomgHYUPCZ6kntRVyH7Zu2jsH7JT9j+Tq4pjAkhd2aIn6U+/5AQfwiu+4OE1qAZ7vQZm t+nYd6KwEYakEyvC0OWVFtx3IJdmq32xMrtiMr2fsSCF+6rO0Tjt0FxKqs3xifF5LFC2 kqTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Drl5/Exf"; 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.42.42; Tue, 31 Aug 2021 14:42:54 -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="Drl5/Exf"; 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 S240824AbhHaT2j (ORCPT + 99 others); Tue, 31 Aug 2021 15:28:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240813AbhHaT2h (ORCPT ); Tue, 31 Aug 2021 15:28:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05A5B61053; Tue, 31 Aug 2021 19:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630438062; bh=1hz+rLyf4P3BZ3OMt88NDe8EDolggy1OIHQDfSHHPc8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Drl5/ExfkJPnxheBzwCx81pEtdrxwdXzNuBv+1v2hTUn68ldoOmV22x/cSICSOb3y CvE7ijrYwvZEzK3I9ApsBqvcl054Ej0X0szhXsp879WYoQM8eMzpEa0XMzjHnmPDwq lNVkspNiciUAUcbCs8ZmAy+gQr6DUbq372RZHazVwcmgLJfDJ2QbEdFIUs+b3IHtVp hyF7v+J2jNvmtpXyg7p0EKlnMXgftfLe7HZ/QIzaFEsg4LObcEBQng7ExAuc3A4wo/ 0KgOA4kyJg2VS4FABGfJrgKJRAlfWQUKKmr0JIzzGe5omNEbU7XtyNbTrcd8vfzrT0 C/rRWNbr1hFfQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D73E74007E; Tue, 31 Aug 2021 16:27:39 -0300 (-03) Date: Tue, 31 Aug 2021 16:27:39 -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 15/37] perf evsel: separate open preparation from open itself 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:21AM +0200, Riccardo Mancini escreveu: > This is a preparatory patch for the following patches with the goal to > separate in evlist__open_cpu the actual perf_event_open, which could be > performed in parallel, from the existing fallback mechanisms, which > should be handled sequentially. Thanks, applied as the end result is equivalent and we erode this patchkit a bit more. - Arnaldo > This patch separates the first lines of evsel__open_cpu into a new > __evsel__prepare_open function. > > Signed-off-by: Riccardo Mancini > --- > tools/perf/util/evsel.c | 45 +++++++++++++++++++++++++++++++---------- > 1 file changed, 34 insertions(+), 11 deletions(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index 7b4bb3229a16524e..ddf324e2e17a0951 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1746,22 +1746,20 @@ static int perf_event_open(struct evsel *evsel, > return fd; > } > > -static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > - struct perf_thread_map *threads, > - int start_cpu, int end_cpu) > + > +static struct perf_cpu_map *empty_cpu_map; > +static struct perf_thread_map *empty_thread_map; > + > +static int __evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, > + struct perf_thread_map *threads) > { > - int cpu, thread, nthreads; > - unsigned long flags = PERF_FLAG_FD_CLOEXEC; > - int pid = -1, err, old_errno; > - enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE; > + int nthreads; > > if ((perf_missing_features.write_backward && evsel->core.attr.write_backward) || > (perf_missing_features.aux_output && evsel->core.attr.aux_output)) > return -EINVAL; > > if (cpus == NULL) { > - static struct perf_cpu_map *empty_cpu_map; > - > if (empty_cpu_map == NULL) { > empty_cpu_map = perf_cpu_map__dummy_new(); > if (empty_cpu_map == NULL) > @@ -1772,8 +1770,6 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > } > > if (threads == NULL) { > - static struct perf_thread_map *empty_thread_map; > - > if (empty_thread_map == NULL) { > empty_thread_map = thread_map__new_by_tid(-1); > if (empty_thread_map == NULL) > @@ -1792,6 +1788,33 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > perf_evsel__alloc_fd(&evsel->core, cpus->nr, nthreads) < 0) > return -ENOMEM; > > + return 0; > +} > + > +static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, > + struct perf_thread_map *threads, > + int start_cpu, int end_cpu) > +{ > + int cpu, thread, nthreads; > + unsigned long flags = PERF_FLAG_FD_CLOEXEC; > + int pid = -1, err, old_errno; > + enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = NO_CHANGE; > + > + err = __evsel__prepare_open(evsel, cpus, threads); > + if (err) > + return err; > + > + if (cpus == NULL) > + cpus = empty_cpu_map; > + > + if (threads == NULL) > + threads = empty_thread_map; > + > + if (evsel->core.system_wide) > + nthreads = 1; > + else > + nthreads = threads->nr; > + > if (evsel->cgrp) { > flags |= PERF_FLAG_PID_CGROUP; > pid = evsel->cgrp->fd; > -- > 2.31.1 -- - Arnaldo