Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4567455rdb; Tue, 12 Dec 2023 03:25:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeNVWnq50fHkEDpuHVgbEtxfwAsZ2sRKcmIT5yoQD3otpKN1BAx3km9KyX+3DyLNJmqLWq X-Received: by 2002:a05:6a20:8c14:b0:18f:97c:384e with SMTP id j20-20020a056a208c1400b0018f097c384emr5952179pzh.40.1702380340254; Tue, 12 Dec 2023 03:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702380340; cv=none; d=google.com; s=arc-20160816; b=xItFCA2kGkkuPMksTetdjet0tx+Fv/sLXQsn4I47niIFFVdvFQJ04rh1RSqydk/anE /lRepRAsoCw7aPE7yppIhnLzRC7q0ZzLp/wCSa9853E+v+8rtc6eBmwMXrdYZjxB6zfB leM3gfe7C26MV5wpbnoNq13s6kQX9A+xiWOvCEzKf8hc/Ljk556b/fiDvhFu7zsBMzdb ifGlWtb3JZBtx+DdYf+TaBHet5NtYfi14M/2OwDUnUG7e+hQXlTWqsDHIvVtxXRKp2FR N8YgnkYWzH9sPeGWXJLTuKctQljwhZoEwOT5fCuA9/8nwy8TxLF/VPlqVPYVvzkZ9BWL I6+w== 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=vscekMzhLst+kv8dAyCKh1jV+FoZleUzI8zhkzsnvx4=; fh=5EP3x1uDWWBI9dywppNETb2J5CyUqdqYJErdwPGhe68=; b=ngUnIHQlThdB2bKFm5ElyPFGHolnbnpvVHvjqyxK5l3Hj8APmfzQOD7eq+Z/we3BE+ yUOKvkh+LtAashTfPxrmfBKZQlcKy8OzW74MPuQWEgD1DHhdBdfnUOJhDZ36qvPVC5ch swxSa2w26qPgJe6/34W2HQzPJHr0rW9ILN1CVYgDvxe1RSdWwVwpfCp87JwGgrDF1zV3 i0e7X+97T9q6CIaxXAWylCqO1kgeORvpHrehJiNv+mu07nknOopExerqYHmIx1YI5VGd wyELNVrZZWKX1Hv/15BK7m8rsV5W6wWhrmpfHY+Gfz/U9I3EX4L596jIsOrc734egwjj n6qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k14-20020a6568ce000000b005c65bfc76b7si7651560pgt.570.2023.12.12.03.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 03:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 5CBCC808E0C6; Tue, 12 Dec 2023 03:25:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346357AbjLLLZO (ORCPT + 99 others); Tue, 12 Dec 2023 06:25:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346233AbjLLLZN (ORCPT ); Tue, 12 Dec 2023 06:25:13 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A79DB8; Tue, 12 Dec 2023 03:25:19 -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 5C35E143D; Tue, 12 Dec 2023 03:26:05 -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 24F483F762; Tue, 12 Dec 2023 03:25:14 -0800 (PST) Message-ID: Date: Tue, 12 Dec 2023 11:25:14 +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 13/14] perf cpumap: Use perf_cpu_map__for_each_cpu when possible Content-Language: en-US To: Ian Rogers References: <20231129060211.1890454-1-irogers@google.com> <20231129060211.1890454-14-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-14-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Tue, 12 Dec 2023 03:25:30 -0800 (PST) On 29/11/2023 06:02, Ian Rogers wrote: > Rather than manually iterating the CPU map, use > perf_cpu_map__for_each_cpu. When possible tidy local variables. > > Signed-off-by: Ian Rogers > --- > tools/perf/arch/arm64/util/header.c | 10 ++-- > tools/perf/tests/bitmap.c | 13 +++--- > tools/perf/tests/topology.c | 46 +++++++++---------- > tools/perf/util/bpf_kwork.c | 16 ++++--- > tools/perf/util/bpf_kwork_top.c | 12 ++--- > tools/perf/util/cpumap.c | 12 ++--- > .../scripting-engines/trace-event-python.c | 12 +++-- > tools/perf/util/session.c | 5 +- > tools/perf/util/svghelper.c | 20 ++++---- > 9 files changed, 72 insertions(+), 74 deletions(-) > [...] > diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c > index 860e1837ba96..8ef0e5ac03c2 100644 > --- a/tools/perf/util/scripting-engines/trace-event-python.c > +++ b/tools/perf/util/scripting-engines/trace-event-python.c > @@ -1693,13 +1693,15 @@ static void python_process_stat(struct perf_stat_config *config, > { > struct perf_thread_map *threads = counter->core.threads; > struct perf_cpu_map *cpus = counter->core.cpus; > - int cpu, thread; > > - for (thread = 0; thread < perf_thread_map__nr(threads); thread++) { > - for (cpu = 0; cpu < perf_cpu_map__nr(cpus); cpu++) { > - process_stat(counter, perf_cpu_map__cpu(cpus, cpu), > + for (int thread = 0; thread < perf_thread_map__nr(threads); thread++) { > + int idx; > + struct perf_cpu cpu; > + > + perf_cpu_map__for_each_cpu(cpu, idx, cpus) { > + process_stat(counter, cpu, > perf_thread_map__pid(threads, thread), tstamp, > - perf_counts(counter->counts, cpu, thread)); > + perf_counts(counter->counts, idx, thread)); I thought changing cpu to idx was fixing a bug, but it was actually just hard to read before where cpu was actually idx and not cpu, so this cleanup is pretty good. Reviewed-by: James Clark