Bug 1582222 - Disable rt threads for Linux for now. r=kinetik a=lizzard
authorPaul Adenot <paul@paul.cx>
Tue, 24 Sep 2019 11:23:25 +0000
changeset 555369 c1868de79e07f9a82a7a26ca58c129531bf13c34
parent 555368 3d4fd3b037246744994935d2fd0e91f4b79db172
child 555370 22126085ed7ef535e2c16cf7637ce6c9ae64d6bf
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, lizzard
bugs1582222
milestone70.0
Bug 1582222 - Disable rt threads for Linux for now. r=kinetik a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D46570
media/audioipc/client/src/context.rs
media/audioipc/client/src/lib.rs
media/audioipc/disable-rt.patch
media/audioipc/server/src/lib.rs
media/audioipc/update.sh
--- a/media/audioipc/client/src/context.rs
+++ b/media/audioipc/client/src/context.rs
@@ -3,17 +3,16 @@
 // This program is made available under an ISC-style license.  See the
 // accompanying file LICENSE for details
 
 use crate::assert_not_in_callback;
 use crate::stream;
 #[cfg(target_os = "linux")]
 use crate::G_THREAD_POOL;
 use crate::{ClientStream, CpuPoolInitParams, CPUPOOL_INIT_PARAMS, G_SERVER_FD};
-use audio_thread_priority::promote_current_thread_to_real_time;
 use audioipc::codec::LengthDelimitedCodec;
 use audioipc::frame::{framed, Framed};
 use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
 use audioipc::{core, rpc};
 use audioipc::{
     messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage,
     ServerMessage,
 };
