Commit fac783d18d61af ("ppc64_cpu: Limit number of CPUs for frequency
calculation") limits the number of threads used for CPU frequency
calculation to CPU_SETSIZE (currently 1024). It is incorrectly stated to
be a limitation of sched_setaffinity(). We can allocate larger masks
using the CPU_ALLOC() and lift the limitation of 1024 CPUs.
Signed-off-by: Nysal Jan K.A. <
ny...@linux.ibm.com>
---
src/ppc64_cpu.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/ppc64_cpu.c b/src/ppc64_cpu.c
index 4017240..469e2ce 100644
--- a/src/ppc64_cpu.c
+++ b/src/ppc64_cpu.c
@@ -742,15 +742,19 @@ static void check_threads(struct cpu_freq *cpu_freqs, int max_thread)
static void *soak(void *arg)
{
unsigned int cpu = (long)arg;
- cpu_set_t cpumask;
+ cpu_set_t *cpumask;
+ size_t cpumask_size;
- CPU_ZERO(&cpumask);
- CPU_SET(cpu, &cpumask);
+ cpumask = CPU_ALLOC(threads_in_system);
+ cpumask_size = CPU_ALLOC_SIZE(threads_in_system);
+ CPU_ZERO_S(cpumask_size, cpumask);
+ CPU_SET_S(cpu, cpumask_size, cpumask);
- if (sched_setaffinity(0, sizeof(cpumask), &cpumask)) {
+ if (sched_setaffinity(0, cpumask_size, cpumask)) {
perror("sched_setaffinity");
pthread_exit(NULL);
}
+ CPU_FREE(cpumask);
while (1)
; /* Do Nothing */
@@ -930,10 +934,7 @@ static int do_cpu_frequency(int sleep_time)
setrlimit_open_files();
- max_thread = MIN(threads_in_system, CPU_SETSIZE);
- if (max_thread < threads_in_system)
- printf("ppc64_cpu currently supports up to %d CPUs\n",
- CPU_SETSIZE);
+ max_thread = threads_in_system;
cpu_freqs = calloc(max_thread, sizeof(*cpu_freqs));
if (!cpu_freqs)
--
2.52.0