Skip to content

Use memfd instead of QTemporaryFile for exchanging large data

Kai Uwe Broulik requested to merge work/kbrouli/memfd-handout into master

utils: Introduce RamFile class for memfd

This class can be used to create an anonymous file, for instance to pass data between compositor and clients, through means of a file descriptor, as is done in various Wayland protocols, notably the keymap exchange.

It also implements sealing the file, so that it can be shared between multiple clients without them being able to modify it.

If supported, memfd_create is used, otherwise a QTemporaryFile is used.

keyboard_interface: Re-use the same keymap fd for supported clients

This makes use of the new RamFile class to create a sealed anonymous file to pass the keymap information to clients.

Since wl_seat version 7 [1] it is specified that clients must map the received fd as MAP_PRIVATE. This means we can use SEAL_WRITE on the file to prevent clients from tampering with it and subsequently reuse the same file for all clients using wl_seat version 7 or above.

[1] https://gitlab.freedesktop.org/wayland/wayland/-/commit/905c0a341ddf0a885811d19e2b79c65a3f1d210c

dmabuf: Use RamFile for passing dmabuf feedback table to clients

This uses a sealed anonymous file (memfd) instead of a QTemporaryFile, which is more efficient.

inputmethod_v1_interface: Use RamFile for passing keymap to clients

This uses a sealed anonymous file (memfd) instead of a QTemporaryFile, which is more efficient.

Ideally, this file was also reused if the keymap didn't change.


Kai Uwe Broulik kai_uwe.broulik@mbition.io on behalf of MBition GmbH

https://github.com/mercedes-benz/foss/blob/master/PROVIDER_INFORMATION.md

Merge request reports