[PATCH 21/23] linux: Add kcmp
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Nov 5 12:31:50 GMT 2026
On 05/11/26 09:22, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
>
>> On 04/11/26 19:51, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>> +#ifndef _LINUX_KCMP_H
>>>> +/* Types of kernel resources compared by kcmp. */
>>>> +enum kcmp_type
>>>> +{
>>>> + KCMP_FILE,
>>>> + KCMP_VM,
>>>> + KCMP_FILES,
>>>> + KCMP_FS,
>>>> + KCMP_SIGHAND,
>>>> + KCMP_IO,
>>>> + KCMP_SYSVSEM,
>>>> + KCMP_EPOLL_TFD,
>>>> +
>>>> + KCMP_TYPES
>>>> +};
>>>
>>> I see that it's exactly like this in the kernel UAPI header, but
>>> KCMP_TYPES is not actual constant and will change as more operation
>>> types are added.
>>
>> We can keep as define or remove, I don't have a strong opinion.
>
> I think we have to keep it in sync with the kernel.
>
>>>> +__BEGIN_DECLS
>>>> +
>>>> +/* Compare the kernel resource of type TYPE (one of the KCMP_* values) used by
>>>> + the process PID1 with the one used by the process PID2. For KCMP_FILE,
>>>> + IDX1 and IDX2 are file descriptors of the processes; for KCMP_EPOLL_TFD,
>>>> + IDX1 is a file descriptor of PID1 and IDX2 points to a
>>>> + struct kcmp_epoll_slot describing a target file registered in an epoll
>>>> + set of PID2.
>>>> + Return 0 if the resources are the same, 1 or 2 if the first one is
>>>> + respectively less or greater than the second one (in an arbitrary
>>>> + ordering), or -1 and set errno on failure. */
>>>> +extern int kcmp (__pid_t __pid1, __pid_t __pid2, int __type,
>>>> + unsigned long int __idx1, unsigned long int __idx2) __THROW;
>>>
>>> Should we expose the sub-options as individual functions?
>>>
>> I don't want to keep adding new wrappers for every kernel feature, and/or
>> having do deprecated some comparison that kernel might remove (like futex
>> did for some case).
>
> Given that the wrapper does not provide type safety, I think it doesn't
> add much value.
>
Do you prefer if we skill providing kcmp in this format then? I can remove it
in the next version.
More information about the Libc-alpha
mailing list