Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4704388rdb; Tue, 12 Dec 2023 07:12:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+rbxjum58s/YojJMjU5gCA1eQEwBmadZXO62MBLSvw90wP2qI0N/5qi0cowQ+L/CghB3d X-Received: by 2002:a05:6a20:4ca2:b0:18f:c21d:7ec4 with SMTP id fq34-20020a056a204ca200b0018fc21d7ec4mr6277868pzb.40.1702393930160; Tue, 12 Dec 2023 07:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702393930; cv=none; d=google.com; s=arc-20160816; b=WqkLFmZhoOYmDJR1980DmHDLE6FwN5BLugCvBPjo7pYLi5u/lA26UFNi5sisV9/4x7 wwjZxCJohURVhwgrUud8TPFDV6as8xDqpDG6/afz6kkiXgzBqiMqPrYpCJ8N0Tf1g4sd dBlOAsDuDexp+BHsNIRVRwl2LpVpqLAe5ZUFOi/Iz1ukftw8BIGPOLYCyuaxj21334NB p0s76dLPUCw4FKESrCyGg1T0j3WzUjeAzP8/n/ar3Qx8fjE9CAsJbaJIx6sn1apeH3yN NvoNFG1Z5EKq5MUrTXSZt+h81ueHwfsizzHUwxwu+sE5KwmuWEMQKYK48emAuA1WegAx dQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from:cc :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=np7rzQFnc1rfyzcptLxNUCaBSRhxFwMXP7ALaChyqkQ=; fh=5EP3x1uDWWBI9dywppNETb2J5CyUqdqYJErdwPGhe68=; b=CsLc/v2RpMIwCJo8PwjMgmXatCUb7P+/sL5s8hDEn19y/+TK67k1GSXq91jiSNLm4I KTP0lFpsQUkhcbtsU8OVx0ypYbf6SdsrEoGsuZN1+wxF/VeHYv8/ImaUkD979WqeP49J KkYJEH2VkD9VHg1Z3ouJay0TDgHeM7Tvbg/ItxVah1ue/GAmRb72Htwyrvq3tLGjDme8 ni4CNExtpzPFbYBfwgXOepJBG2sqALeRaXXwWUwl9gCH48uEJByp2xtINSf8kUKIHFuq p0WAK66c9GdEg+DWZ31NK4Wfh0PCy8w7rFMNLstV4mEfMkaAMZry5GrNENq3cwMXkMZl 1y9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d16-20020a056a0010d000b006ce4f45bf67si7840234pfu.278.2023.12.12.07.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 07:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9D78D804E7A7; Tue, 12 Dec 2023 07:12:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376469AbjLLPL6 (ORCPT + 99 others); Tue, 12 Dec 2023 10:11:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232844AbjLLPL5 (ORCPT ); Tue, 12 Dec 2023 10:11:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F77BAA; Tue, 12 Dec 2023 07:12:03 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7F51E143D; Tue, 12 Dec 2023 07:12:49 -0800 (PST) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEE2D3F738; Tue, 12 Dec 2023 07:11:57 -0800 (PST) Message-ID: Date: Tue, 12 Dec 2023 15:11:53 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 10/14] perf top: Avoid repeated function calls Content-Language: en-US To: Ian Rogers References: <20231129060211.1890454-1-irogers@google.com> <20231129060211.1890454-11-irogers@google.com> Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , 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 , =?UTF-8?Q?Andr=c3=a9_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 From: James Clark In-Reply-To: <20231129060211.1890454-11-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 07:12:07 -0800 (PST) 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 > --- > 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);