summarylogtreecommitdiffstats
path: root/prio.patch
blob: dce8549262035632c34643dd8d9688c6297dfc77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Author: Carlos Garnacho <carlosg@gnome.org>
Editor: Mingi Sung <fiestalake@disroot.org>
Commit: a8ca0c1de0d4439779397eda665d394a62964f35
Last Updated: 5/2/23 (Mutter 44.1+r1+gd643eb5c6)
---

Revert "backends/native: Use rtkit to get realtime priority"
    
This reverts commit 820aa18126674dcee73f47afb23ed89b57251e2d.

---
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 b87980939..4175c6a51 100644
--- a/data/org.gnome.mutter.gschema.xml.in
+++ b/data/org.gnome.mutter.gschema.xml.in
@@ -127,7 +127,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 5c1690d88..035b03c5e 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"
@@ -219,36 +219,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 a4fe0850c..b5a3ae0c8 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -946,11 +946,6 @@ if have_remote_desktop
 endif
 
 dbus_interfaces += [
-  {
-    'name': 'meta-dbus-rtkit1',
-    'interface': 'org.freedesktop.RealtimeKit1.xml',
-    'prefix': 'org.freedesktop.',
-  },
   {
     'name': 'meta-dbus-gsd-color',
     'interface': 'org.gnome.SettingsDaemon.Color.xml',