1
0
Fork 0

Allow to spawn realtime threads without the help of rtkit

Signed-off-by: Mingi Sung <fiestalake@disroot.org>
This commit is contained in:
Mingi Sung 2023-04-16 22:23:24 +09:00
parent 05857b6046
commit 58e96fe65e
No known key found for this signature in database
GPG key ID: 31A419BE9238EC9D
3 changed files with 168 additions and 12 deletions

View file

@ -1,7 +1,7 @@
pkgbase = mutter-performance
pkgdesc = A window manager for GNOME | Attempts to improve performances with non-upstreamed merge-requests and frequent stable branch resync
pkgver = 43.4+r3+g951b2a98b
pkgrel = 2
pkgrel = 3
epoch = 1
url = https://gitlab.gnome.org/GNOME/mutter
arch = x86_64
@ -37,10 +37,12 @@ pkgbase = mutter-performance
source = mr1441.patch
source = mr1880.patch
source = mr2702.patch
source = prio.patch
sha256sums = SKIP
sha256sums = ca6ea6aaa7d8fb2089d110a5ba48906caa29e6f240e1debd19bf62ea3a74c824
sha256sums = 37586730b26c476175d508288d537a38e3e828467163c2e7d91f1df76fd12cd2
sha256sums = 7a6b606cfbaae395e8bdad96eaf377f2f00b85fce431df8700017c2518d19059
sha256sums = b0381879ca6d36f185543553a327c3d115194f17ba817c7dcccd64d9b09b6fdb
pkgname = mutter-performance
groups = gnome

View file

