From 5d3e31a49968fc0da04e98c0f9d624ea5095c9e0 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 10 Oct 2023 14:48:55 -0400 Subject: [PATCH] kms/impl-device: Inhibit real-time scheduling when mode setting Certain kernel drivers can take an unreasonably long time to complete mode setting operations. That excessive CPU time is charged to the process's rlimits which can lead to the process getting killed if the thread is a real-time thread. This commit inhibits real-time scheduling around mode setting commits, since those commits are the ones currently presenting as excessively slow. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3037 Part-of: --- src/backends/native/meta-kms-impl-device.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 8f88219fe..bce64d309 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -1581,6 +1581,10 @@ process_mode_set_update (MetaKmsImplDevice *impl_device, { MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); + MetaKmsImpl *kms_impl = meta_kms_impl_device_get_impl (impl_device); + MetaThreadImpl *thread_impl = META_THREAD_IMPL (kms_impl); + MetaThread *thread = meta_thread_impl_get_thread (thread_impl); + MetaKmsFeedback *feedback; CrtcFrame *crtc_frame; GList *l; GHashTableIter iter; @@ -1612,7 +1616,11 @@ process_mode_set_update (MetaKmsImplDevice *impl_device, disarm_crtc_frame_deadline_timer (crtc_frame); } - return do_process (impl_device, NULL, update, flags); + meta_thread_inhibit_realtime_in_impl (thread); + feedback = do_process (impl_device, NULL, update, flags); + meta_thread_uninhibit_realtime_in_impl (thread); + + return feedback; } MetaKmsFeedback * @@ -1656,13 +1664,18 @@ meta_kms_impl_device_disable (MetaKmsImplDevice *impl_device) { MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); + MetaKmsImpl *kms_impl = meta_kms_impl_device_get_impl (impl_device); + MetaThreadImpl *thread_impl = META_THREAD_IMPL (kms_impl); + MetaThread *thread = meta_thread_impl_get_thread (thread_impl); MetaKmsImplDeviceClass *klass = META_KMS_IMPL_DEVICE_GET_CLASS (impl_device); if (!priv->device_file) return; meta_kms_impl_device_hold_fd (impl_device); + meta_thread_inhibit_realtime_in_impl (thread); klass->disable (impl_device); + meta_thread_uninhibit_realtime_in_impl (thread); g_list_foreach (priv->crtcs, (GFunc) meta_kms_crtc_disable_in_impl, NULL); g_list_foreach (priv->connectors,