Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp92990rdh; Mon, 18 Dec 2023 12:35:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEt7tnLyypMPinXGiCck1lRmzoTTKNxuHhy3v5GarEldgaMd6xwBbRhpYm7wR9WN4ZA/oRN X-Received: by 2002:a2e:7d19:0:b0:2cc:6f37:491d with SMTP id y25-20020a2e7d19000000b002cc6f37491dmr1246634ljc.79.1702931707910; Mon, 18 Dec 2023 12:35:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702931707; cv=none; d=google.com; s=arc-20160816; b=T6mYzeAL7PKT2R3yYksRzJmP6w1vJWsFbxXK1Qx8Y2qwfDlPZVeLCD5aBiTSffYIDM XuAjrRIqSVyww0Ty6FK6X6HYCI0CuaP2ffb2HwPUSlpUun5svHPs4gYCMEu5f2sPnVxa Rgnb9/EwrHU1WMGmJBLv+MFyc+lkO46aGHaM+QYthvVLvq2Pbn/fqfdXUF30x0GKOHv2 ImScUTerC7sukqbvJwJ5oid8DwsyGNeBgnpL1CjRKNZspjG9tVaMCXhjC+IX6xEdUgja laJRu+xVy/FBDC6bsMcuqhTguoHzPB7Tt8aKYZMq4HUB11S8qu0jkWYhTAfFfFWnsyZJ J6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GKoVHvYKuoUtzOlpC8DkcQcGVvx4Qj5h6qtHAW2OUzw=; fh=FWQt6Qhlfs4LWiCj74nI3s2zWEKWl2ZDJBpc7A+1bPs=; b=oZuMXdM5CErrt7Ym1DWJ8cKvBUclWYyVOBH6RX5mhAxCapbr+NVH6zeXuh2F6yu2yt fm/NFEtlCCpFM+qHkT1ISHiQTiexTrbckk+cy99XCSAUj0fJLg/vkdTt+vusCBUIGH4w +BXuq1Jhf0ywUb9sSSER3mk4CmTEJVy/GFW2EXcDhXs2omplRe2dJgwg8s0fH5RkFYUr Mvv9Qsvr+VtdlgtLwd0YXteaqU26vkfDUCTOSXb8lKCyP5mo4OVmaqpnvxXZitgeYTxC WOEwA7ANrCdcIxQlXZY3liMO9Z5Hfe8WZV5+B+hAjXiXZu2Da109DyVYBgyCcaiRrC7h Qc7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="QS/Q8n0H"; spf=pass (google.com: domain of linux-kernel+bounces-4360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l12-20020a056402230c00b00552a7b3a2ffsi3389695eda.284.2023.12.18.12.35.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 12:35:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="QS/Q8n0H"; spf=pass (google.com: domain of linux-kernel+bounces-4360-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4360-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A22B61F22D30 for ; Mon, 18 Dec 2023 20:35:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E42B73465; Mon, 18 Dec 2023 20:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QS/Q8n0H" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 993521DA29; Mon, 18 Dec 2023 20:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F25F5C433C8; Mon, 18 Dec 2023 20:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702931697; bh=XgCl1gqQm6Hy5BOss5zz/mULMH3Fu6AXj/W8dxIHYHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QS/Q8n0HomxDBTx2LKKlbPGNDImEA97qdRUmVuqa5R8EuNIxsUl7LRL/bjK83zntp NGzkbF7nTBSH3f2cPbPeNSQYAdI88+ovZeV1M6URpnZaAricEZK3rZYVPSBNcDAgOW tJy2o9+D6LGkBued47DuFDUxWuoyX7Ro/ahqgnTaCBg/1MmoXlwiThIjVmM7COY2Yq Tqg8WBZVsKTkxG0r6StGxQQzphrdhOqa2TzWxORnL5Leiw/xwGu0jrbikLtKDkVHja IBrIAiVxAAzAA3fqHxyYCDdIbM0C5UM/2dm6nRZd12YUrlXVSsW5vzKZKqRZGSxuM8 lCqvo/eiCDM6Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 81F6D403EF; Mon, 18 Dec 2023 17:34:54 -0300 (-03) Date: Mon, 18 Dec 2023 17:34:54 -0300 From: Arnaldo Carvalho de Melo To: James Clark Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , Kan Liang , K Prateek Nayak , Sean Christopherson , Paolo Bonzini , Kajol Jain , Athira Rajeev , Andrew Jones , Alexandre Ghiti , Atish Patra , "Steinar H. Gunderson" , Yang Jihong , Yang Li , Changbin Du , Sandipan Das , Ravi Bangoria , Paran Lee , Nick Desaulniers , Huacai Chen , Yanteng Si , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org Subject: Re: [PATCH v1 10/14] perf top: Avoid repeated function calls Message-ID: References: <20231129060211.1890454-1-irogers@google.com> <20231129060211.1890454-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Em Tue, Dec 12, 2023 at 03:11:53PM +0000, James Clark escreveu: > > > On 29/11/2023 06:02, Ian Rogers wrote: > > Add a local variable to avoid repeated calls to perf_cpu_map__nr. > > > > Signed-off-by: Ian Rogers > > Reviewed-by: James Clark Thanks, applied to perf-tools-next. - Arnaldo > > --- > > tools/perf/util/top.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c > > index be7157de0451..4db3d1bd686c 100644 > > --- a/tools/perf/util/top.c > > +++ b/tools/perf/util/top.c > > @@ -28,6 +28,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size) > > struct record_opts *opts = &top->record_opts; > > struct target *target = &opts->target; > > size_t ret = 0; > > + int nr_cpus; > > > > if (top->samples) { > > samples_per_sec = top->samples / top->delay_secs; > > @@ -93,19 +94,17 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size) > > else > > ret += SNPRINTF(bf + ret, size - ret, " (all"); > > > > + nr_cpus = perf_cpu_map__nr(top->evlist->core.user_requested_cpus); > > if (target->cpu_list) > > ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)", > > - perf_cpu_map__nr(top->evlist->core.user_requested_cpus) > 1 > > - ? "s" : "", > > + nr_cpus > 1 ? "s" : "", > > target->cpu_list); > > else { > > if (target->tid) > > ret += SNPRINTF(bf + ret, size - ret, ")"); > > else > > ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)", > > - perf_cpu_map__nr(top->evlist->core.user_requested_cpus), > > - perf_cpu_map__nr(top->evlist->core.user_requested_cpus) > 1 > > - ? "s" : ""); > > + nr_cpus, nr_cpus > 1 ? "s" : ""); > > } > > > > perf_top__reset_sample_counters(top); > -- - Arnaldo