Ensure libinput connection thread uses real time scheduling
ClosedPublic

Authored by graesslin on Sep 30 2017, 8:09 AM.

Details

Summary

The SCHED_RESET_ON_FORK results in threads (not only processes) to have
the scheduling policy reset to default. This means that the libinput
thread is not real time, but this was actually intended.

To solve this problem KWin does start without the RESET_ON_FORK flag
during startup. Once createInput has been called the scheduling is
adjusted again and RESET_ON_FORK is added again. This results in the
libinput thread and all threads Qt starts in between (e.g. dbus) to gain
real time policy. But it is still not leaked to other processes or to
threads in KWin which don't need it.

Other options considered: just don't use RESET_ON_FORK and instead
manually reset on fork. This would mean all threads in KWin gain real
time, but we don't need this. It's only interesting for the main
(rendering, Wayland thread) and the input thread. Also the danger to
leak into another process is too high.

Keeping the capability till the libinput thread is created and adjust
the thread itself. This option was discarded as I don't want KWin to
have any capabilities when the QApplication is started.

Test Plan

ps -eL -o class,rtprio,cmd,comm | grep kwin_wayland

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Sep 30 2017, 8:09 AM
Restricted Application added a project: KWin. · View Herald TranscriptSep 30 2017, 8:09 AM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
anthonyfieroni added inline comments.
main_wayland.cpp
91

static

graesslin added inline comments.Oct 16 2017, 7:43 PM
main_wayland.cpp
91

Could you please explain why you think that this function should be static? Please keep in mind that main_wayland.cpp is it's own translation unit.

anthonyfieroni added inline comments.Oct 17 2017, 4:32 AM
main_wayland.cpp
91

It does not have other purpose, i don't see it's only one unit.

graesslin updated this revision to Diff 21011.Oct 20 2017, 1:42 PM

Use anonymous namespace

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptOct 20 2017, 1:42 PM
This comment was removed by davidedmundson.
davidedmundson accepted this revision.Oct 23 2017, 3:07 PM
This revision is now accepted and ready to land.Oct 23 2017, 3:07 PM
This revision was automatically updated to reflect the committed changes.