@ -11,8 +11,8 @@
### PACKAGE OPTIONS
## MERGE REQUESTS SELECTION
# Merge Requests List: ('579' '1441' '1880' '2702')
_merge_requests_to_use=('1441' '2702')
# Merge Requests List: ('579' '1441' '1880' 'revert_2060' '2702')
_merge_requests_to_use=('1441' 'revert_2060' '2702')
## Disable building the DOCS package (Enabled if not set)
# Remember to unset this variable when producing .SRCINFO
@ -32,7 +32,7 @@ else
fi
epoch=1
pkgver=43.4+r3+g951b2a98b
pkgrel=2
pkgrel=3
pkgdesc="A window manager for GNOME | Attempts to improve performances with non-upstreamed merge-requests and frequent stable branch resync"
url="https://gitlab.gnome.org/GNOME/mutter"
arch=(x86_64 aarch64)
@ -50,11 +50,13 @@ _commit=951b2a98b5c18c258aecbb9c1f853367d0463748 # tags/43.4^3
source=("$pkgname::git+https://gitlab.gnome.org/GNOME/mutter.git#commit=$_commit"
'mr1441.patch'
'mr1880.patch'
'mr2702.patch')
'mr2702.patch'
'prio.patch')
sha256sums=('SKIP'
'ca6ea6aaa7d8fb2089d110a5ba48906caa29e6f240e1debd19bf62ea3a74c824'
'37586730b26c476175d508288d537a38e3e828467163c2e7d91f1df76fd12cd2'
'7a6b606cfbaae395e8bdad96eaf377f2f00b85fce431df8700017c2518d19059')
'7a6b606cfbaae395e8bdad96eaf377f2f00b85fce431df8700017c2518d19059'
'b0381879ca6d36f185543553a327c3d115194f17ba817c7dcccd64d9b09b6fdb')
pkgver() {
cd $pkgname
@ -94,12 +96,6 @@ prepare() {
git reset --hard
git cherry-pick --abort || true
# build: Replace deprecated/custom meson functions
pick_mr '2702' 'mr2702.patch' 'patch'
# Not affected with mr1880 enabled.
pick_mr '1880' 76ce6a0ab5975062ffe1f8b885b9be650b60e5a7 'revert'
#git remote add vanvugt https://gitlab.gnome.org/vanvugt/mutter.git || true
#git remote add verdre https://gitlab.gnome.org/verdre/mutter.git || true
#git remote add 3v1no https://gitlab.gnome.org/3v1n0/mutter.git || true
@ -157,8 +153,20 @@ prepare() {
# Status: 4
# Comment: Introduce transactions consisting of state changes for Wayland surfaces.
# Fixes: #1162
pick_mr '1880' 76ce6a0ab5975062ffe1f8b885b9be650b60e5a7 'revert' # Not affected with mr1880 enabled
pick_mr '1880' 'mr1880.patch' 'patch'
# Title: [REVERT] backends/native: Use rtkit to get realtime priority
# Author: Carlos Garnacho <carlosg@gnome.org>
# URL: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2060
# Type: 1
# Status: 4
# Comment: Reverting it to get rt-scheduler working with mr1441.
pick_mr 'revert_2060' 'prio.patch' 'patch'
# build: Replace deprecated/custom meson functions
pick_mr '2702' 'mr2702.patch' 'patch'
}
build() {

146
prio.patch Normal file
View file

@ -0,0 +1,146 @@
diff --git a/data/dbus-interfaces/org.freedesktop.RealtimeKit1.xml b/data/dbus-interfaces/org.freedesktop.RealtimeKit1.xml
deleted file mode 100644
index 305e767b1..000000000
--- a/data/dbus-interfaces/org.freedesktop.RealtimeKit1.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name="org.freedesktop.RealtimeKit1">
- <method name="MakeThreadRealtime">
- <arg name="thread" type="t" direction="in"/>
- <arg name="priority" type="u" direction="in"/>
- </method>
- <method name="MakeThreadRealtimeWithPID">
- <arg name="process" type="t" direction="in"/>
- <arg name="thread" type="t" direction="in"/>
- <arg name="priority" type="u" direction="in"/>
- </method>
- <method name="MakeThreadHighPriority">
- <arg name="thread" type="t" direction="in"/>
- <arg name="priority" type="i" direction="in"/>
- </method>
- <method name="MakeThreadHighPriorityWithPID">
- <arg name="process" type="t" direction="in"/>
- <arg name="thread" type="t" direction="in"/>
- <arg name="priority" type="i" direction="in"/>
- </method>
- <method name="ResetKnown"/>
- <method name="ResetAll"/>
- <method name="Exit"/>
- <property name="RTTimeUSecMax" type="x" access="read"/>
- <property name="MaxRealtimePriority" type="i" access="read"/>
- <property name="MinNiceLevel" type="i" access="read"/>
- </interface>
- <interface name="org.freedesktop.DBus.Properties">
- <method name="Get">
- <arg name="interface" direction="in" type="s"/>
- <arg name="property" direction="in" type="s"/>
- <arg name="value" direction="out" type="v"/>
- </method>
- </interface>
- <interface name="org.freedesktop.DBus.Introspectable">
- <method name="Introspect">
- <arg name="data" type="s" direction="out"/>
- </method>
- </interface>
-</node>
diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in
index c014b749f..5d3188099 100644
--- a/data/org.gnome.mutter.gschema.xml.in
+++ b/data/org.gnome.mutter.gschema.xml.in
@@ -136,7 +136,9 @@
restart.
• “rt-scheduler” — makes mutter request a low priority
- real-time scheduling. Requires a restart.
+ real-time scheduling. The executable
+ or user must have CAP_SYS_NICE.
+ Requires a restart.
• “autoclose-xwayland” — automatically terminates Xwayland if all
relevant X11 clients are gone.
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 8a4dbd730..ad9b4f762 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -38,6 +38,7 @@
#include "backends/native/meta-backend-native-private.h"
#include "backends/native/meta-input-thread.h"
+#include <sched.h>
#include <stdlib.h>
#include "backends/meta-color-manager.h"
@@ -62,7 +63,6 @@
#include "cogl/cogl.h"
#include "core/meta-border.h"
#include "meta/main.h"
-#include "meta-dbus-rtkit1.h"
#ifdef HAVE_REMOTE_DESKTOP
#include "backends/meta-screen-cast.h"
@@ -222,36 +222,15 @@ meta_backend_native_post_init (MetaBackend *backend)
if (meta_settings_is_experimental_feature_enabled (settings,
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
{
- g_autoptr (MetaDbusRealtimeKit1) rtkit_proxy = NULL;
- g_autoptr (GError) error = NULL;
-
- rtkit_proxy =
- meta_dbus_realtime_kit1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
- G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
- G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
- "org.freedesktop.RealtimeKit1",
- "/org/freedesktop/RealtimeKit1",
- NULL,
- &error);
-
- if (rtkit_proxy)
- {
- uint32_t priority;
-
- priority = sched_get_priority_min (SCHED_RR);
- meta_dbus_realtime_kit1_call_make_thread_realtime_sync (rtkit_proxy,
- gettid (),
- priority,
- NULL,
- &error);
- }
+ int retval;
+ struct sched_param sp = {
+ .sched_priority = sched_get_priority_min (SCHED_RR)
+ };
- if (error)
- {
- g_dbus_error_strip_remote_error (error);
- g_message ("Failed to set RT scheduler: %s", error->message);
- }
+ retval = sched_setscheduler (0, SCHED_RR | SCHED_RESET_ON_FORK, &sp);
+
+ if (retval != 0)
+ g_warning ("Failed to set RT scheduler: %m");
}
#ifdef HAVE_REMOTE_DESKTOP
diff --git a/src/meson.build b/src/meson.build
index 6790efa16..cffc408e0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -930,13 +930,6 @@ if have_remote_desktop
mutter_built_sources += dbus_screen_cast_built_sources
endif
-dbus_rtkit_built_sources = gnome.gdbus_codegen('meta-dbus-rtkit1',
- join_paths(dbus_interfaces_dir, 'org.freedesktop.RealtimeKit1.xml'),
- interface_prefix: 'org.freedesktop.',
- namespace: 'MetaDbus',
-)
-mutter_built_sources += dbus_rtkit_built_sources
-
dbus_gsd_color_built_sources = gnome.gdbus_codegen('meta-dbus-gsd-color',
join_paths(dbus_interfaces_dir, 'org.gnome.SettingsDaemon.Color.xml'),
interface_prefix: 'org.gnome.',