@@ -86,24 +85,16 @@ fn open_server_stream() -> io::Result<au
         Err(io::Error::new(
             io::ErrorKind::Other,
             "Failed to get server connection.",
         ))
     }
 }
 
 fn register_thread(callback: Option<extern "C" fn(*const ::std::os::raw::c_char)>) {
-    match promote_current_thread_to_real_time(0, 48000) {
-        Ok(_) => {
-            info!("Audio thread promoted to real-time.");
-        }
-        Err(_) => {
-            warn!("Could not promote thread to real-time.");
-        }
-    }
     if let Some(func) = callback {
         let thr = thread::current();
         let name = CString::new(thr.name().unwrap()).unwrap();
         func(name.as_ptr());
     }
 }
 
 fn create_thread_pool(init_params: CpuPoolInitParams) -> CpuPool {
--- a/media/audioipc/client/src/lib.rs
+++ b/media/audioipc/client/src/lib.rs
@@ -13,18 +13,16 @@ extern crate lazy_static;
 
 #[macro_use]
 mod send_recv;
 mod context;
 mod stream;
 
 use crate::context::ClientContext;
 use crate::stream::ClientStream;
-#[cfg(target_os = "linux")]
-use audio_thread_priority::promote_current_thread_to_real_time;
 use audio_thread_priority::RtPriorityHandle;
 use audioipc::{PlatformHandle, PlatformHandleType};
 use cubeb_backend::{capi, ffi};
 use futures_cpupool::CpuPool;
 #[cfg(target_os = "linux")]
 use std::ffi::CString;
 use std::os::raw::{c_char, c_int};
 use std::sync::Mutex;
@@ -104,26 +102,16 @@ pub unsafe extern "C" fn audioipc_init_t
     // It is critical that this function waits until the various threads are created, promoted to
     // real-time, and _then_ return, because the sandbox lockdown happens right after returning
     // from here.
     let pair = Arc::new((Mutex::new((*init_params).pool_size), Condvar::new()));
     let pair2 = pair.clone();
 
     let register_thread = move || {
         if let Some(func) = thread_create_callback {
-            match promote_current_thread_to_real_time(0, 48000) {
-                Ok(handle) => {
-                    G_PRIORITY_HANDLES.with(|handles| {
-                        (handles.borrow_mut()).push(handle);
-                    });
-                }
-                Err(_) => {
-                    warn!("Could not promote audio threads to real-time during initialization.");
-                }
-            }
             let thr = thread::current();
             let name = CString::new(thr.name().unwrap()).unwrap();
             func(name.as_ptr());
             let &(ref lock, ref cvar) = &*pair2;
             let mut count = lock.lock().unwrap();
             *count -= 1;
             cvar.notify_one();
         }
new file mode 100644
--- /dev/null
+++ b/media/audioipc/disable-rt.patch
@@ -0,0 +1,139 @@
+diff --git a/media/audioipc/client/src/context.rs b/media/audioipc/client/src/context.rs
+--- a/media/audioipc/client/src/context.rs
++++ b/media/audioipc/client/src/context.rs
+@@ -3,17 +3,16 @@
+ // This program is made available under an ISC-style license.  See the
+ // accompanying file LICENSE for details
+ 
+ use crate::assert_not_in_callback;
+ use crate::stream;
+ #[cfg(target_os = "linux")]
+ use crate::G_THREAD_POOL;
+ use crate::{ClientStream, CpuPoolInitParams, CPUPOOL_INIT_PARAMS, G_SERVER_FD};
+-use audio_thread_priority::promote_current_thread_to_real_time;
+ use audioipc::codec::LengthDelimitedCodec;
+ use audioipc::frame::{framed, Framed};
+ use audioipc::platformhandle_passing::{framed_with_platformhandles, FramedWithPlatformHandles};
+ use audioipc::{core, rpc};
+ use audioipc::{
+     messages, messages::DeviceCollectionReq, messages::DeviceCollectionResp, ClientMessage,
+     ServerMessage,
+ };
+@@ -86,24 +85,16 @@ fn open_server_stream() -> io::Result<au
+         Err(io::Error::new(
+             io::ErrorKind::Other,
+             "Failed to get server connection.",
+         ))
+     }
+ }
+ 
+ fn register_thread(callback: Option<extern "C" fn(*const ::std::os::raw::c_char)>) {
+-    match promote_current_thread_to_real_time(0, 48000) {
+-        Ok(_) => {
+-            info!("Audio thread promoted to real-time.");
+-        }
+-        Err(_) => {
+-            warn!("Could not promote thread to real-time.");
+-        }
+-    }
+     if let Some(func) = callback {
+         let thr = thread::current();
+         let name = CString::new(thr.name().unwrap()).unwrap();
+         func(name.as_ptr());
+     }
+ }
+ 
+ fn create_thread_pool(init_params: CpuPoolInitParams) -> CpuPool {
+diff --git a/media/audioipc/client/src/lib.rs b/media/audioipc/client/src/lib.rs
+--- a/media/audioipc/client/src/lib.rs
++++ b/media/audioipc/client/src/lib.rs
+@@ -13,18 +13,16 @@ extern crate lazy_static;
+ 
+ #[macro_use]
+ mod send_recv;
+ mod context;
+ mod stream;
+ 
+ use crate::context::ClientContext;
+ use crate::stream::ClientStream;
+-#[cfg(target_os = "linux")]
+-use audio_thread_priority::promote_current_thread_to_real_time;
+ use audio_thread_priority::RtPriorityHandle;
+ use audioipc::{PlatformHandle, PlatformHandleType};
+ use cubeb_backend::{capi, ffi};
+ use futures_cpupool::CpuPool;
+ #[cfg(target_os = "linux")]
+ use std::ffi::CString;
+ use std::os::raw::{c_char, c_int};
+ use std::sync::Mutex;
+@@ -104,26 +102,16 @@ pub unsafe extern "C" fn audioipc_init_t
+     // It is critical that this function waits until the various threads are created, promoted to
+     // real-time, and _then_ return, because the sandbox lockdown happens right after returning
+     // from here.
+     let pair = Arc::new((Mutex::new((*init_params).pool_size), Condvar::new()));
+     let pair2 = pair.clone();
+ 
+     let register_thread = move || {
+         if let Some(func) = thread_create_callback {
+-            match promote_current_thread_to_real_time(0, 48000) {
+-                Ok(handle) => {
+-                    G_PRIORITY_HANDLES.with(|handles| {
+-                        (handles.borrow_mut()).push(handle);
+-                    });
+-                }
+-                Err(_) => {
+-                    warn!("Could not promote audio threads to real-time during initialization.");
+-                }
+-            }
+             let thr = thread::current();
+             let name = CString::new(thr.name().unwrap()).unwrap();
+             func(name.as_ptr());
+             let &(ref lock, ref cvar) = &*pair2;
+             let mut count = lock.lock().unwrap();
+             *count -= 1;
+             cvar.notify_one();
+         }
+diff --git a/media/audioipc/server/src/lib.rs b/media/audioipc/server/src/lib.rs
+--- a/media/audioipc/server/src/lib.rs
++++ b/media/audioipc/server/src/lib.rs
+@@ -6,17 +6,16 @@
+ 
+ #[macro_use]
+ extern crate error_chain;
+ #[macro_use]
+ extern crate log;
+ #[macro_use]
+ extern crate lazy_static;
+ 
+-use audio_thread_priority::promote_current_thread_to_real_time;
+ use audioipc::core;
+ use audioipc::platformhandle_passing::framed_with_platformhandles;
+ use audioipc::rpc;
+ use audioipc::{MessageStream, PlatformHandle, PlatformHandleType};
+ use futures::sync::oneshot;
+ use futures::Future;
+ use std::error::Error;
+ use std::ffi::{CStr, CString};
+@@ -59,22 +58,16 @@ struct ServerWrapper {
+     core_thread: core::CoreThread,
+     callback_thread: core::CoreThread,
+ }
+ 
+ fn run() -> Result<ServerWrapper> {
+     trace!("Starting up cubeb audio server event loop thread...");
+ 
+     let callback_thread = core::spawn_thread("AudioIPC Callback RPC", || {
+-        match promote_current_thread_to_real_time(0, 48000) {
+-            Ok(_) => {}
+-            Err(_) => {
+-                debug!("Failed to promote audio callback thread to real-time.");
+-            }
+-        }
+         trace!("Starting up cubeb audio callback event loop thread...");
+         Ok(())
+     })
+     .or_else(|e| {
+         debug!(
+             "Failed to start cubeb audio callback event loop thread: {:?}",
+             e.description()
+         );
--- a/media/audioipc/server/src/lib.rs
+++ b/media/audioipc/server/src/lib.rs
@@ -6,17 +6,16 @@
 
 #[macro_use]
 extern crate error_chain;
 #[macro_use]
 extern crate log;
 #[macro_use]
 extern crate lazy_static;
 
-use audio_thread_priority::promote_current_thread_to_real_time;
 use audioipc::core;
 use audioipc::platformhandle_passing::framed_with_platformhandles;
 use audioipc::rpc;
 use audioipc::{MessageStream, PlatformHandle, PlatformHandleType};
 use futures::sync::oneshot;
 use futures::Future;
 use std::error::Error;
 use std::ffi::{CStr, CString};
@@ -59,22 +58,16 @@ struct ServerWrapper {
     core_thread: core::CoreThread,
     callback_thread: core::CoreThread,
 }
 
 fn run() -> Result<ServerWrapper> {
     trace!("Starting up cubeb audio server event loop thread...");
 
     let callback_thread = core::spawn_thread("AudioIPC Callback RPC", || {
-        match promote_current_thread_to_real_time(0, 48000) {
-            Ok(_) => {}
-            Err(_) => {
-                debug!("Failed to promote audio callback thread to real-time.");
-            }
-        }
         trace!("Starting up cubeb audio callback event loop thread...");
         Ok(())
     })
     .or_else(|e| {
         debug!(
             "Failed to start cubeb audio callback event loop thread: {:?}",
             e.description()
         );
--- a/media/audioipc/update.sh
+++ b/media/audioipc/update.sh
@@ -28,9 +28,11 @@ if [ -n "$rev" ]; then
   sed -i.bak -e "/The git commit ID used was/ s/[0-9a-f]\{40\}\(-dirty\)\{0,1\} .\{1,100\}/$version ($date)/" README_MOZILLA
   rm README_MOZILLA.bak
 else
   echo "Remember to update README_MOZILLA with the version details."
 fi
 
 echo "Applying gecko.patch on top of $rev"
 patch -p3 < gecko.patch
+echo "Applying disable-rt.patch on top of $rev"
+patch -p3 < disable-rt.patch