[vlc-commits] Drop POSIX real-time priorities
Rémi Denis-Courmont
git at videolan.org
Wed Apr 1 20:44:53 CEST 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 30 16:41:16 2020 +0300| [492240a61f413d1c485b4b742cd164c0e7aa4737] | committer: Rémi Denis-Courmont
Drop POSIX real-time priorities
This only worked with root privileges, meaning it was pure placebo for
those few users that actually invoked the command line flag.
And then it seems more likely to crash the system than the achieve its
purpose, seen as VLC was never designed to handle real-time scheduling.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=492240a61f413d1c485b4b742cd164c0e7aa4737
---
src/libvlc-module.c | 20 ++----------------
src/posix/thread.c | 61 ++---------------------------------------------------
2 files changed, 4 insertions(+), 77 deletions(-)
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 34cd5a661f..91bac987ae 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1094,20 +1094,6 @@ static const char *const ppsz_prefres[] = {
"You can select which VoD server module you want to use. Set this " \
"to 'vod_rtsp' to switch back to the old, legacy module." )
-#define RT_PRIORITY_TEXT N_("Allow real-time priority")
-#define RT_PRIORITY_LONGTEXT N_( \
- "Running VLC in real-time priority will allow for much more precise " \
- "scheduling and yield better, especially when streaming content. " \
- "It can however lock up your whole machine, or make it very very " \
- "slow. You should only activate this if you know what you're " \
- "doing.")
-
-#define RT_OFFSET_TEXT N_("Adjust VLC priority")
-#define RT_OFFSET_LONGTEXT N_( \
- "This option adds an offset (positive or negative) to VLC default " \
- "priorities. You can use it to tune VLC priority against other " \
- "programs, or against other VLC instances.")
-
#define USE_STREAM_IMMEDIATE_LONGTEXT N_( \
"This option is useful if you want to lower the latency when " \
"reading a stream")
@@ -2160,10 +2146,8 @@ vlc_module_begin ()
set_section( N_("Performance options"), NULL )
#if defined (LIBVLC_USE_PTHREAD)
- add_bool( "rt-priority", false, RT_PRIORITY_TEXT,
- RT_PRIORITY_LONGTEXT, true )
- add_integer( "rt-offset", 0, RT_OFFSET_TEXT,
- RT_OFFSET_LONGTEXT, true )
+ add_obsolete_bool( "rt-priority" ) /* since 4.0.0 */
+ add_obsolete_integer( "rt-offset" ) /* since 4.0.0 */
#endif
#if defined(HAVE_DBUS)
diff --git a/src/posix/thread.c b/src/posix/thread.c
index e34725c7f1..b755f97282 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -159,30 +159,11 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
return pthread_getspecific (key);
}
-static bool rt_priorities = false;
-static int rt_offset;
-
void vlc_threads_setup (libvlc_int_t *p_libvlc)
{
- static vlc_mutex_t lock = VLC_STATIC_MUTEX;
- static bool initialized = false;
-
- vlc_mutex_lock (&lock);
- /* Initializes real-time priorities before any thread is created,
- * just once per process. */
- if (!initialized)
- {
- if (var_InheritBool (p_libvlc, "rt-priority"))
- {
- rt_offset = var_InheritInteger (p_libvlc, "rt-offset");
- rt_priorities = true;
- }
- initialized = true;
- }
- vlc_mutex_unlock (&lock);
+ (void) p_libvlc;
}
-
static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr,
void *(*entry) (void *), void *data, int priority)
{
@@ -211,27 +192,6 @@ static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr,
pthread_sigmask (SIG_BLOCK, &set, &oldset);
}
-#if defined (_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING >= 0) \
- && defined (_POSIX_THREAD_PRIORITY_SCHEDULING) \
- && (_POSIX_THREAD_PRIORITY_SCHEDULING >= 0)
- if (rt_priorities)
- {
- struct sched_param sp = { .sched_priority = priority + rt_offset, };
- int policy;
-
- if (sp.sched_priority <= 0)
- sp.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
- else
- sp.sched_priority += sched_get_priority_min (policy = SCHED_RR);
-
- pthread_attr_setschedpolicy (attr, policy);
- pthread_attr_setschedparam (attr, &sp);
- pthread_attr_setinheritsched (attr, PTHREAD_EXPLICIT_SCHED);
- }
-#else
- (void) priority;
-#endif
-
/* The thread stack size.
* The lower the value, the less address space per thread, the highest
* maximum simultaneous threads per process. Too low values will cause
@@ -254,6 +214,7 @@ static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr,
ret = pthread_create(&th->handle, attr, entry, data);
pthread_sigmask (SIG_SETMASK, &oldset, NULL);
pthread_attr_destroy (attr);
+ (void) priority;
return ret;
}
@@ -323,25 +284,7 @@ VLC_WEAK unsigned long vlc_thread_id(void)
int vlc_set_priority (vlc_thread_t th, int priority)
{
-#if defined (_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING >= 0) \
- && defined (_POSIX_THREAD_PRIORITY_SCHEDULING) \
- && (_POSIX_THREAD_PRIORITY_SCHEDULING >= 0)
- if (rt_priorities)
- {
- struct sched_param sp = { .sched_priority = priority + rt_offset, };
- int policy;
-
- if (sp.sched_priority <= 0)
- sp.sched_priority += sched_get_priority_max (policy = SCHED_OTHER);
- else
- sp.sched_priority += sched_get_priority_min (policy = SCHED_RR);
-
- if (pthread_setschedparam(th.handle, policy, &sp))
- return VLC_EGENERIC;
- }
-#else
(void) th; (void) priority;
-#endif
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list