From patchwork Thu Dec 23 07:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12698035 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 E67F4C433FE for ; Thu, 23 Dec 2021 08:24:24 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=h5yYBPKC4vN3UDgrlI48nRmI6qIaV6KolJE7rizTLco=; b=DagFJDcZmBQKZW+i7+3JkCp9gj g7RIyfdqNjhDn3aHi0Hp9Vg+WF4dUIhYehcpak4c2EDqLAcmq2Xa0oYBTxDefhQ3ZJK2yMB+Efy46 asLmSmmTur8/xnShlktI2064buVXEtPpdS66sKGW+1q59mmqQ6DdMT5nEpMSFOkGeEOu/3H0lZ4/s 95oQXDoPT+5n9QeAl9diDS8CY5DCfA+c6kaCo3GanBqHZD1OzpsCWDtG11k909I/DLnE7GvX123RR GvWUxPqx4Urg0wVOEOzBpEWkxRJOsbFuEaCtf61B1lVuMcPoArD0YKAve+gJ3S4aa6a/pYmDdI+Ge 9LACLsYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0JNF-00CD3q-TV; Thu, 23 Dec 2021 08:22:54 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0IpY-00C0Kc-If for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 07:48:07 +0000 Received: by mail-yb1-xb49.google.com with SMTP id w5-20020a25ac05000000b005c55592df4dso8707446ybi.12 for ; Wed, 22 Dec 2021 23:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0+jllfj9qKTtJn62Mv0xaycKEmjVjVqlWS+UU/ykrAI=; b=VS1sJ5HaFNgLWNjQYGVO1AtJP7sYCg/muV4bWo4w9PU1mXOnMoE2wy2OOHSPptpn2e 8LBFCDKZ4EjtqSPtym/k8DfExCgIcaZ64yNjXn0dfjp1nOoiQzswq3FYIS8MOteOJGtE yCaOybVqwP/dg7QKAKb3xVJjcmqSEbX+9Z8BQo1GizOG3xz0MQcHMis3c6tTiCb2f7Mo 4Kl5OgK9mi4fV0xNjFYNcncF/iQVH2cpuZkxSN7Y1P9B9h8HjRvr9mZJh4G2bhe+boat m5W3RIosFUHAC9q0KNgBYT3dMEzl6qtVOwXxTHw1OiUyFsBO1JEfQJtUP/oSiOmpojl7 TIfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0+jllfj9qKTtJn62Mv0xaycKEmjVjVqlWS+UU/ykrAI=; b=wdtKL/SQyoXyVfALShakLI8/E43no3af+/NOObKtsD7BujB1a15N96fwXUwAr3sMWc 0YC1cnGPPwelcrJZtV1KHWZsVazUX9YFElljPndO25tZ96rE3JJKEU3TazhlDo9zobv2 AN1TpNy5D2DRMVnPeUn7Nvf/U97MKSkSJc1LWHhDC1shpdrBfjUAbGZ7rxxebpTODMIS +Em22dVkprP+VF1pPpgX+faWQoFlJLWb6XlBCrLsqLG1JUKHomvmvy5l4dSvGeHBLKg5 9eEV276t3EIbhqiC8qH62VlKv5Q8VT1ax6yPyRnON7JeTCvwlzjUi9DxcySMQaueq0+Q Bqkg== X-Gm-Message-State: AOAM532/hZ81H3L6RuPDRHdKIRF2Smz46lHmlfk2AwmFFguMMPpcaN4B g2PXLXYYdMABkpsE6pj3xTaQ/iI6L5S9 X-Google-Smtp-Source: ABdhPJw1XvXrCrCmgw8Tk2gnaSSb4wGPW7JXEGtNiZ5hS4rNdk0qW6Y2vLin1IHozUlivVvyHQGwrvdHCPkX X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:4fef:90ff:589d:24ca]) (user=irogers job=sendgmr) by 2002:a25:2c4d:: with SMTP id s74mr1589032ybs.171.1640245682584; Wed, 22 Dec 2021 23:48:02 -0800 (PST) Date: Wed, 22 Dec 2021 23:45:38 -0800 In-Reply-To: <20211223074541.3318938-1-irogers@google.com> Message-Id: <20211223074541.3318938-46-irogers@google.com> Mime-Version: 1.0 References: <20211223074541.3318938-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog Subject: [PATCH v2 45/48] perf c2c: Use more intention revealing iterator From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_234804_791094_1D9504D9 X-CRM114-Status: GOOD ( 13.35 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use perf_cpu_map__for_each_cpu in setup_nodes. Signed-off-by: Ian Rogers --- tools/perf/builtin-c2c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index b5c67ef73862..ad1fbeafc93d 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2015,7 +2015,7 @@ static int setup_nodes(struct perf_session *session) { struct numa_node *n; unsigned long **nodes; - int node, cpu; + int node, cpu, idx; int *cpu2node; if (c2c.node_info > 2) @@ -2057,13 +2057,13 @@ static int setup_nodes(struct perf_session *session) if (perf_cpu_map__empty(map)) continue; - for (cpu = 0; cpu < map->nr; cpu++) { - set_bit(map->map[cpu], set); + perf_cpu_map__for_each_cpu(cpu, idx, map) { + set_bit(cpu, set); - if (WARN_ONCE(cpu2node[map->map[cpu]] != -1, "node/cpu topology bug")) + if (WARN_ONCE(cpu2node[cpu] != -1, "node/cpu topology bug")) return -EINVAL; - cpu2node[map->map[cpu]] = node; + cpu2node[cpu] = node; } }