[PATCH] configure: introduce --{enable, disable}-syscall-clock

Vignatti Tiago (Nokia-D/Helsinki) tiago.vignatti at nokia.com
Mon Mar 29 11:00:37 PDT 2010


On Mon, Mar 29, 2010 at 07:17:11PM +0200, Vignatti Tiago (Nokia-D/Helsinki) wrote:
> Some systems might not want to link against rt and pthread libraries simply to
> implement monotonic clock, inside GetTimeInMillis(). For those, use a direct
> syscall instead.
> 
> This patch keeps the new syscall version disabled by default - therefore not
> changing the original behaviour of the xserver build.
> 
> The main concern was regarding some eventual performance degradation when not
> going through optimized code in C library, or because syscall is varargs
> based. The simple program bellow (kudos to Adam Jackson) performs equally in
> the practice, for both syscall and C library implementation, when executed in
> several architectures:

oops, I should insert something like this snip in this part of the mini-program:

#ifdef SYSCALL_MONOTONIC_CLOCK
#define clock_gettime(a, b) syscall(SYS_clock_gettime, a, b)
#endif

> 
> int main(void) {
>     int i;
>     struct timespec tp;
> 
>     for (i = 0; i < 1e7; i++)
>     clock_gettime(CLOCK_MONOTONIC, &tp);
> 
>     return 0;
> }
> 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
> Myself, ajax, alanc and others discussed already on IRC about the performance
> degradation. We all ran the program above, obtaining equally results within
> different environments.
> 
> Besides, I think I could use AC_CHECK_FUNC(syscall) to check in fact if the
> call exists, but I thought that would be too much. Or not?
> 
> I guess also one will like to work out a bit the autoconf code. It's gigantic
> and confusing! But lets work on it in another patch instead :)
> 
> 
>  configure.ac            |   10 +++++++++-
>  include/dix-config.h.in |    3 +++
>  os/utils.c              |    5 +++++
>  3 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index a6b058d..8f42c60 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -632,6 +632,9 @@ AC_ARG_ENABLE(xaa,               AS_HELP_STRING([--enable-xaa], [Build XAA (defa
>  AC_ARG_ENABLE(vgahw,          AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes])
>  AC_ARG_ENABLE(vbe,            AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
>  AC_ARG_ENABLE(int10-module,     AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
> +dnl clock_gettime() uses rt library and some systems might not want to link
> +dnl against it, so the alternative is to use syscall directly.
> +AC_ARG_ENABLE(syscall-clock,    AS_HELP_STRING([--enable-syscall-clock], [Use syscall to build monotonic clock instead C library based version (default: disabled)]), [SYSCALL_CLOCK=$enableval], [SYSCALL_CLOCK=no])
>  
>  dnl DDXes.
>  AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
> @@ -912,7 +915,12 @@ AC_MSG_RESULT([$MONOTONIC_CLOCK])
>  
>  if test "x$MONOTONIC_CLOCK" = xyes; then
>      AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
> -    LIBS="$LIBS $CLOCK_LIBS"
> +    if test "x$SYSCALL_CLOCK" = xyes; then
> +        AC_DEFINE(SYSCALL_MONOTONIC_CLOCK, 1, 
> +                    [Use syscall based monotonic clock])
> +    else
> +        LIBS="$LIBS $CLOCK_LIBS"
> +    fi
>  fi
>  
>  AM_CONDITIONAL(XV, [test "x$XV" = xyes])
> diff --git a/include/dix-config.h.in b/include/dix-config.h.in
> index 32e88d9..1fd6310 100644
> --- a/include/dix-config.h.in
> +++ b/include/dix-config.h.in
> @@ -402,6 +402,9 @@
>  /* Have a monotonic clock from clock_gettime() */
>  #undef MONOTONIC_CLOCK
>  
> +/* Have a monotonic clock from a direct syscall */
> +#undef SYSCALL_MONOTONIC_CLOCK
> +
>  /* Define to 1 if the DTrace Xserver provider probes should be built in */
>  #undef XSERVER_DTRACE
>  
> diff --git a/os/utils.c b/os/utils.c
> index 5a5a203..a13ba3f 100644
> --- a/os/utils.c
> +++ b/os/utils.c
> @@ -124,6 +124,11 @@ __stdcall unsigned long GetTickCount(void);
>  #include "picture.h"
>  #endif
>  
> +#ifdef SYSCALL_MONOTONIC_CLOCK
> +#include <sys/syscall.h>
> +#define clock_gettime(a, b) syscall(SYS_clock_gettime, a, b)
> +#endif
> +
>  Bool noTestExtensions;
>  #ifdef COMPOSITE
>  Bool noCompositeExtension = FALSE;
> -- 
> 1.6.0.4
                            Tiago


More information about the xorg-devel mailing list