tools/perf: Fix perf bench epoll to enable the run when some CPU's are offline
authorAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Fri, 7 Jun 2024 04:43:53 +0000 (10:13 +0530)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 14 Jun 2024 04:27:26 +0000 (21:27 -0700)
Perf bench epoll fails as below when attempted to run on
on a powerpc system:

   ./perf bench epoll wait
   Running 'epoll/wait' benchmark:
   Run summary [PID 627653]: 79 threads monitoring on 64 file-descriptors for 8 secs.

   perf: pthread_create: No such file or directory

In the setup where this perf bench was ran, difference was that
partition had 640 CPU's, but not all CPUs were online. 80 CPUs
were online. While creating threads and using epoll_wait , code
sets the affinity using cpumask. The cpumask size used is 80
which is picked from "nrcpus = perf_cpu_map__nr(cpu)". Here the
benchmark reports fail while setting affinity for cpu number which
is greater than 80 or higher, because it attempts to set a bit
position which is not allocated on the cpumask. Fix this by changing
the size of cpumask to number of possible cpus and not the number
of online cpus.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Tested-by: Disha Goel <disgoel@linux.ibm.com>
Cc: akanksha@linux.ibm.com
Cc: kjain@linux.ibm.com
Cc: maddy@linux.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240607044354.82225-2-atrajeev@linux.vnet.ibm.com
tools/perf/bench/epoll-ctl.c
tools/perf/bench/epoll-wait.c

index d3db73dac66afe48ff80ff30849e125240c812e7..d66d852b90e4c20b3db558b6bf076b5268323085 100644 (file)
@@ -232,7 +232,7 @@ static int do_threads(struct worker *worker, struct perf_cpu_map *cpu)
        if (!noaffinity)
                pthread_attr_init(&thread_attr);
 
-       nrcpus = perf_cpu_map__nr(cpu);
+       nrcpus = cpu__max_cpu().cpu;
        cpuset = CPU_ALLOC(nrcpus);
        BUG_ON(!cpuset);
        size = CPU_ALLOC_SIZE(nrcpus);
index 06bb3187660abdd736821b5e96dddc73af261fed..ef5c4257844d13c79d2ddce2473326b2c81b74e2 100644 (file)
@@ -309,7 +309,7 @@ static int do_threads(struct worker *worker, struct perf_cpu_map *cpu)
        if (!noaffinity)
                pthread_attr_init(&thread_attr);
 
-       nrcpus = perf_cpu_map__nr(cpu);
+       nrcpus = cpu__max_cpu().cpu;
        cpuset = CPU_ALLOC(nrcpus);
        BUG_ON(!cpuset);
        size = CPU_ALLOC_SIZE(nrcpus);