[ltt-dev] [UST PATCH] Add Systemtap to the tracepoint benchmark

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed Jan 26 22:01:17 EST 2011


* Julien Desfossez (julien.desfossez at polymtl.ca) wrote:
> Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
> ---
>  configure.ac                                      |   22 +++++++++++++++++++++
>  tests/tracepoint/benchmark/Makefile.am            |   13 ++++++++++++
>  tests/tracepoint/benchmark/probes.d               |    3 ++
>  tests/tracepoint/benchmark/testutrace.stp         |    5 ++-
>  tests/tracepoint/benchmark/trace.h                |    9 ++++++++
>  tests/tracepoint/benchmark/tracepoint_benchmark.c |    2 +
>  6 files changed, 52 insertions(+), 2 deletions(-)
>  create mode 100644 tests/tracepoint/benchmark/probes.d
>  create mode 100644 tests/tracepoint/benchmark/trace.h
> 
> diff --git a/configure.ac b/configure.ac
> index c7d966b..583cac3 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -107,6 +107,28 @@ esac
>  AC_SUBST(LIBFORMAT)
>  AC_MSG_RESULT($LIBFORMAT)
>  
> +### Systemtap header for benchmark ###

Is there a way we could do these checks within the benchmark makefile instead of
polluting the whole UST configure.ac ?

Mathieu

> +AC_MSG_CHECKING([whether to include systemtap tracing support in the tracepoint benchmark])
> +AC_ARG_ENABLE([systemtap],
> +			  [AS_HELP_STRING([--enable-systemtap],
> +			  [Enable inclusion of systemtap trace support in tracepoint benchmark])],
> +			  [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
> +AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
> +AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
> +
> +if test "x${ENABLE_SYSTEMTAP}" = xyes; then
> +	AC_CHECK_PROGS(DTRACE, dtrace)
> +	if test -z "$DTRACE"; then
> +		AC_MSG_ERROR([dtrace not found])
> +	fi
> +	AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
> +				[SDT_H_FOUND='no';
> +				 AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
> +	AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using  probes.])
> +fi
> +
> +### end Systemtap ###
> +
>  AC_CONFIG_FILES([
>  	Makefile
>  	doc/Makefile
> diff --git a/tests/tracepoint/benchmark/Makefile.am b/tests/tracepoint/benchmark/Makefile.am
> index 50f7bf5..82c9ac1 100644
> --- a/tests/tracepoint/benchmark/Makefile.am
> +++ b/tests/tracepoint/benchmark/Makefile.am
> @@ -5,3 +5,16 @@ tracepoint_benchmark_SOURCES = tracepoint_benchmark.c tracepoint_benchmark.h
>  tracepoint_benchmark_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
>  
>  CFLAGS_tracepoint_benchmark.o = -I$(src) -g
> +
> +if ENABLE_SYSTEMTAP
> +probes.h: probes.d
> +		$(DTRACE) -C -h -s $< -o $@
> +
> +probes.o: probes.d
> +		$(DTRACE) -C -G -s $< -o $@
> +
> +BUILT_SOURCES = probes.h
> +
> +tracepoint_benchmark_SOURCES += probes.d trace.h
> +tracepoint_benchmark_LDADD += probes.o
> +endif
> diff --git a/tests/tracepoint/benchmark/probes.d b/tests/tracepoint/benchmark/probes.d
> new file mode 100644
> index 0000000..0dc6a10
> --- /dev/null
> +++ b/tests/tracepoint/benchmark/probes.d
> @@ -0,0 +1,3 @@
> +provider tracepoint_benchmark {
> +	probe single_trace(int);
> +};
> diff --git a/tests/tracepoint/benchmark/testutrace.stp b/tests/tracepoint/benchmark/testutrace.stp
> index ad8ed68..cc79770 100644
> --- a/tests/tracepoint/benchmark/testutrace.stp
> +++ b/tests/tracepoint/benchmark/testutrace.stp
> @@ -1,4 +1,5 @@
> -probe process("./.libs/tracepoint_benchmark").function("single_trace") { 
> -	printf("%d : %s\n", gettimeofday_ns(), $$parms); 
> +probe process(".libs/tracepoint_benchmark").mark("single_trace")
> +{
> +	printf("%d : %d\n", gettimeofday_ns(), $arg1);
>  }
>  
> diff --git a/tests/tracepoint/benchmark/trace.h b/tests/tracepoint/benchmark/trace.h
> new file mode 100644
> index 0000000..044c99c
> --- /dev/null
> +++ b/tests/tracepoint/benchmark/trace.h
> @@ -0,0 +1,9 @@
> +#include "config.h"
> +#ifdef HAVE_SYSTEMTAP
> +// include the generated probes header and put markers in code
> +#include "probes.h"
> +#define TRACE(probe) probe
> +#else
> +// Wrap the probe to allow it to be removed when no systemtap available
> +#define TRACE(probe)
> +#endif
> diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.c b/tests/tracepoint/benchmark/tracepoint_benchmark.c
> index 8af4b84..7e443c2 100644
> --- a/tests/tracepoint/benchmark/tracepoint_benchmark.c
> +++ b/tests/tracepoint/benchmark/tracepoint_benchmark.c
> @@ -27,6 +27,7 @@
>  #include <stdio.h>
>  #include "tracepoint_benchmark.h"
>  #include <ust/type-serializer.h>
> +#include "trace.h"
>  
>  #define NR_EVENTS	10000000
>  
> @@ -54,6 +55,7 @@ static void __attribute__((constructor)) init()
>  
>  void single_trace(unsigned int v)
>  {
> +	TRACE(TRACEPOINT_BENCHMARK_SINGLE_TRACE(v));
>  	trace_ust_event(v);
>  }
>  
> -- 
> 1.7.3.5
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list