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
This commit is contained in:
Carsten Haitzler 2016-10-28 14:50:05 +09:00
parent ecc3e2fa51
commit 973eaedf51
5 changed files with 31 additions and 6 deletions

View File

@ -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

View File

@ -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 <sys/prctl.h>
]],
[[
prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
]])
])
dnl Macro that checks function availability
dnl
dnl EFL_CHECK_FUNC(EFL, FUNCTION)

View File

@ -30,6 +30,10 @@
#endif /* ! _WIN32 */
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
#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);

View File

@ -13,7 +13,7 @@
#include <sys/time.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_PRCTL_H
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
#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();

View File

@ -17,6 +17,10 @@
#include <sys/select.h>
#include <fcntl.h>
#ifdef HAVE_PRCTL
# include <sys/prctl.h>
#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);