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

2016-06-23 Thread Julien Desfossez
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 
---
 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
@@ -55,6 +55,7 @@ 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 {
@@ -131,24 +132,50 @@ 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
@@ -221,7 +248,9 @@ struct lttng_perf_counter_thread_field *
if (!thread_field)
abort();
thread_field->field = perf_field;
-   thread_field->pc = setup_perf(_field->attr);
+   thread_field->fd = open_perf_fd(_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(_field->rcu_field_node,
@@ -293,6 +322,7 @@ 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(_field->rcu_field_node);
cds_list_del(_field->thread_field_node);
@@ -341,7 +371,6 @@ 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;
 
@@ -389,12 +418,12 @@ 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(_field->attr);
-   if (!tmp_pc) {
+   ret = open_perf_fd(_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@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust v2 2/2] Add perf context support for ARMv7

2016-06-23 Thread Julien Desfossez
Allow to add perf context to UST traces. ARMv7 does not have a reliable
way to read perf PMU counters entirely from user-space like we do on
x86, so this approach requires a system call every time a counter needs
to be read which has a significant performance impact.

ARMv7 does not have way to read PMU from userspace because it requires
write access to the debug coprocessor to select which PMU counter to
read which defeats user-space/kernel protection. For that reason, the
bits required to allow user-space access to those registers are not
enabled in the kernel and Perf does not expose any information in the
shared mmap page, so we do not know what is the counter index. Also, for
ARMv7 we cannot the exclude_kernel flag, so the counter stays active
even when the process is executing in kernel context (system calls
mainly).

This generic approach might work on other architecture, but it has not
yet been tested so it is not enabled in the code.

Signed-off-by: Julien Desfossez 
---
 configure.ac   |  1 +
 liblttng-ust-ctl/ustctl.c  |  2 +-
 liblttng-ust/lttng-context-perf-counters.c | 84 +-
 3 files changed, 62 insertions(+), 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index de462ff..5475640 100644
--- a/configure.ac
+++ b/configure.ac
@@ -219,6 +219,7 @@ AS_CASE([$host_cpu],
[i[[3456]]86], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[x86_64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[amd64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
+   [armv7l], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=no])
 AC_MSG_RESULT([$UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS])
 
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 0165786..97445d5 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -1742,7 +1742,7 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream 
*stream,
return client_cb->instance_id(buf, handle, id);
 }
 
-#if defined(__x86_64__) || defined(__i386__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__)
 
 int ustctl_has_perf_counters(void)
 {
diff --git a/liblttng-ust/lttng-context-perf-counters.c 
b/liblttng-ust/lttng-context-perf-counters.c
index 725b1b4..a981aa9 100644
--- a/liblttng-ust/lttng-context-perf-counters.c
+++ b/liblttng-ust/lttng-context-perf-counters.c
@@ -91,17 +91,13 @@ uint64_t rdpmc(unsigned int counter)
return low | ((uint64_t) high) << 32;
 }
 
-#else /* defined(__x86_64__) || defined(__i386__) */
-
-#error "Perf event counters are only supported on x86 so far."
-
-#endif /* #else defined(__x86_64__) || defined(__i386__) */
-
 static
-uint64_t read_perf_counter(struct perf_event_mmap_page *pc)
+uint64_t read_perf_counter(
+   struct lttng_perf_counter_thread_field *thread_field)
 {
uint32_t seq, idx;
uint64_t count;
+   struct perf_event_mmap_page *pc = thread_field->pc;
 
if (caa_unlikely(!pc))
return 0;
@@ -122,6 +118,29 @@ uint64_t read_perf_counter(struct perf_event_mmap_page *pc)
return count;
 }
 
+#elif defined (__ARM_ARCH_7A__)
+
+static
+uint64_t read_perf_counter(
+   struct lttng_perf_counter_thread_field *thread_field)
+{
+   uint64_t count;
+
+   if (caa_unlikely(thread_field->fd < 0))
+   return 0;
+
+   if (read(thread_field->fd, , sizeof(count)) < sizeof(count))
+   return 0;
+
+   return count;
+}
+
+#else /* defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__) 
*/
+
+#error "Perf event counters are only supported on x86 and ARMv7 so far."
+
+#endif /* #else defined(__x86_64__) || defined(__i386__) || 
defined(__ARM_ARCH_7A__) */
+
 static
 int sys_perf_event_open(struct perf_event_attr *attr,
pid_t pid, int cpu, int group_fd,
@@ -144,6 +163,20 @@ int open_perf_fd(struct perf_event_attr *attr)
 }
 
 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");
+   }
+}
+
+static
 struct perf_event_mmap_page *setup_perf(
struct lttng_perf_counter_thread_field *thread_field)
 {
@@ -160,25 +193,10 @@ struct perf_event_mmap_page *setup_perf(
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");
-   }
-}
-
-static
 void unmap_perf_page(struct perf_event_mmap_page *pc)
 {
int ret;
@@ -292,7 +310,7 @@ uint64_t wrapper_perf_counter_read(struct lttng_ctx_field 
*field)
 
perf_field = field->u.perf_counter;

Re: [lttng-dev] [PATCH lttng-ust 2/2] Add perf context support for ARMv7

2016-06-23 Thread Mathieu Desnoyers
- On Jun 23, 2016, at 4:15 PM, Julien Desfossez jdesfos...@efficios.com 
wrote:

> Allow to add perf context to UST traces. ARMv7 does not have a reliable
> way to read perf PMU counters entirely from user-space like we do on
> x86, so this approach requires a system call everytime a counter needs

everytime -> every time

> to be read which has a significant performance impact.
> 
> This generic approach might work on other architecture, but it has not
> yet been tested so it is not enabled in the code.

We might want to say a few words on why ARMv7 does not have way
to read PMU from userspace (requires write access to the debug
coprocessor to select which PMU counter to read or such, which
defeats userspace/kernel protection).

> 
> Signed-off-by: Julien Desfossez 
> ---
> configure.ac   |  1 +
> liblttng-ust-ctl/ustctl.c  |  2 +-
> liblttng-ust/lttng-context-perf-counters.c | 71 --
> 3 files changed, 50 insertions(+), 24 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index de462ff..5475640 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -219,6 +219,7 @@ AS_CASE([$host_cpu],
>   [i[[3456]]86], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
>   [x86_64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
>   [amd64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
> + [armv7l], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
>   [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=no])
> AC_MSG_RESULT([$UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS])
> 
> diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
> index 0165786..97445d5 100644
> --- a/liblttng-ust-ctl/ustctl.c
> +++ b/liblttng-ust-ctl/ustctl.c
> @@ -1742,7 +1742,7 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream
> *stream,
>   return client_cb->instance_id(buf, handle, id);
> }
> 
> -#if defined(__x86_64__) || defined(__i386__)
> +#if defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__)
> 
> int ustctl_has_perf_counters(void)
> {
> diff --git a/liblttng-ust/lttng-context-perf-counters.c
> b/liblttng-ust/lttng-context-perf-counters.c
> index 725b1b4..220686b 100644
> --- a/liblttng-ust/lttng-context-perf-counters.c
> +++ b/liblttng-ust/lttng-context-perf-counters.c
> @@ -91,17 +91,13 @@ uint64_t rdpmc(unsigned int counter)
>   return low | ((uint64_t) high) << 32;
> }
> 
> -#else /* defined(__x86_64__) || defined(__i386__) */
> -
> -#error "Perf event counters are only supported on x86 so far."
> -
> -#endif /* #else defined(__x86_64__) || defined(__i386__) */
> -
> static
> -uint64_t read_perf_counter(struct perf_event_mmap_page *pc)
> +uint64_t read_perf_counter(
> + struct lttng_perf_counter_thread_field *thread_field)
> {
>   uint32_t seq, idx;
>   uint64_t count;
> + struct perf_event_mmap_page *pc = thread_field->pc;
> 
>   if (caa_unlikely(!pc))
>   return 0;
> @@ -122,6 +118,31 @@ uint64_t read_perf_counter(struct perf_event_mmap_page 
> *pc)
>   return count;
> }
> 
> +#elif defined (__ARM_ARCH_7A__)
> +
> +static
> +uint64_t read_perf_counter(
> + struct lttng_perf_counter_thread_field *thread_field)
> +{
> + uint64_t count;
> + int ret;

remove ret variable.

> +
> + if (caa_unlikely(thread_field->fd < 0))
> + return 0;
> +
> + ret = read(thread_field->fd, , sizeof(count));
> + if (ret < sizeof(count))

if (read(...) < 0)
  return 0;


> + return 0;
> +
> + return count;
> +}
> +
> +#else /* defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__)
> */
> +
> +#error "Perf event counters are only supported on x86 and ARMv7 so far."
> +
> +#endif /* #else defined(__x86_64__) || defined(__i386__) ||
> defined(__ARM_ARCH_7A__) */
> +
> static
> int sys_perf_event_open(struct perf_event_attr *attr,
>   pid_t pid, int cpu, int group_fd,
> @@ -144,6 +165,20 @@ int open_perf_fd(struct perf_event_attr *attr)
> }
> 
> 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");
> + }
> +}
> +
> +static
> struct perf_event_mmap_page *setup_perf(
>   struct lttng_perf_counter_thread_field *thread_field)
> {
> @@ -160,25 +195,10 @@ struct perf_event_mmap_page *setup_perf(
>   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");
> - }
> -}
> -
> -static
> void unmap_perf_page(struct perf_event_mmap_page *pc)
> {
>   int ret;
> @@ -292,7 +312,7 @@ uint64_t wrapper_perf_counter_read(struct lttng_ctx_field
> 

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

2016-06-23 Thread Julien Desfossez
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 
---
 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
@@ -55,6 +55,7 @@ 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 {
@@ -131,24 +132,50 @@ 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
@@ -221,7 +248,9 @@ struct lttng_perf_counter_thread_field *
if (!thread_field)
abort();
thread_field->field = perf_field;
-   thread_field->pc = setup_perf(_field->attr);
+   thread_field->fd = open_perf_fd(_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(_field->rcu_field_node,
@@ -293,6 +322,7 @@ 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(_field->rcu_field_node);
cds_list_del(_field->thread_field_node);
@@ -341,7 +371,6 @@ 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;
 
@@ -389,12 +418,12 @@ 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(_field->attr);
-   if (!tmp_pc) {
+   ret = open_perf_fd(_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@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust 2/2] Add perf context support for ARMv7

2016-06-23 Thread Julien Desfossez
Allow to add perf context to UST traces. ARMv7 does not have a reliable
way to read perf PMU counters entirely from user-space like we do on
x86, so this approach requires a system call everytime a counter needs
to be read which has a significant performance impact.

This generic approach might work on other architecture, but it has not
yet been tested so it is not enabled in the code.

Signed-off-by: Julien Desfossez 
---
 configure.ac   |  1 +
 liblttng-ust-ctl/ustctl.c  |  2 +-
 liblttng-ust/lttng-context-perf-counters.c | 71 --
 3 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index de462ff..5475640 100644
--- a/configure.ac
+++ b/configure.ac
@@ -219,6 +219,7 @@ AS_CASE([$host_cpu],
[i[[3456]]86], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[x86_64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[amd64], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
+   [armv7l], [UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=yes],
[UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS=no])
 AC_MSG_RESULT([$UST_SUPPORT_FOR_ARCH_PERF_EVENT_COUNTERS])
 
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 0165786..97445d5 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -1742,7 +1742,7 @@ int ustctl_get_instance_id(struct ustctl_consumer_stream 
*stream,
return client_cb->instance_id(buf, handle, id);
 }
 
-#if defined(__x86_64__) || defined(__i386__)
+#if defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__)
 
 int ustctl_has_perf_counters(void)
 {
diff --git a/liblttng-ust/lttng-context-perf-counters.c 
b/liblttng-ust/lttng-context-perf-counters.c
index 725b1b4..220686b 100644
--- a/liblttng-ust/lttng-context-perf-counters.c
+++ b/liblttng-ust/lttng-context-perf-counters.c
@@ -91,17 +91,13 @@ uint64_t rdpmc(unsigned int counter)
return low | ((uint64_t) high) << 32;
 }
 
-#else /* defined(__x86_64__) || defined(__i386__) */
-
-#error "Perf event counters are only supported on x86 so far."
-
-#endif /* #else defined(__x86_64__) || defined(__i386__) */
-
 static
-uint64_t read_perf_counter(struct perf_event_mmap_page *pc)
+uint64_t read_perf_counter(
+   struct lttng_perf_counter_thread_field *thread_field)
 {
uint32_t seq, idx;
uint64_t count;
+   struct perf_event_mmap_page *pc = thread_field->pc;
 
if (caa_unlikely(!pc))
return 0;
@@ -122,6 +118,31 @@ uint64_t read_perf_counter(struct perf_event_mmap_page *pc)
return count;
 }
 
+#elif defined (__ARM_ARCH_7A__)
+
+static
+uint64_t read_perf_counter(
+   struct lttng_perf_counter_thread_field *thread_field)
+{
+   uint64_t count;
+   int ret;
+
+   if (caa_unlikely(thread_field->fd < 0))
+   return 0;
+
+   ret = read(thread_field->fd, , sizeof(count));
+   if (ret < sizeof(count))
+   return 0;
+
+   return count;
+}
+
+#else /* defined(__x86_64__) || defined(__i386__) || defined(__ARM_ARCH_7A__) 
*/
+
+#error "Perf event counters are only supported on x86 and ARMv7 so far."
+
+#endif /* #else defined(__x86_64__) || defined(__i386__) || 
defined(__ARM_ARCH_7A__) */
+
 static
 int sys_perf_event_open(struct perf_event_attr *attr,
pid_t pid, int cpu, int group_fd,
@@ -144,6 +165,20 @@ int open_perf_fd(struct perf_event_attr *attr)
 }
 
 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");
+   }
+}
+
+static
 struct perf_event_mmap_page *setup_perf(
struct lttng_perf_counter_thread_field *thread_field)
 {
@@ -160,25 +195,10 @@ struct perf_event_mmap_page *setup_perf(
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");
-   }
-}
-
-static
 void unmap_perf_page(struct perf_event_mmap_page *pc)
 {
int ret;
@@ -292,7 +312,7 @@ uint64_t wrapper_perf_counter_read(struct lttng_ctx_field 
*field)
 
perf_field = field->u.perf_counter;
perf_thread_field = get_thread_field(perf_field);
-   return read_perf_counter(perf_thread_field->pc);
+   return read_perf_counter(perf_thread_field);
 }
 
 static
@@ -413,7 +433,12 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
 
perf_field->attr.type = type;
perf_field->attr.config = config;
+#if defined (__ARM_ARCH_7A__)
+   /* exclude_kernel does not work on ARM. */
+   perf_field->attr.exclude_kernel = 0;
+#else
perf_field->attr.exclude_kernel = 1;
+#endif

[lttng-dev] [RELEASE] LTTng-analyses v0.4.4

2016-06-23 Thread Julien Desfossez
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@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


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

2016-06-23 Thread Sebastien Boisvert
Hi Mathieu,

Thanks for your comments on GitHub on my PR v5 and PR v6.


I am posting hyper links here. That way, your comments will be easier to find 
when I get to the point in time
when I address them.


https://github.com/sebhtml/lttng-ust/commits/for-phil-cmake-example.v5


https://github.com/sebhtml/lttng-ust/commit/8f2baee901120cdeaed40ae4b02a4132b06378b5

https://github.com/sebhtml/lttng-ust/commit/637b998e793c59315ea4fab3d12ed8e616a83a59

https://github.com/sebhtml/lttng-ust/commit/6c3f321202c508aa31242d4519567445b507b3de



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


https://github.com/sebhtml/lttng-ust/commit/5e5b4ea7229f52560f48b4234224ba523a21e272

https://github.com/sebhtml/lttng-ust/commit/7c7d60f720c562bb3ced17d5b89f2a1dd65c9e43

https://github.com/sebhtml/lttng-ust/commit/a29c7505d09cfbd3a03b55913c88a9e93a258533


On 06/22/2016 10:33 PM, Sebastien Boisvert wrote:
> 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@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] lttng-ust deadlock.

2016-06-23 Thread Aravind HT
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@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev