Bug 487996 - kwin do not get realtime capabilities on musl
Summary: kwin do not get realtime capabilities on musl
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: master
Platform: Gentoo Packages Linux
: LO normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-03 21:24 UTC by Mehmet Karataş
Modified: 2024-07-17 13:32 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1.4
Sentry Crash Report:


Attachments
fix-kwin-realtime-thread-musl.patch (482 bytes, text/plain)
2024-07-04 22:09 UTC, psykose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mehmet Karataş 2024-06-03 21:24:30 UTC
SUMMARY
Building and running kwin on musl will not get realtime priorities since sched_setscheduler in musl does nothing.

https://www.openwall.com/lists/musl/2016/03/01/4

OBSERVED RESULT
kwin running with normal priority 

EXPECTED RESULT
kwin running with realtime priorities

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
(available in About System)
KDE Plasma Version: 6.1.80
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.1

ADDITIONAL INFORMATION
Comment 1 David Edmundson 2024-06-04 05:50:22 UTC
From your link:

The reason it doesn't do anything is that Linux does not provide a way
to set scheduling parameters for a _process_, only for threads. The
sched_setscheduler syscall is documented as taking a pid but actually
takes a thread id and only operates on that thread. glibc just ignores
this and provides sched_* functions that do the wrong thing.

Fortunately there's an easy fix: use pthread_setschedparam, and
pthread_self to get the pthread_t value you need to pass to it.

---

That seems like an actionable task
Comment 2 psykose 2024-07-04 22:09:41 UTC
Created attachment 171387 [details]
fix-kwin-realtime-thread-musl.patch
Comment 3 psykose 2024-07-04 22:09:59 UTC
that patch should work on both glibc and musl
Comment 4 Bug Janitor Service 2024-07-16 12:30:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6107
Comment 5 Vlad Zahorodnii 2024-07-16 13:20:20 UTC
Git commit 5921be95d3bfcf239436681bc5fe7837c5cee203 by Vlad Zahorodnii.
Committed on 16/07/2024 at 12:56.
Pushed by vladz into branch 'master'.

utils: Fix gaining realtime scheduling with musl

sched_setscheduler() is implemented as a stub in musl that does
nothing because Linux provides no way to set scheduling parameters
per process.

Use pthread_setschedparam() to change the scheduling parameters of
the threads instead.

M  +2    -1    src/utils/realtime.cpp

https://invent.kde.org/plasma/kwin/-/commit/5921be95d3bfcf239436681bc5fe7837c5cee203
Comment 6 Vlad Zahorodnii 2024-07-17 05:50:49 UTC
Git commit 2b7882fbbc734101b097b7b7b019197386769eb1 by Vlad Zahorodnii.
Committed on 17/07/2024 at 05:29.
Pushed by vladz into branch 'Plasma/6.1'.

utils: Fix gaining realtime scheduling with musl

sched_setscheduler() is implemented as a stub in musl that does
nothing because Linux provides no way to set scheduling parameters
per process.

Use pthread_setschedparam() to change the scheduling parameters of
the threads instead.


(cherry picked from commit 5921be95d3bfcf239436681bc5fe7837c5cee203)

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>

M  +2    -1    src/utils/realtime.cpp

https://invent.kde.org/plasma/kwin/-/commit/2b7882fbbc734101b097b7b7b019197386769eb1