mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-20 08:56:56 -05:00
module-rt: only change nice level on our servers
Make the default nice.level an invalid value, that is not configured as the priority on a process. Explicitly enable a nice level on our daemon processes. Fixes #2034
This commit is contained in:
parent
9976a7f8b2
commit
f3dfa9b9af
13 changed files with 22 additions and 28 deletions
|
|
@ -37,7 +37,6 @@ context.modules = [
|
||||||
# Uses realtime scheduling to boost the audio thread priorities
|
# Uses realtime scheduling to boost the audio thread priorities
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ context.modules = [
|
||||||
# Uses realtime scheduling to boost the audio thread priorities
|
# Uses realtime scheduling to boost the audio thread priorities
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ context.modules = [
|
||||||
# Boost the data thread priority.
|
# Boost the data thread priority.
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ context.modules = [
|
||||||
# scheduling.
|
# scheduling.
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
nice.level = -11
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ context.spa-libs = {
|
||||||
context.modules = [
|
context.modules = [
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
nice.level = -11
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ context.modules = [
|
||||||
# scheduling.
|
# scheduling.
|
||||||
{ name = libpipewire-module-rt
|
{ name = libpipewire-module-rt
|
||||||
args = {
|
args = {
|
||||||
#nice.level = -11
|
nice.level = -11
|
||||||
#rt.prio = 88
|
#rt.prio = 88
|
||||||
#rt.time.soft = -1
|
#rt.time.soft = -1
|
||||||
#rt.time.hard = -1
|
#rt.time.hard = -1
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,18 @@ PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
||||||
#ifdef SCHED_RESET_ON_FORK
|
#ifdef SCHED_RESET_ON_FORK
|
||||||
#define PW_SCHED_RESET_ON_FORK SCHED_RESET_ON_FORK
|
#define PW_SCHED_RESET_ON_FORK SCHED_RESET_ON_FORK
|
||||||
#else
|
#else
|
||||||
// FreeBSD compat
|
/* FreeBSD compat */
|
||||||
#define PW_SCHED_RESET_ON_FORK 0
|
#define PW_SCHED_RESET_ON_FORK 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_NICE_LEVEL -11
|
#define IS_VALID_NICE_LEVEL(l) ((l)>=-20 && (l)<=19)
|
||||||
|
|
||||||
|
#define DEFAULT_NICE_LEVEL 20
|
||||||
#define DEFAULT_RT_PRIO 88
|
#define DEFAULT_RT_PRIO 88
|
||||||
#define DEFAULT_RT_TIME_SOFT -1
|
#define DEFAULT_RT_TIME_SOFT -1
|
||||||
#define DEFAULT_RT_TIME_HARD -1
|
#define DEFAULT_RT_TIME_HARD -1
|
||||||
|
|
||||||
#define MODULE_USAGE "[nice.level=<priority: default "SPA_STRINGIFY(DEFAULT_NICE_LEVEL)">] " \
|
#define MODULE_USAGE "[nice.level=<priority: default "SPA_STRINGIFY(DEFAULT_NICE_LEVEL)"(don't change)>] " \
|
||||||
"[rt.prio=<priority: default "SPA_STRINGIFY(DEFAULT_RT_PRIO)">] " \
|
"[rt.prio=<priority: default "SPA_STRINGIFY(DEFAULT_RT_PRIO)">] " \
|
||||||
"[rt.time.soft=<in usec: default "SPA_STRINGIFY(DEFAULT_RT_TIME_SOFT)"] " \
|
"[rt.time.soft=<in usec: default "SPA_STRINGIFY(DEFAULT_RT_TIME_SOFT)"] " \
|
||||||
"[rt.time.hard=<in usec: default "SPA_STRINGIFY(DEFAULT_RT_TIME_HARD)"] "
|
"[rt.time.hard=<in usec: default "SPA_STRINGIFY(DEFAULT_RT_TIME_HARD)"] "
|
||||||
|
|
@ -111,9 +113,9 @@ struct impl {
|
||||||
bool use_rtkit;
|
bool use_rtkit;
|
||||||
struct pw_rtkit_bus *system_bus;
|
struct pw_rtkit_bus *system_bus;
|
||||||
|
|
||||||
// These are only for the RTKit implementation to fill in the `thread`
|
/* These are only for the RTKit implementation to fill in the `thread`
|
||||||
// struct. Since there's barely any overhead here we'll do this
|
* struct. Since there's barely any overhead here we'll do this
|
||||||
// regardless of which backend is used.
|
* regardless of which backend is used. */
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
struct spa_list threads_list;
|
struct spa_list threads_list;
|
||||||
|
|
@ -488,10 +490,10 @@ static bool check_rtprio_rlimit(rlim_t priority)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// The BSDs generally don't have RLIMIT_RTPRIO. In that case we can just
|
/* The BSDs generally don't have RLIMIT_RTPRIO. In that case we can just
|
||||||
// try if setting realtime scheduling works so it can still be used when
|
* try if setting realtime scheduling works so it can still be used when
|
||||||
// PipeWire is run as root. There's probably a cleaner way to check this
|
* PipeWire is run as root. There's probably a cleaner way to check this
|
||||||
// on FreeBSD that I'm now aware of.
|
* on FreeBSD that I'm now aware of. */
|
||||||
int old_scheduler;
|
int old_scheduler;
|
||||||
struct sched_param old_sched_params;
|
struct sched_param old_sched_params;
|
||||||
if ((old_scheduler = sched_getscheduler(0)) != 0 ||
|
if ((old_scheduler = sched_getscheduler(0)) != 0 ||
|
||||||
|
|
@ -609,7 +611,7 @@ static struct spa_thread *impl_create(void *data, const struct spa_dict *props,
|
||||||
this->start = start_routine;
|
this->start = start_routine;
|
||||||
this->arg = arg;
|
this->arg = arg;
|
||||||
|
|
||||||
// This thread list is only used for the RTKit implementation
|
/* This thread list is only used for the RTKit implementation */
|
||||||
pthread_mutex_lock(&impl->lock);
|
pthread_mutex_lock(&impl->lock);
|
||||||
err = pthread_create(&this->thread, NULL, custom_start, this);
|
err = pthread_create(&this->thread, NULL, custom_start, this);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
|
|
@ -687,7 +689,7 @@ static int impl_acquire_rt(void *data, struct spa_thread *thread, int priority)
|
||||||
pthread_t pt = (pthread_t)thread;
|
pthread_t pt = (pthread_t)thread;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
// See the docstring on `spa_thread_utils_methods::acquire_rt`
|
/* See the docstring on `spa_thread_utils_methods::acquire_rt` */
|
||||||
if (priority == -1) {
|
if (priority == -1) {
|
||||||
priority = impl->rt_prio;
|
priority = impl->rt_prio;
|
||||||
}
|
}
|
||||||
|
|
@ -797,8 +799,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
impl->rt_time_soft = pw_properties_get_int32(props, "rt.time.soft", DEFAULT_RT_TIME_SOFT);
|
impl->rt_time_soft = pw_properties_get_int32(props, "rt.time.soft", DEFAULT_RT_TIME_SOFT);
|
||||||
impl->rt_time_hard = pw_properties_get_int32(props, "rt.time.hard", DEFAULT_RT_TIME_HARD);
|
impl->rt_time_hard = pw_properties_get_int32(props, "rt.time.hard", DEFAULT_RT_TIME_HARD);
|
||||||
|
|
||||||
// If the user has permissions to use regular realtime scheduling, then
|
/* If the user has permissions to use regular realtime scheduling, then
|
||||||
// we'll use that instead of RTKit
|
* we'll use that instead of RTKit */
|
||||||
if (check_rtprio_rlimit(impl->rt_prio)) {
|
if (check_rtprio_rlimit(impl->rt_prio)) {
|
||||||
use_rtkit = false;
|
use_rtkit = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -808,7 +810,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should this be pw_log_warn or pw_log_debug instead?
|
/* TODO: Should this be pw_log_warn or pw_log_debug instead? */
|
||||||
pw_log_info("could not use realtime scheduling, falling back to using RTKit instead");
|
pw_log_info("could not use realtime scheduling, falling back to using RTKit instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -822,7 +824,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_nice(impl, impl->nice_level);
|
if (IS_VALID_NICE_LEVEL(impl->nice_level))
|
||||||
|
set_nice(impl, impl->nice_level);
|
||||||
set_rlimit(impl);
|
set_rlimit(impl);
|
||||||
|
|
||||||
impl->thread_utils.iface = SPA_INTERFACE_INIT(
|
impl->thread_utils.iface = SPA_INTERFACE_INIT(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue