From patchwork Thu Dec 30 07:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12701302 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 BA364C433EF for ; Thu, 30 Dec 2021 07:53:54 +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=ihoiMmKIH6Qr+s4n345/EWRa6fEwOv9ZbqQtsfTPUos=; b=329zIdb1PWMeEkGTkLVOIpxHra bWERcJzhBvkI248aDzhQCEJFTEdmkIXS7BYg4us23xkPu4jnIBzTu6PQeaNLGIVzmYOQDfsW2bAhh ONAB1risbm4hKEVGzo6lXvleefB4OBGk1StvrUKOjqYBcpHqUJi4NwE6ctxGlAi2zUvPdoc4bUcGv aYvKR7eaMPz57WUM+tjjr9GOiEf1GVw/4cLKflcJgNqsMZHGu/bttTbXmK5JOrFdHI+D+a1RzNeW6 8nCvevP6D1cZJTnyva+SvXiCp61dhBdzViEa5zKOFev9jLo8LPc83hzmpvBIaQKwjkCkSbEBy8kiP JMeYmXPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2qEa-003uo3-4k; Thu, 30 Dec 2021 07:52:24 +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 1n2plU-003kHG-Cr for linux-arm-kernel@lists.infradead.org; Thu, 30 Dec 2021 07:22:21 +0000 Received: by mail-yb1-xb49.google.com with SMTP id p140-20020a257492000000b0060dbb88d8abso11652288ybc.15 for ; Wed, 29 Dec 2021 23:22:19 -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=zv8Au8yEBbpBWPa207TVw47r1vENU76hbFmK75NTzaI=; b=cm5pC41StIJJ8ZTI6ni5rDmi8zqtUkXa6N2IC/yAHj5WHEzVKTdBu0wB8K3poeDkag QFnOLF4mucomBZ/iPBrTu5/Ng+0C1r7IhfcJA1yYG7aXw0QISw4BpF3cKCajx7mdSXwX 5tifU2Wjrb/tvq2B1mqCm8BnEe8TT076JLDktKfUebxQnSbrVW4TYdKj7FngNVn0jIyP XPggI65FTzvFpqFmsUfZQ7MakRzid3dDp5D68fpgsA9/T+jufiDdRjeJl45r7D/WRcJG TmQDF8Z913vTmA/AZbcV/eFSCLyCm/fmA3PhICJCtRmuyYvFrrbP3BykqknShuMxSrW1 BiOQ== 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=zv8Au8yEBbpBWPa207TVw47r1vENU76hbFmK75NTzaI=; b=URz7O5TH2xv+MWx6UPYuFXWQwyY37FCvfsqLRYpoM+vjIGH7wsxwTvm4Zmp33S5z/m UTgPIJfEW+DQFTkaphmtaJtxXesQCND6uC47aX3AaNm+OZTqMtXtE/JaIeGKEbvSmolL tKGDDed2v6iU0hsWFzcdh0egMVYfnB0kA2NJr2omVmVOaiMm/mySKiWilhAz0PGqnd57 S+Sc3TkDLEe+wYzAzIhBBLforsyIIzCzTZriSneaL2Guj+kcSLKA3T0zD4eZFdyWuNl1 dIgQABliPmKw+byQhFBpMaEV1B7j6fTNMcJV203NTKPeSW/WhOJpVgjDUeP2WeOosn51 RLww== X-Gm-Message-State: AOAM533+jC10tjp6RbA+wUMsNjLxVAXb0PPCdF+hwf3gI9+gCVT+vO0l l8pZn0LddfpdHTr60nnilLqFpWG5BWxG X-Google-Smtp-Source: ABdhPJw1Ll8Ncrw9J+MROnunrWaGDWAMTzviVpnbWMtVY0h4rw0YkaMGyM1QnS6GI4i7Sme5QRz3QetSYd3B X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:31c4:9539:dba1:a82b]) (user=irogers job=sendgmr) by 2002:a25:2c89:: with SMTP id s131mr23705628ybs.504.1640848938565; Wed, 29 Dec 2021 23:22:18 -0800 (PST) Date: Wed, 29 Dec 2021 23:20:22 -0800 In-Reply-To: <20211230072030.302559-1-irogers@google.com> Message-Id: <20211230072030.302559-42-irogers@google.com> Mime-Version: 1.0 References: <20211230072030.302559-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH v3 40/48] perf test: Use perf_cpu_map__for_each_cpu 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, zhengjun.xing@intel.com Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211229_232220_490953_55FE8C12 X-CRM114-Status: GOOD ( 15.22 ) 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 Clean up variable naming to make cpu and index clearer. Signed-off-by: Ian Rogers --- tools/perf/tests/openat-syscall-all-cpus.c | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index 544db0839b3b..ca0a50e92839 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c @@ -22,7 +22,7 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __maybe_unused, int subtest __maybe_unused) { - int err = -1, fd, cpu; + int err = -1, fd, idx, cpu; struct perf_cpu_map *cpus; struct evsel *evsel; unsigned int nr_openat_calls = 111, i; @@ -58,23 +58,23 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb goto out_evsel_delete; } - for (cpu = 0; cpu < cpus->nr; ++cpu) { - unsigned int ncalls = nr_openat_calls + cpu; + perf_cpu_map__for_each_cpu(cpu, idx, cpus) { + unsigned int ncalls = nr_openat_calls + idx; /* * XXX eventually lift this restriction in a way that * keeps perf building on older glibc installations * without CPU_ALLOC. 1024 cpus in 2010 still seems * a reasonable upper limit tho :-) */ - if (cpus->map[cpu] >= CPU_SETSIZE) { - pr_debug("Ignoring CPU %d\n", cpus->map[cpu]); + if (cpu >= CPU_SETSIZE) { + pr_debug("Ignoring CPU %d\n", cpu); continue; } - CPU_SET(cpus->map[cpu], &cpu_set); + CPU_SET(cpu, &cpu_set); if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { pr_debug("sched_setaffinity() failed on CPU %d: %s ", - cpus->map[cpu], + cpu, str_error_r(errno, sbuf, sizeof(sbuf))); goto out_close_fd; } @@ -82,29 +82,29 @@ static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __mayb fd = openat(0, "/etc/passwd", O_RDONLY); close(fd); } - CPU_CLR(cpus->map[cpu], &cpu_set); + CPU_CLR(cpu, &cpu_set); } evsel->core.cpus = perf_cpu_map__get(cpus); err = 0; - for (cpu = 0; cpu < cpus->nr; ++cpu) { + perf_cpu_map__for_each_cpu(cpu, idx, cpus) { unsigned int expected; - if (cpus->map[cpu] >= CPU_SETSIZE) + if (cpu >= CPU_SETSIZE) continue; - if (evsel__read_on_cpu(evsel, cpu, 0) < 0) { + if (evsel__read_on_cpu(evsel, idx, 0) < 0) { pr_debug("evsel__read_on_cpu\n"); err = -1; break; } - expected = nr_openat_calls + cpu; - if (perf_counts(evsel->counts, cpu, 0)->val != expected) { + expected = nr_openat_calls + idx; + if (perf_counts(evsel->counts, idx, 0)->val != expected) { pr_debug("evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", - expected, cpus->map[cpu], perf_counts(evsel->counts, cpu, 0)->val); + expected, cpu, perf_counts(evsel->counts, idx, 0)->val); err = -1; } }