From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7964DC35274 for ; Mon, 18 Dec 2023 20:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1UNDpLZZRvz/WQR0yzE4EIOBYjbNi67lhgofHYvGKj0=; b=qB/+jV7AOdBkIK PPF3ekKNDQg7Iw2fhlx6u3qDSk7WJcpy0bOCAZSSksgNeMibTMf58ACBmsnF5R8AvFeN5456GFUiI 0tuWhxA9IMhm+0YBaz9T6mXC4rAfq5aNqSPzEKi0YDV1KvaGAtunuB4Lv6NWtFdgFvvwZYskpyUgT KQBSozi0/AyVpGc0G6RdFT2ASED9EF7kTxGWEqCpwjGwzw8BlyPOLFK0rMCHemzUdCs4Z6K9ERFNC +BR2WAviryYBr2tFKwHqr891NHoSzCFReyHCnOS/7KPNo8oW04BFFczElkP2S64ZEZSYfUDPdoPRM Mg0Pt0XEKDVH8aulUkRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFKKM-00C24Y-1H; Mon, 18 Dec 2023 20:35:02 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFKKK-00C249-1s for linux-arm-kernel@bombadil.infradead.org; Mon, 18 Dec 2023 20:35:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GKoVHvYKuoUtzOlpC8DkcQcGVvx4Qj5h6qtHAW2OUzw=; b=OTS0J2CGZNQNTs3atLPsw/mGby 34CIp+NZMXhn6a/dLkEAMKUhQ2FKrTUhEa9uUSIZzny177ezhRxKXIVN5GNsH9zph1+zVi7+o+h8w BV/KwQxI7bi1s63fE0ZOxdxar+4hW+WeGu4lFpQRnTxlzuELjyAntvIJoaVX4NfHTWj0OB/2ThGXP JSQdTPNE9LAhATOM9mt3hdB/3LBU9+iYEFp1IMEB/eYAl/8aOPFzEVlJSCsf7I8tEiXPlomtAJ4wk iJ2iUt8jKDQMK6QFknetPbPB93yWd+oR6iFwJBnX94qXE8nmkbJUK53fVfuNDI6Y8SBlkvJl4xPdl zGOB0ZTQ==; Received: from [187.19.173.117] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFKKH-00DG89-10; Mon, 18 Dec 2023 20:34:58 +0000 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel