Message ID | a56715d8-efbc-3104-11d3-47014fa1c5f9@huawei.com |
---|---|
State | New |
Headers | show |
Series | rt-tests: cyclictest: Fix -a option fail when max_cpus is more | expand |
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index c5f1fd46567a..989113fb3483 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1135,7 +1135,7 @@ static void use_current_cpuset(const int max_cpus) pid = getpid(); - curmask = numa_bitmask_alloc(sizeof(struct bitmask)); + curmask = numa_bitmask_alloc(max_cpus); numa_sched_getaffinity(pid, curmask); /* Clear bits that are not set in both the cpuset from the environment,
An Error occurs when run: ./cyclictest -v -t 5 -p 80 -i 1000 -a 3 parse_cpumask: Using 0 cpus. Max CPUs = 96 WARN: Couldn't setaffinity in main thread: Invalid argument # /dev/cpu_dma_latency set to 0us FATAL: No allowable cpus to run on We find that numa_bitmask_alloc() is used incorrectly in use_current_cpuset(), it should pass the number of cpus as parameters, not the sizeof(struct bitmask), which is only 8 bytes. The syscall sched_getaffinity will check the parameters, if using sizeof(struct bitmask), it will fail when cpus is more: SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, unsigned long __user *, user_mask_ptr) { int ret; cpumask_var_t mask; if ((len * BITS_PER_BYTE) < nr_cpu_ids) return -EINVAL; Fix it by passing max_cpus as parameters to numa_bitmask_alloc(). Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com> --- src/cyclictest/cyclictest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)