Re: [RFC PATCH v6 1/5] Thread-local ABI system call: cache CPU number of running thread
From: H. Peter Anvin
Date: Mon Apr 04 2016 - 13:12:45 EST
On 04/04/16 10:01, Mathieu Desnoyers wrote:
>
> Changes since v5:
> - Rename "getcpu_cache" to "thread_local_abi", allowing to extend
> this system call to cover future features such as restartable critical
> sections. Generalizing this system call ensures that we can add
> features similar to the cpu_id field within the same cache-line
> without having to track one pointer per feature within the task
> struct.
> - Add a tlabi_nr parameter to the system call, thus allowing to extend
> the ABI beyond the initial 64-byte structure by registering structures
> with tlabi_nr greater than 0. The initial ABI structure is associated
> with tlabi_nr 0.
> - Rebased on kernel v4.5.
>
This seems absolutely insanely complex, both for the kernel and for
userspace.
A much saner way would be for userspace to query the kernel for the size
of the structure; userspace then allocates the maximum of what it knows
and what the kernel knows. That way, the kernel doesn't need to
conditionalize its accesses to user space, and libc doesn't need to
conditionalize its accesses either.
-hpa