From 973eaedf51a8ab0f9881c1fb900850dd8475bbf7 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 28 Oct 2016 14:50:05 +0900 Subject: [PATCH] improve responsivness of timer sleeping threads for vsync with prctl prctl allows us on some platforms to request a thread be woken up more agressively e.g. due to a timeout bu setting timerslack. since we use a dedicated thread just for vsync events, this is a very good idea to ask the kernel to be as exact as possible for this thread as it only wakes up once per frame (or should only) and accuracy is important. so use this. also improve prctl checks to be more explicit in configure.ac and use these ifdefs in ecore exe too where prctl is used as well. @feature --- configure.ac | 2 +- m4/efl_check_funcs.m4 | 11 +++++++++++ src/lib/ecore/ecore_anim.c | 7 +++++++ src/lib/ecore/ecore_exe_posix.c | 10 +++++----- src/lib/ecore_x/xlib/ecore_x_vsync.c | 7 +++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 1a850808f8..4e61cc5d40 100644 --- a/configure.ac +++ b/configure.ac @@ -1029,7 +1029,7 @@ EFL_CHECK_GCC_BUILTIN([bswap64], [HAVE_BSWAP64]) AC_CHECK_FUNCS([fchmod]) -EFL_CHECK_FUNCS([EINA], [dlopen dladdr iconv shm_open splice setxattr getpagesize]) +EFL_CHECK_FUNCS([EINA], [dlopen dladdr iconv shm_open splice setxattr getpagesize prctl]) enable_log="no" if test "x${efl_func_fnmatch}" = "xyes" && test "x${want_log}" = "xyes" ; then diff --git a/m4/efl_check_funcs.m4 b/m4/efl_check_funcs.m4 index 39fb5ee5ad..b44f20bc55 100644 --- a/m4/efl_check_funcs.m4 +++ b/m4/efl_check_funcs.m4 @@ -288,6 +288,17 @@ sz = getpagesize(); ]]) ]) +dnl _EFL_CHECK_FUNC_PRCTL is for internal use +dnl _EFL_CHECK_FUNC_PRCTL(EFL, VARIABLE) +AC_DEFUN([_EFL_CHECK_FUNC_PRCTL], +[EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[ +#include +]], +[[ +prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0); +]]) +]) + dnl Macro that checks function availability dnl dnl EFL_CHECK_FUNC(EFL, FUNCTION) diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c index c069c96118..66432868d5 100644 --- a/src/lib/ecore/ecore_anim.c +++ b/src/lib/ecore/ecore_anim.c @@ -30,6 +30,10 @@ #endif /* ! _WIN32 */ +#ifdef HAVE_PRCTL +# include +#endif + #include "Ecore.h" #include "ecore_private.h" @@ -109,6 +113,9 @@ _timer_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread) int ret; eina_thread_name_set(eina_thread_self(), "Eanimator-timer"); +#ifdef HAVE_PRCTL + prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0); +#endif while (!ecore_thread_check(thread)) { DBG("------- timer_event_is_busy=%i", timer_event_is_busy); diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c index 5ad60f9010..14c7d6963f 100644 --- a/src/lib/ecore/ecore_exe_posix.c +++ b/src/lib/ecore/ecore_exe_posix.c @@ -13,7 +13,7 @@ #include #include -#ifdef HAVE_SYS_PRCTL_H +#ifdef HAVE_PRCTL # include #endif @@ -1017,11 +1017,11 @@ _ecore_exe_exec_it(const char *exe_cmd, } } -#ifdef HAVE_SYS_PRCTL_H +#ifdef HAVE_PRCTL if ((flags & ECORE_EXE_TERM_WITH_PARENT)) - { - prctl(PR_SET_PDEATHSIG, SIGTERM); - } + { + prctl(PR_SET_PDEATHSIG, SIGTERM); + } #endif if (!(flags & ECORE_EXE_NOT_LEADER)) setsid(); diff --git a/src/lib/ecore_x/xlib/ecore_x_vsync.c b/src/lib/ecore_x/xlib/ecore_x_vsync.c index 436645e63c..ee43406ab5 100644 --- a/src/lib/ecore_x/xlib/ecore_x_vsync.c +++ b/src/lib/ecore_x/xlib/ecore_x_vsync.c @@ -17,6 +17,10 @@ #include #include +#ifdef HAVE_PRCTL +# include +#endif + #define ECORE_X_VSYNC_DRM 1 static Ecore_X_Window vsync_root = 0; @@ -286,6 +290,9 @@ _drm_tick_core(void *data EINA_UNUSED, Ecore_Thread *thread) int tick = 0; eina_thread_name_set(eina_thread_self(), "Eanimator-vsync"); +#ifdef HAVE_PRCTL + prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0); +#endif while (!ecore_thread_check(thread)) { DBG("------- drm_event_is_busy=%i", drm_event_is_busy);