Vijay Anand | 27 Jun 12:12 2016
Picon

subbuffers count and size

Hi,

I have been trying to understand the impact of performance while logging user space program based on the subbuffer count and size.

I have a simple program logging 1 million traces and I dont seem to see any appreciable performance between the below two configurations.

a. default 4 subbufers 128KB each
b. 16 subbufers with 1024kB each.

Moreover I have been looking at the lttng-ust code to understand the performance impacts from the implementation and unable to comprehend what is documented at 


I see that channel_backend_init, _shm_object_table_alloc_shm seems to allocate one big shared memory chunk which again is subdivided into subbuffers with each subbuffer referenced using the subbufer index.

Further more lib_ring_buffer_write seems to find the subbuffer index and write "len" number of bytes into the subbuffer index.

Could anyone please enlighten me what is the overhead involved while switching from one subbufer to another as documented.

Regards,
Vijay
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Sebastien Boisvert | 27 Jun 04:01 2016

[lttng-ust GIT PULL v7] Doc: add a CMake example

Hi Mathieu,

This is the version 7 of my pull request; it contains a CMake example in C++ which uses LTTng-UST
instrumentation in 2 shared libraries. Yes, this is v7. I started to count from v1, but the first that you
reviewed was v5 I think. Philippe helped me with v1 through v4/v5.

I looked at the comments from your code reviews (on both v5 and v6 [1]).

I implemented all the required changes (acked-by, style, whitespace lines, and so on).

I went the extra mile too. I also converted the 4-space indentations to
tab indentations. Finally, I improved the tracepoints in the example such that it makes
more sense.

Philippe: I used the 'fixup' thing and I love it.

Mathieu, you can pull from

       https://github.com/sebhtml/lttng-ust.git  tags/for-compudj-cmake-example.v7

The changes can be viewed on github:

       https://github.com/sebhtml/lttng-ust/commits/for-compudj-cmake-example.v7

Let me know if there should be a v8, given my previous misuse of git acked-by and signed-off tags.

shortlog

Sebastien Boisvert (3):
       configure.ac: check cmake availability
       Doc: add CMake example
       Doc: ship cmake example with 'make distcheck'

diffstat

  configure.ac                                                          |   3 ++
  doc/examples/Makefile.am                                              |  38 ++++++++++++++++++++--
  doc/examples/cmake-multiple-shared-libraries/CMakeLists.txt           |  23 ++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/README.md                |  52 ++++++++++++++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/aligner-lib.cpp          |  34 ++++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/aligner-lib.h            |  30 ++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/aligner.cpp              |  30 ++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/cmake/FindLTTngUST.cmake | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/tester-lib.cpp           |  31 ++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/tester-lib.h             |  30 ++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/tester.cpp               |  35 +++++++++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/trace.sh                 |   9 ++++++
  doc/examples/cmake-multiple-shared-libraries/tracepoint-provider.cpp  |  26 +++++++++++++++
  doc/examples/cmake-multiple-shared-libraries/tracepoint-provider.h    |  60 +++++++++++++++++++++++++++++++++++
  14 files changed, 510 insertions(+), 2 deletions(-)

References

[1] https://lists.lttng.org/pipermail/lttng-dev/2016-June/026255.html
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Julien Desfossez | 24 Jun 00:52 2016

[PATCH lttng-ust v2 1/2] Keep perf context FD open for other architectures

Instead of closing the perf context after the page has been mapped, keep
it open so it can be used with the read() system call if the
architecture does not support direct access from user-space.

Signed-off-by: Julien Desfossez <jdesfossez <at> efficios.com>
---
 liblttng-ust/lttng-context-perf-counters.c | 53 +++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/liblttng-ust/lttng-context-perf-counters.c b/liblttng-ust/lttng-context-perf-counters.c
index 97ddf97..725b1b4 100644
--- a/liblttng-ust/lttng-context-perf-counters.c
+++ b/liblttng-ust/lttng-context-perf-counters.c
 <at>  <at>  -55,6 +55,7  <at>  <at>  struct lttng_perf_counter_thread_field {
 	struct perf_event_mmap_page *pc;
 	struct cds_list_head thread_field_node;	/* Per-field list of thread fields (node) */
 	struct cds_list_head rcu_field_node;	/* RCU per-thread list of fields (node) */
+	int fd;					/* Perf FD */
 };

 struct lttng_perf_counter_thread {
 <at>  <at>  -131,24 +132,50  <at>  <at>  int sys_perf_event_open(struct perf_event_attr *attr,
 }

 static
-struct perf_event_mmap_page *setup_perf(struct perf_event_attr *attr)
+int open_perf_fd(struct perf_event_attr *attr)
 {
-	void *perf_addr;
-	int fd, ret;
+	int fd;

 	fd = sys_perf_event_open(attr, 0, -1, -1, 0);
 	if (fd < 0)
-		return NULL;
+		return -1;
+
+	return fd;
+}
+
+static
+struct perf_event_mmap_page *setup_perf(
+		struct lttng_perf_counter_thread_field *thread_field)
+{
+	void *perf_addr;

 	perf_addr = mmap(NULL, sizeof(struct perf_event_mmap_page),
-			PROT_READ, MAP_SHARED, fd, 0);
+			PROT_READ, MAP_SHARED, thread_field->fd, 0);
 	if (perf_addr == MAP_FAILED)
-		return NULL;
+		perf_addr = NULL;
+
+	/* No need to keep the FD open on x86 */
+#if defined(__x86_64__) || defined(__i386__)
+	close_perf_fd(thread_field->fd);
+	thread_field->fd = -1;
+#endif
+
+end:
+	return perf_addr;
+}
+
+static
+void close_perf_fd(int fd)
+{
+	int ret;
+
+	if (fd < 0)
+		return;
+
 	ret = close(fd);
 	if (ret) {
 		perror("Error closing LTTng-UST perf memory mapping FD");
 	}
-	return perf_addr;
 }

 static
 <at>  <at>  -221,7 +248,9  <at>  <at>  struct lttng_perf_counter_thread_field *
 	if (!thread_field)
 		abort();
 	thread_field->field = perf_field;
