tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kcmp(2)



Taylor R Campbell <campbell+netbsd-tech-kern%mumble.net@localhost> wrote:
> Date: Tue, 11 Jul 2023 22:00:25 +0100
> From: Robert Swindells <rjs%fdy2.co.uk@localhost>
> 
>> Linux has the kcmp(2) syscall, Mesa makes use of it.
>> 
>> Do we want a version of the syscall?
>
> Can you give any more details?
>
> What is kcmp(2) useful for?

It can compare two file descriptors to determine if they are for the
same or different files. There are online man pages for it.

The Linux implementation can compare handles to other kernel objects
as well but I don't think this functionality is needed right now.

Maybe it will be required for our Linux emulation at some point.

> Is kcmp(2) a good design for that goal?

It needs something like a syscall because the information on whether
the handles are to the same object is in the kernel.

> What does Mesa use kcmp(2) for?

Working out whether two device handles are to the same DRM device.

> Is there another way to accomplish what Mesa is trying to use it for?

I don't know of one.

> Is the functionality in Mesa optional or mandatory?

There is a wrapper function in Mesa that has one implementation for
Linux and one for everything else.

The non-Linux version just tests whether the fds are identical and
returns an error if not.

> If optional, what are the consequences of disabling it?

The xf86-video-amdgpu driver makes multiple attempts to startup the
GPU, the kernel DRM code doesn't seem to like this.

> What do operating systems other than Linux do?

They will print a warning:

               os_log_message("amdgpu: os_same_file_description couldn't "
                              "determine if two DRM fds reference the same "
                              "file description.\n"
                              "If they do, bad things may happen!\n");



Home | Main Index | Thread Index | Old Index