lkml.org 
[lkml]   [2021]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v3 40/48] perf test: Use perf_cpu_map__for_each_cpu
    From
    Clean up variable naming to make cpu and index clearer.

    Signed-off-by: Ian Rogers <irogers@google.com>
    ---
    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;
    }
    }
    --
    2.34.1.448.ga2b2bfdf31-goog
    \
     
     \ /
      Last update: 2021-12-30 08:24    [W:4.538 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site