-	thread_field->pc = setup_perf(&perf_field->attr);
+	thread_field->fd = open_perf_fd(&perf_field->attr);
+	if (thread_field->fd >= 0)
+		thread_field->pc = setup_perf(thread_field);
 	/* Note: thread_field->pc can be NULL if setup_perf() fails. */
 	ust_lock_nocheck();
 	cds_list_add_rcu(&thread_field->rcu_field_node,
 <at>  <at>  -293,6 +322,7  <at>  <at>  static
 void lttng_destroy_perf_thread_field(
 		struct lttng_perf_counter_thread_field *thread_field)
 {
+	close_perf_fd(thread_field->fd);
 	unmap_perf_page(thread_field->pc);
 	cds_list_del_rcu(&thread_field->rcu_field_node);
 	cds_list_del(&thread_field->thread_field_node);
 <at>  <at>  -341,7 +371,6  <at>  <at>  int lttng_add_perf_counter_to_ctx(uint32_t type,
 {
 	struct lttng_ctx_field *field;
 	struct lttng_perf_counter_field *perf_field;
-	struct perf_event_mmap_page *tmp_pc;
 	char *name_alloc;
 	int ret;

 <at>  <at>  -389,12 +418,12  <at>  <at>  int lttng_add_perf_counter_to_ctx(uint32_t type,
 	field->u.perf_counter = perf_field;

 	/* Ensure that this perf counter can be used in this process. */
-	tmp_pc = setup_perf(&perf_field->attr);
-	if (!tmp_pc) {
+	ret = open_perf_fd(&perf_field->attr);
+	if (ret < 0) {
 		ret = -ENODEV;
 		goto setup_error;
 	}
-	unmap_perf_page(tmp_pc);
+	close_perf_fd(ret);

 	/*
 	 * Contexts can only be added before tracing is started, so we
--

-- 
1.9.1

_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Julien Desfossez | 23 Jun 22:15 2016

[PATCH lttng-ust 1/2] Keep perf context FD open for other architectures

Instead of closing the perf context after the page has been mapped, keep
it open so it can be used with the read() system call if the
architecture does not support direct access from user-space.

Signed-off-by: Julien Desfossez <jdesfossez <at> efficios.com>
---
 liblttng-ust/lttng-context-perf-counters.c | 53 +++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/liblttng-ust/lttng-context-perf-counters.c b/liblttng-ust/lttng-context-perf-counters.c
index 97ddf97..725b1b4 100644
--- a/liblttng-ust/lttng-context-perf-counters.c
+++ b/liblttng-ust/lttng-context-perf-counters.c
 <at>  <at>  -55,6 +55,7  <at>  <at>  struct lttng_perf_counter_thread_field {
 	struct perf_event_mmap_page *pc;
 	struct cds_list_head thread_field_node;	/* Per-field list of thread fields (node) */
 	struct cds_list_head rcu_field_node;	/* RCU per-thread list of fields (node) */
+	int fd;					/* Perf FD */
 };

 struct lttng_perf_counter_thread {
 <at>  <at>  -131,24 +132,50  <at>  <at>  int sys_perf_event_open(struct perf_event_attr *attr,
 }

 static
-struct perf_event_mmap_page *setup_perf(struct perf_event_attr *attr)
+int open_perf_fd(struct perf_event_attr *attr)
 {
-	void *perf_addr;
-	int fd, ret;
+	int fd;

 	fd = sys_perf_event_open(attr, 0, -1, -1, 0);
 	if (fd < 0)
-		return NULL;
+		return -1;
+
+	return fd;
+}
+
+static
+struct perf_event_mmap_page *setup_perf(
+		struct lttng_perf_counter_thread_field *thread_field)
+{
+	void *perf_addr;

 	perf_addr = mmap(NULL, sizeof(struct perf_event_mmap_page),
-			PROT_READ, MAP_SHARED, fd, 0);
+			PROT_READ, MAP_SHARED, thread_field->fd, 0);
 	if (perf_addr == MAP_FAILED)
-		return NULL;
+		perf_addr = NULL;
+
+	/* No need to keep the FD open on x86 */
+#if defined(__x86_64__) || defined(__i386__)
+	close_perf_fd(thread_field->fd);
+	thread_field->fd = -1;
+#endif
+
+end:
+	return perf_addr;
+}
+
+static
+void close_perf_fd(int fd)
+{
+	int ret;
+
+	if (fd < 0)
+		return;
+
 	ret = close(fd);
 	if (ret) {
 		perror("Error closing LTTng-UST perf memory mapping FD");
 	}
-	return perf_addr;
 }

 static
 <at>  <at>  -221,7 +248,9  <at>  <at>  struct lttng_perf_counter_thread_field *
 	if (!thread_field)
 		abort();
 	thread_field->field = perf_field;
-	thread_field->pc = setup_perf(&perf_field->attr);
+	thread_field->fd = open_perf_fd(&perf_field->attr);
+	if (thread_field->fd >= 0)
+		thread_field->pc = setup_perf(thread_field);
 	/* Note: thread_field->pc can be NULL if setup_perf() fails. */
 	ust_lock_nocheck();
 	cds_list_add_rcu(&thread_field->rcu_field_node,
 <at>  <at>  -293,6 +322,7  <at>  <at>  static
 void lttng_destroy_perf_thread_field(
 		struct lttng_perf_counter_thread_field *thread_field)
 {
+	close_perf_fd(thread_field->fd);
 	unmap_perf_page(thread_field->pc);
 	cds_list_del_rcu(&thread_field->rcu_field_node);
 	cds_list_del(&thread_field->thread_field_node);
 <at>  <at>  -341,7 +371,6  <at>  <at>  int lttng_add_perf_counter_to_ctx(uint32_t type,
 {
 	struct lttng_ctx_field *field;
 	struct lttng_perf_counter_field *perf_field;
-	struct perf_event_mmap_page *tmp_pc;
 	char *name_alloc;
 	int ret;

 <at>  <at>  -389,12 +418,12  <at>  <at>  int lttng_add_perf_counter_to_ctx(uint32_t type,
 	field->u.perf_counter = perf_field;

 	/* Ensure that this perf counter can be used in this process. */
-	tmp_pc = setup_perf(&perf_field->attr);
-	if (!tmp_pc) {
+	ret = open_perf_fd(&perf_field->attr);
+	if (ret < 0) {
 		ret = -ENODEV;
 		goto setup_error;
 	}
-	unmap_perf_page(tmp_pc);
+	close_perf_fd(ret);

 	/*
 	 * Contexts can only be added before tracing is started, so we
--

-- 
1.9.1

_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Julien Desfossez | 23 Jun 22:08 2016

[RELEASE] LTTng-analyses v0.4.4

Hi everyone,

We are glad to announce the first stable release of the lttng-analyses !
https://github.com/lttng/lttng-analyses

This project is a collection of tools to extract metrics and high-level
informations from offline LTTng kernel traces to investigate complex
problems.

This is a release from the new stable-0.4 branch created to support
users of the integration with Trace Compass 2.0.

So the changes are only backports of fixes already in master and v0.5,
the most interesting ones are:
- backport of the progress bar in MI mode,
- fix the schedfreq analyse in MI,
- Travis CI integration.

We encourage you to test it and check out the integration in Trace
Compass to see the power of combining an interactive graphical tool to
these analyses.

As always, we appreciate all kinds of feedback, use-cases and real-world
experiences, so please test it and let us know what you think about it.

Thanks,

Julien
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Aravind HT | 23 Jun 08:03 2016
Picon

lttng-ust deadlock.

Hi,

I am facing a deadlock in lttng-ust. Though my version is 2.6 I can see that this is applicable to the the latest UST version also.

Deadlocks happening due to these two flows
1. lttng_fix_pending_events () -> ustcomm_register_event () -> calloc() -> __GI___dl_iterate_phdr()
     Note that Im not using the libc wrapper, but using a proprietary version for malloc() family which can call __GI___dl_iterate_phdr() .
     This flow takes up UST_LOCK() before calling __GI___dl_iterate_phdr(), and __GI___dl_iterate_phdr() has its own mutex( lets say DL_MUTEX).
2. lttng_ust_baddr_statedump() calls  __GI___dl_iterate_phdr() which first takes up DL_MUTEX and then takes the UST_LOCK() in the call back function as extract_soinfo_events()->trace_baddr()->UST_LOCK().

Since the order is reversed, it can lead to deadlock. To fix this, do you think taking UST_LOCK in  lttng_ust_baddr_statedump() ( surrounding __GI___dl_iterate_phdr() call ) instead of the call back function is proper ?

In the latest version of UST, I see some changes/refactoring and that the UST_LOCK has been removed from trace_baddr() and moved one call up, but still is being called in the call back function after __GI___dl_iterate_phdr() is called.


Regards,
Aravind.
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Sebastien Boisvert | 23 Jun 04:33 2016

[lttng-ust GIT PULL v6] Doc: add a CMake example

Hi Mathieu,

I have 3 commits since 21ddb8ec9689e02944dae9cd4e5aba1ca2ab0d5b.

You can pull from

      https://github.com/sebhtml/lttng-ust.git  tags/for-compudj-cmake-example.v6

The changes can be viewed on github:

      https://github.com/sebhtml/lttng-ust/commits/for-compudj-cmake-example.v6

Sebastien Boisvert (3):
       configure.ac: check cmake availability
       Doc: add CMake example
       Doc: ship cmake example with 'make distcheck'
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Mathieu Desnoyers | 23 Jun 03:52 2016
Gravatar

Re: [PATCH urcu] Clean pthread detection


----- On Jun 22, 2016, at 6:36 PM, Michael Jeanson mjeanson <at> efficios.com wrote:

Hi Michael,

Can you re-send this patch CCing lttng-dev, and Charles Briere too,
so he can try it out on Android ?

Thanks,

Mathieu

> Signed-off-by: Michael Jeanson <mjeanson <at> efficios.com>
> ---
> Makefile.am                  |   3 -
> configure.ac                 |  14 --
> m4/ax_pthread.m4             | 385 ++++++++++++++++++++++++++++++-------------
> tests/benchmark/Makefile.am  |   3 -
> tests/regression/Makefile.am |   3 -
> tests/unit/Makefile.am       |   3 -
> 6 files changed, 269 insertions(+), 142 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 8e25fd9..7b21321 100644
> --- a/Makefile.am
> +++ b/Makefile.am
>  <at>  <at>  -5,9 +5,6  <at>  <at>  AM_CPPFLAGS = -I$(top_builddir)/urcu
> #Add the -version-info directly here since we are only building
> # library that use the version-info
> AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION)
> -if !LIBC_INCLUDES_PTHREAD
> -AM_LDFLAGS+=-lpthread
> -endif
> if USE_CYGWIN
> AM_LDFLAGS+=-no-undefined
> endif
> diff --git a/configure.ac b/configure.ac
> index 639b984..95b0515 100644
> --- a/configure.ac
> +++ b/configure.ac
>  <at>  <at>  -140,11 +140,6  <at>  <at>  AS_CASE([$host_cpu],
> 	[ARCHTYPE="unknown"]
> )
> 
> -AS_CASE([$host],[*-*-linux-androideabi],
> -	[AM_CONDITIONAL(TARGET_IS_ANDROID, true)],
> -	[AM_CONDITIONAL(TARGET_IS_ANDROID, false)]
> -)
> -
> AS_CASE([$host],[*-cygwin*],
> 	[AM_CONDITIONAL(USE_CYGWIN, true)],
> 	[AM_CONDITIONAL(USE_CYGWIN, false)]
>  <at>  <at>  -236,15 +231,6  <at>  <at>  AC_SEARCH_LIBS([clock_gettime], [rt], [
> 	AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1])
> ], [])
> 
> -# Check for pthread
> -AC_CHECK_LIB([pthread], [pthread_create],
> -	[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)],
> -	[AC_CHECK_LIB([c], [pthread_create],
> -		[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)],
> -		[AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its
> location.])]
> -	)]
> -)
> -
> AM_CONDITIONAL([COMPAT_FUTEX], [test "x$compat_futex_test" = "x1"])
> AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = "xx86compat"])
> AM_CONDITIONAL([NO_SHARED], [test "x$enable_shared" = "xno"])
> diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
> index d383ad5..4c4051e 100644
> --- a/m4/ax_pthread.m4
> +++ b/m4/ax_pthread.m4
>  <at>  <at>  -19,10 +19,10  <at>  <at> 
> #   is necessary on AIX to use the special cc_r compiler alias.)
> #
> #   NOTE: You are assumed to not only compile your program with these flags,
> -#   but also link it with them as well. e.g. you should link with
> +#   but also to link with them as well. For example, you might link with
> #   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
> #
> -#   If you are only building threads programs, you may wish to use these
> +#   If you are only building threaded programs, you may wish to use these
> #   variables in your default LIBS, CFLAGS, and CC:
> #
> #     LIBS="$PTHREAD_LIBS $LIBS"
>  <at>  <at>  -30,8 +30,8  <at>  <at> 
> #     CC="$PTHREAD_CC"
> #
> #   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
> -#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
> -#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
> +#   has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
> +#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
> #
> #   Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
> #   PTHREAD_PRIO_INHERIT symbol is defined when compiling with
>  <at>  <at>  -82,35 +82,40  <at>  <at> 
> #   modified version of the Autoconf Macro, you may extend this special
> #   exception to the GPL to apply to your modified version as well.
> 
> -#serial 21
> +#serial 23
> 
> AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
> AC_DEFUN([AX_PTHREAD], [
> AC_REQUIRE([AC_CANONICAL_HOST])
> +AC_REQUIRE([AC_PROG_CC])
> +AC_REQUIRE([AC_PROG_SED])
> AC_LANG_PUSH([C])
> ax_pthread_ok=no
> 
> # We used to check for pthread.h first, but this fails if pthread.h
> -# requires special compiler flags (e.g. on True64 or Sequent).
> +# requires special compiler flags (e.g. on Tru64 or Sequent).
> # It gets checked for in the link test anyway.
> 
> # First of all, check if the user has set any of the PTHREAD_LIBS,
> # etcetera environment variables, and if threads linking works using
> # them:
> -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
> -        save_CFLAGS="$CFLAGS"
> +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
> +        ax_pthread_save_CC="$CC"
> +        ax_pthread_save_CFLAGS="$CFLAGS"
> +        ax_pthread_save_LIBS="$LIBS"
> +        AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
>         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
> -        save_LIBS="$LIBS"
>         LIBS="$PTHREAD_LIBS $LIBS"
> -        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with
> CFLAGS=$PTHREAD_CFLAGS])
> -        AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
> +        AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS
> $PTHREAD_LIBS])
> +        AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
>         AC_MSG_RESULT([$ax_pthread_ok])
> -        if test x"$ax_pthread_ok" = xno; then
> +        if test "x$ax_pthread_ok" = "xno"; then
>                 PTHREAD_LIBS=""
>                 PTHREAD_CFLAGS=""
>         fi
> -        LIBS="$save_LIBS"
> -        CFLAGS="$save_CFLAGS"
> +        CC="$ax_pthread_save_CC"
> +        CFLAGS="$ax_pthread_save_CFLAGS"
> +        LIBS="$ax_pthread_save_LIBS"
> fi
> 
> # We must check for the threads library under a number of different
>  <at>  <at>  -123,7 +128,7  <at>  <at>  fi
> # which indicates that we try without any flags at all, and "pthread-config"
> # which is a program returning the flags for the Pth emulation library.
> 
> -ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads
> -mthreads pthread --thread-safe -mt pthread-config"
> +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread
> --thread-safe -mt pthread-config"
> 
> # The ordering *is* (sometimes) important.  Some notes on the
> # individual items follow:
>  <at>  <at>  -132,82 +137,225  <at>  <at>  ax_pthread_flags="pthreads none -Kthread -kthread lthread
> -pthread -pthreads -mt
> # none: in case threads are in libc; should be tried before -Kthread and
> #       other compiler flags to prevent continual compiler warnings
> # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
> -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
> -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
> -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
> -# -pthreads: Solaris/gcc
> -# -mthreads: Mingw32/gcc, Lynx/gcc
> +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
> +#           (Note: HP C rejects this with "bad form for `-t' option")
> +# -pthreads: Solaris/gcc (Note: HP C also rejects)
> # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
> -#      doesn't hurt to check since this sometimes defines pthreads too;
> -#      also defines -D_REENTRANT)
> -#      ... -mt is also the pthreads flag for HP/aCC
> +#      doesn't hurt to check since this sometimes defines pthreads and
> +#      -D_REENTRANT too), HP C (must be checked before -lpthread, which
> +#      is present but should not be used directly; and before -mthreads,
> +#      because the compiler interprets this as "-mt" + "-hreads")
> +# -mthreads: Mingw32/gcc, Lynx/gcc
> # pthread: Linux, etcetera
> # --thread-safe: KAI C++
> # pthread-config: use pthread-config program (for GNU Pth library)
> 
> -case ${host_os} in
> +case $host_os in
> +
> +        freebsd*)
> +
> +        # -kthread: FreeBSD kernel threads (preferred to -pthread since
> SMP-able)
> +        # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
> +
> +        ax_pthread_flags="-kthread lthread $ax_pthread_flags"
> +        ;;
> +
> +        hpux*)
> +
> +        # From the cc(1) man page: "[-mt] Sets various -D flags to enable
> +        # multi-threading and also sets -lpthread."
> +
> +        ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
> +        ;;
> +
> +        openedition*)
> +
> +        # IBM z/OS requires a feature-test macro to be defined in order to
> +        # enable POSIX threads at all, so give the user a hint if this is
> +        # not set. (We don't define these ourselves, as they can affect
> +        # other portions of the system API in unpredictable ways.)
> +
> +        AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
> +            [
> +#            if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
> +             AX_PTHREAD_ZOS_MISSING
> +#            endif
> +            ],
> +            [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or
> -D_UNIX03_THREADS to enable pthreads support.])])
> +        ;;
> +
>         solaris*)
> 
>         # On Solaris (at least, for some versions), libc contains stubbed
>         # (non-functional) versions of the pthreads routines, so link-based
> -        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
> -        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
> -        # a function called by this macro, so we could check for that, but
> -        # who knows whether they'll stub that too in a future libc.)  So,
> -        # we'll just look for -pthreads and -lpthread first:
> +        # tests will erroneously succeed. (N.B.: The stubs are missing
> +        # pthread_cleanup_push, or rather a function called by this macro,
> +        # so we could check for that, but who knows whether they'll stub
> +        # that too in a future libc.)  So we'll check first for the
> +        # standard Solaris way of linking pthreads (-mt -lpthread).
> +
> +        ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
> +        ;;
> +esac
> +
> +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
> 
> -        ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
> +AS_IF([test "x$GCC" = "xyes"],
> +      [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
> +
> +# The presence of a feature test macro requesting re-entrant function
> +# definitions is, on some systems, a strong hint that pthreads support is
> +# correctly enabled
> +
> +case $host_os in
> +        darwin* | hpux* | linux* | osf* | solaris*)
> +        ax_pthread_check_macro="_REENTRANT"
>         ;;
> 
> -        darwin*)
> -        ax_pthread_flags="-pthread $ax_pthread_flags"
> +        aix*)
> +        ax_pthread_check_macro="_THREAD_SAFE"
> +        ;;
> +
> +        *)
> +        ax_pthread_check_macro="--"
>         ;;
> esac
> +AS_IF([test "x$ax_pthread_check_macro" = "x--"],
> +      [ax_pthread_check_cond=0],
> +      [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
> +
> +# Are we compiling with Clang?
> +
> +AC_CACHE_CHECK([whether $CC is Clang],
> +    [ax_cv_PTHREAD_CLANG],
> +    [ax_cv_PTHREAD_CLANG=no
> +     # Note that Autoconf sets GCC=yes for Clang as well as GCC
> +     if test "x$GCC" = "xyes"; then
> +        AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
> +            [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
> +#            if defined(__clang__) && defined(__llvm__)
> +             AX_PTHREAD_CC_IS_CLANG
> +#            endif
> +            ],
> +            [ax_cv_PTHREAD_CLANG=yes])
> +     fi
> +    ])
> +ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
> +
> +ax_pthread_clang_warning=no
> +
> +# Clang needs special handling, because older versions handle the -pthread
> +# option in a rather... idiosyncratic way
> +
> +if test "x$ax_pthread_clang" = "xyes"; then
> +
> +        # Clang takes -pthread; it has never supported any other flag
> +
> +        # (Note 1: This will need to be revisited if a system that Clang
> +        # supports has POSIX threads in a separate library.  This tends not
> +        # to be the way of modern systems, but it's conceivable.)
> +
> +        # (Note 2: On some systems, notably Darwin, -pthread is not needed
> +        # to get POSIX threads support; the API is always present and
> +        # active.  We could reasonably leave PTHREAD_CFLAGS empty.  But
> +        # -pthread does define _REENTRANT, and while the Darwin headers
> +        # ignore this macro, third-party headers might not.)
> +
> +        PTHREAD_CFLAGS="-pthread"
> +        PTHREAD_LIBS=
> +
> +        ax_pthread_ok=yes
> +
> +        # However, older versions of Clang make a point of warning the user
> +        # that, in an invocation where only linking and no compilation is
> +        # taking place, the -pthread option has no effect ("argument unused
> +        # during compilation").  They expect -pthread to be passed in only
> +        # when source code is being compiled.
> +        #
> +        # Problem is, this is at odds with the way Automake and most other
> +        # C build frameworks function, which is that the same flags used in
> +        # compilation (CFLAGS) are also used in linking.  Many systems
> +        # supported by AX_PTHREAD require exactly this for POSIX threads
> +        # support, and in fact it is often not straightforward to specify a
> +        # flag that is used only in the compilation phase and not in
> +        # linking.  Such a scenario is extremely rare in practice.
> +        #
> +        # Even though use of the -pthread flag in linking would only print
> +        # a warning, this can be a nuisance for well-run software projects
> +        # that build with -Werror.  So if the active version of Clang has
> +        # this misfeature, we search for an option to squash it.
> +
> +        AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused"
> warning when linking with -pthread],
> +            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
> +            [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
> +             # Create an alternate version of $ac_link that compiles and
> +             # links in two steps (.c -> .o, .o -> exe) instead of one
> +             # (.c -> exe), because the warning occurs only in the second
> +             # step
> +             ax_pthread_save_ac_link="$ac_link"
> +             ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
> +             ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
> +             ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) &&
> ($ax_pthread_link_step)"
> +             ax_pthread_save_CFLAGS="$CFLAGS"
> +             for ax_pthread_try in '' -Qunused-arguments
> -Wno-unused-command-line-argument unknown; do
> +                AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
> +                CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try
> -pthread $ax_pthread_save_CFLAGS"
> +                ac_link="$ax_pthread_save_ac_link"
> +                AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
> +                    [ac_link="$ax_pthread_2step_ac_link"
> +                     AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return
> 0;}]])],
> +                         [break])
> +                    ])
> +             done
> +             ac_link="$ax_pthread_save_ac_link"
> +             CFLAGS="$ax_pthread_save_CFLAGS"
> +             AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
> +             ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
> +            ])
> 
> -# Clang doesn't consider unrecognized options an error unless we specify
> -# -Werror. We throw in some extra Clang-specific options to ensure that
> -# this doesn't happen for GCC, which also accepts -Werror.
> +        case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
> +                no | unknown) ;;
> +                *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG
> $PTHREAD_CFLAGS" ;;
> +        esac
> 
> -AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
> -save_CFLAGS="$CFLAGS"
> -ax_pthread_extra_flags="-Werror"
> -CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option
> -Wsizeof-array-argument"
> -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
> -                  [AC_MSG_RESULT([yes])],
> -                  [ax_pthread_extra_flags=
> -                   AC_MSG_RESULT([no])])
> -CFLAGS="$save_CFLAGS"
> +fi # $ax_pthread_clang = yes
> 
> -if test x"$ax_pthread_ok" = xno; then
> -for flag in $ax_pthread_flags; do
> +if test "x$ax_pthread_ok" = "xno"; then
> +for ax_pthread_try_flag in $ax_pthread_flags; do
> 
> -        case $flag in
> +        case $ax_pthread_try_flag in
>                 none)
>                 AC_MSG_CHECKING([whether pthreads work without any flags])
>                 ;;
> 
> +                -mt,pthread)
> +                AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
> +                PTHREAD_CFLAGS="-mt"
> +                PTHREAD_LIBS="-lpthread"
> +                ;;
> +
>                 -*)
> -                AC_MSG_CHECKING([whether pthreads work with $flag])
> -                PTHREAD_CFLAGS="$flag"
> +                AC_MSG_CHECKING([whether pthreads work with
> $ax_pthread_try_flag])
> +                PTHREAD_CFLAGS="$ax_pthread_try_flag"
>                 ;;
> 
>                 pthread-config)
>                 AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
> -                if test x"$ax_pthread_config" = xno; then continue; fi
> +                AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
>                 PTHREAD_CFLAGS="`pthread-config --cflags`"
>                 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
>                 ;;
> 
>                 *)
> -                AC_MSG_CHECKING([for the pthreads library -l$flag])
> -                PTHREAD_LIBS="-l$flag"
> +                AC_MSG_CHECKING([for the pthreads library
> -l$ax_pthread_try_flag])
> +                PTHREAD_LIBS="-l$ax_pthread_try_flag"
>                 ;;
>         esac
> 
> -        save_LIBS="$LIBS"
> -        save_CFLAGS="$CFLAGS"
> +        ax_pthread_save_CFLAGS="$CFLAGS"
> +        ax_pthread_save_LIBS="$LIBS"
> +        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
>         LIBS="$PTHREAD_LIBS $LIBS"
> -        CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
> 
>         # Check for various functions.  We must include pthread.h,
>         # since some functions may be macros.  (On the Sequent, we
>  <at>  <at>  -218,7 +366,11  <at>  <at>  for flag in $ax_pthread_flags; do
>         # pthread_cleanup_push because it is one of the few pthread
>         # functions on Solaris that doesn't have a non-functional libc stub.
>         # We try pthread_create on general principles.
> +
>         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
> +#                       if $ax_pthread_check_cond
> +#                        error "$ax_pthread_check_macro must be defined"
> +#                       endif
>                         static void routine(void *a) { a = 0; }
>                         static void *start_routine(void *a) { return a; }],
>                        [pthread_t th; pthread_attr_t attr;
>  <at>  <at>  -227,16 +379,14  <at>  <at>  for flag in $ax_pthread_flags; do
>                         pthread_attr_init(&attr);
>                         pthread_cleanup_push(routine, 0);
>                         pthread_cleanup_pop(0) /* ; */])],
> -                [ax_pthread_ok=yes],
> -                [])
> +            [ax_pthread_ok=yes],
> +            [])
> 
> -        LIBS="$save_LIBS"
> -        CFLAGS="$save_CFLAGS"
> +        CFLAGS="$ax_pthread_save_CFLAGS"
> +        LIBS="$ax_pthread_save_LIBS"
> 
>         AC_MSG_RESULT([$ax_pthread_ok])
> -        if test "x$ax_pthread_ok" = xyes; then
> -                break;
> -        fi
> +        AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
> 
>         PTHREAD_LIBS=""
>         PTHREAD_CFLAGS=""
>  <at>  <at>  -244,71 +394,74  <at>  <at>  done
> fi
> 
> # Various other checks:
> -if test "x$ax_pthread_ok" = xyes; then
> -        save_LIBS="$LIBS"
> -        LIBS="$PTHREAD_LIBS $LIBS"
> -        save_CFLAGS="$CFLAGS"
> +if test "x$ax_pthread_ok" = "xyes"; then
> +        ax_pthread_save_CFLAGS="$CFLAGS"
> +        ax_pthread_save_LIBS="$LIBS"
>         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
> +        LIBS="$PTHREAD_LIBS $LIBS"
> 
>         # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
> -        AC_MSG_CHECKING([for joinable pthread attribute])
> -        attr_name=unknown
> -        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
> -            AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
> -                           [int attr = $attr; return attr /* ; */])],
> -                [attr_name=$attr; break],
> -                [])
> -        done
> -        AC_MSG_RESULT([$attr_name])
> -        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
> -            AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
> -                               [Define to necessary symbol if this constant
> -                                uses a non-standard name on your system.])
> -        fi
> -
> -        AC_MSG_CHECKING([if more special flags are required for pthreads])
> -        flag=no
> -        case ${host_os} in
> -            aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
> -            osf* | hpux*) flag="-D_REENTRANT";;
> -            solaris*)
> -            if test "$GCC" = "yes"; then
> -                flag="-D_REENTRANT"
> -            else
> -                # TODO: What about Clang on Solaris?
> -                flag="-mt -D_REENTRANT"
> -            fi
> -            ;;
> -        esac
> -        AC_MSG_RESULT([$flag])
> -        if test "x$flag" != xno; then
> -            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
> -        fi
> +        AC_CACHE_CHECK([for joinable pthread attribute],
> +            [ax_cv_PTHREAD_JOINABLE_ATTR],
> +            [ax_cv_PTHREAD_JOINABLE_ATTR=unknown
> +             for ax_pthread_attr in PTHREAD_CREATE_JOINABLE
> PTHREAD_CREATE_UNDETACHED; do
> +                 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
> +                                                 [int attr = $ax_pthread_attr;
> return attr /* ; */])],
> +                                [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr;
> break],
> +                                [])
> +             done
> +            ])
> +        AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
> +               test "x$ax_cv_PTHREAD_JOINABLE_ATTR" !=
> "xPTHREAD_CREATE_JOINABLE" && \
> +               test "x$ax_pthread_joinable_attr_defined" != "xyes"],
> +              [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
> +                                  [$ax_cv_PTHREAD_JOINABLE_ATTR],
> +                                  [Define to necessary symbol if this constant
> +                                   uses a non-standard name on your system.])
> +               ax_pthread_joinable_attr_defined=yes
> +              ])
> +
> +        AC_CACHE_CHECK([whether more special flags are required for pthreads],
> +            [ax_cv_PTHREAD_SPECIAL_FLAGS],
> +            [ax_cv_PTHREAD_SPECIAL_FLAGS=no
> +             case $host_os in
> +             solaris*)
> +             ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
> +             ;;
> +             esac
> +            ])
> +        AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
> +               test "x$ax_pthread_special_flags_added" != "xyes"],
> +              [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
> +               ax_pthread_special_flags_added=yes])
> 
>         AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
> -            [ax_cv_PTHREAD_PRIO_INHERIT], [
> -                AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
> -                                                [[int i =
> PTHREAD_PRIO_INHERIT;]])],
> -                    [ax_cv_PTHREAD_PRIO_INHERIT=yes],
> -                    [ax_cv_PTHREAD_PRIO_INHERIT=no])
> +            [ax_cv_PTHREAD_PRIO_INHERIT],
> +            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
> +                                             [[int i =
> PTHREAD_PRIO_INHERIT;]])],
> +                            [ax_cv_PTHREAD_PRIO_INHERIT=yes],
> +                            [ax_cv_PTHREAD_PRIO_INHERIT=no])
>             ])
> -        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
> -            [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have
> PTHREAD_PRIO_INHERIT.])])
> +        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
> +               test "x$ax_pthread_prio_inherit_defined" != "xyes"],
> +              [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have
> PTHREAD_PRIO_INHERIT.])
> +               ax_pthread_prio_inherit_defined=yes
> +              ])
> 
> -        LIBS="$save_LIBS"
> -        CFLAGS="$save_CFLAGS"
> +        CFLAGS="$ax_pthread_save_CFLAGS"
> +        LIBS="$ax_pthread_save_LIBS"
> 
>         # More AIX lossage: compile with *_r variant
> -        if test "x$GCC" != xyes; then
> +        if test "x$GCC" != "xyes"; then
>             case $host_os in
>                 aix*)
>                 AS_CASE(["x/$CC"],
> -
> [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
> -                  [#handle absolute path differently from PATH based program
> lookup
> -                   AS_CASE(["x$CC"],
> -                     [x/*],
> -
> [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
> -                     [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
> +
> [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
> +                    [#handle absolute path differently from PATH based program
> lookup
> +                     AS_CASE(["x$CC"],
> +                         [x/*],
> +
> [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
> +                         [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
>                 ;;
>             esac
>         fi
>  <at>  <at>  -321,7 +474,7  <at>  <at>  AC_SUBST([PTHREAD_CFLAGS])
> AC_SUBST([PTHREAD_CC])
> 
> # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
> -if test x"$ax_pthread_ok" = xyes; then
> +if test "x$ax_pthread_ok" = "xyes"; then
>         ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads
>         libraries and header files.])],[$1])
>         :
> else
> diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am
> index 2326721..f513ed4 100644
> --- a/tests/benchmark/Makefile.am
> +++ b/tests/benchmark/Makefile.am
>  <at>  <at>  -1,6 +1,3  <at>  <at> 
> -if !LIBC_INCLUDES_PTHREAD
> -AM_LDFLAGS=-lpthread
> -endif
> AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
> 
> SCRIPT_LIST = common.sh \
> diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
> index 2376edc..9556e3c 100644
> --- a/tests/regression/Makefile.am
> +++ b/tests/regression/Makefile.am
>  <at>  <at>  -1,6 +1,3  <at>  <at> 
> -if !LIBC_INCLUDES_PTHREAD
> -AM_LDFLAGS=-lpthread
> -endif
> AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils
> -I$(top_srcdir)/tests/common -g
> 
> SCRIPT_LIST = run.sh
> diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
> index 08a3cba..d97e43f 100644
> --- a/tests/unit/Makefile.am
> +++ b/tests/unit/Makefile.am
>  <at>  <at>  -1,6 +1,3  <at>  <at> 
> -if !LIBC_INCLUDES_PTHREAD
> -AM_LDFLAGS=-lpthread
> -endif
> AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/utils
> -I$(top_srcdir)/tests/common -g
> 
> SCRIPT_LIST = test_loop run.sh unit_tests
> --
> 2.7.4

--

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Julien Desfossez | 22 Jun 21:27 2016

[PATCH lttng-tools v2 1/3] Enable perf PMU counters by raw ID

Allow enabling perf PMU counters by raw ID in addition to the generic
list already provided. The format for kernel tracing is
"perf:cpu:raw:rNNN:<name>" and "perf:thread:raw:rNNN:<name> for
user-space. The rNNN format is the same as perf-record(1) where NNN is a
hexadecimal event descriptor in the form of umask+eventsel. The <name>
field allows the user to give a more friendly name.

Example usage on Intel i7-3520M to get the unhalted reference cycles
(eventsel: 0x13c) count at privilege level 0 (umask: 0x00):
lttng add-context -k -t perf:cpu:raw:r0013c:x86unhalted

Result in the trace:
sched_switch: { cpu_id = 3 }, {
	perf_cpu_raw_r0013c_x86unhalted = 27632578 }, [...]

Signed-off-by: Julien Desfossez <jdesfossez <at> efficios.com>
---
 doc/man/lttng-add-context.1.txt      |  8 +++
 src/bin/lttng/commands/add_context.c | 94 +++++++++++++++++++++++++++++++++++-
 2 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/doc/man/lttng-add-context.1.txt b/doc/man/lttng-add-context.1.txt
index f995a7f..c43581a 100644
--- a/doc/man/lttng-add-context.1.txt
+++ b/doc/man/lttng-add-context.1.txt
 <at>  <at>  -45,6 +45,14  <at>  <at>  per-thread (`perf:thread:` prefix) counters. Currently, per-CPU counters
 can only be used in the Linux kernel tracing domain, while per-thread
 counters can only be used in the user space tracing domain.

+It is also possible to enable PMU counters by raw ID using the
+`perf:cpu:raw:r<N>:<name>` or `perf:thread:raw:r<N>:<name>` format for the
+kernel and user-space respectively. `<N>` is a hexadecimal event descriptor
+which is the same format as perf-record(1): a concatenation of the `Umask
+value` and `Event number` provided by the processors manufacturer. The possible
+values for this field are processor-specific. The `<name>` field is used to
+give a symbolic name to the counter in the trace.
+
 Application-specific context fields can be added to a channel using the
 following syntax:

diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
index 2f43dc7..711c1e0 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
 <at>  <at>  -87,6 +87,7  <at>  <at>  enum perf_type {
 	PERF_TYPE_HARDWARE = 0,
 	PERF_TYPE_SOFTWARE = 1,
 	PERF_TYPE_HW_CACHE = 3,
+	PERF_TYPE_RAW = 4,
 };

 enum perf_count_hard {
 <at>  <at>  -688,9 +689,88  <at>  <at>  end:
 }

 static
+int find_ctx_type_perf_raw(const char *ctx, struct ctx_type *type)
+{
+	char *next;
+	int ret;
+	int field_pos = 0;
+	char *tmp_list;
+
+	tmp_list = strdup(ctx);
+	if (!tmp_list) {
+		PERROR("strdup temp list");
+		ret = -ENOMEM;
+		goto error;
+	}
+
+	/* Looking for "perf:[cpu|thread]:raw:<mask>:<name>". */
+	for (;;) {
+		next = strtok(tmp_list, ":");
+		if (!next) {
+			break;
+		}
+		tmp_list = NULL;
+		switch (field_pos) {
+		case 0:
+			if (strncmp(next, "perf", 4) != 0) {
+				ret = -1;
+				goto end;
+			}
+			break;
+		case 1:
+			if (strncmp(next, "cpu", 3) == 0) {
+				type->opt->ctx_type = CONTEXT_PERF_CPU_COUNTER;
+			} else if (strncmp(next, "thread", 4) == 0) {
+				type->opt->ctx_type = CONTEXT_PERF_THREAD_COUNTER;
+			} else {
+				ret = -1;
+				goto end;
+			}
+			break;
+		case 2:
+			if (strncmp(next, "raw", 3) != 0) {
+				ret = -1;
+				goto end;
+			}
+			break;
+		case 3:
+			if (strlen(next) < 2 || next[0] != 'r') {
+				ERR("Wrong perf raw mask format: rNNN");
+				ret = -1;
+				goto end;
+			}
+			type->opt->u.perf.config = strtoll(next +  1, NULL, 16);
+			break;
+		case 4:
+			/* name */
+			break;
+		case 5:
+			ERR("Too many ':' in perf raw format");
+			ret = -1;
+			goto end;
+		};
+		field_pos++;
+	}
+
+	if (field_pos < 5) {
+		ERR("Wrong perf raw format");
+		ret = -1;
+		goto end;
+	}
+
+	ret = 0;
+	goto end;
+
+end:
+	free(tmp_list);
+error:
+	return ret;
+}
+
+static
 struct ctx_type *get_context_type(const char *ctx)
 {
-	int opt_index;
+	int opt_index, ret;
 	struct ctx_type *type = NULL;
 	const char app_ctx_prefix[] = "$app.";
 	char *provider_name = NULL, *ctx_name = NULL;
 <at>  <at>  -713,6 +793,18  <at>  <at>  struct ctx_type *get_context_type(const char *ctx)
 		goto found;
 	}

+	/* Check if ctx is a raw perf context. */
+	ret = find_ctx_type_perf_raw(ctx, type);
+	if (ret == 0) {
+		type->opt->u.perf.type = PERF_TYPE_RAW;
+		type->opt->symbol = strdup(ctx);
+		if (!type->opt->symbol) {
+			PERROR("Copy perf field name");
+			goto not_found;
+		}
+		goto found;
+	}
+
 	/*
 	 * No match found against static contexts; check if it is an app
 	 * context.
--

-- 
1.9.1

_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Marian Florea | 22 Jun 09:55 2016

[PATCH lttng-tools] Fix: consumerd memory leak when using snapshot sessions

When starting tracing a snapshot session in an active environment
a metadata channel is created that on destroy is not freed. Because the
metadata channel created is not passed to the metadata thread/is not monitored,
the destruction of this channel can be done by notifying the channel thread.
Sessiond thread inside consumerd when receiving a close_metadata command
will now also notify the channel thread to destroy the metadata channel.

Fixes: #1017

Signed-off-by: Marian Florea <marian.florea <at> windriver.com>
---
 src/common/ust-consumer/ust-consumer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c
index 01d5ecf..14d3dff 100644
--- a/src/common/ust-consumer/ust-consumer.c
+++ b/src/common/ust-consumer/ust-consumer.c
 <at>  <at>  -1622,6 +1622,8  <at>  <at>  int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
 			ret_code = ret;
 		}

+		notify_thread_del_channel(ctx, msg.u.close_metadata.key);
+
 		goto end_msg_sessiond;
 	}
 	case LTTNG_CONSUMER_FLUSH_CHANNEL:
--

-- 
1.9.1

_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Денис Корешков | 22 Jun 12:26 2016
Picon

rculfhash: memory leak

Hello,
there's a small memory leak in the rculfhash observed under FreeBSD-10 when destroying a table. 
The line
pthread_mutex_init(&ht->resize_mutex, NULL);
actually calloc's some memory for resize_mutex, and there should be a call to pthread_mutex_destroy(3) in cds_lfht_destroy to free it. There's no such call in the latest (0.9.2) Userspace RCU.
Cheers!
_______________________________________________
lttng-dev mailing list
lttng-dev <at> lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Gmane