Re: [LTP] [PATCH] ht_affinity.c: fix ht_affinity test failure

Cyril Hrubis
2024-09-20T12:24:16Z

Hi!
> From the kernel source code, the user_mask_ptr is unsigned long.
>
> SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
> unsigned long __user *, user_mask_ptr)
>
> so maybe we can keep the type of user_mask_ptr consistent with it.

It's actually accessed as an array. See get_user_cpu_mask() function just
above this syscall definition and userspace is suppose to pass an array
big enough for all the flags of CPUs it cares about.

There are also macros in the libc sched.h header that allows you to
allocate an array big enough for the current machine and manipulate the
bits, see man CPU_ALLOC.

--
Cyril Hrubis
chrubis@suse.cz