[lttng-dev] [PATCH lttng-tools] Fix: add missing rcu_barrier before daemon teardown

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon Jan 9 19:11:48 UTC 2017


Merged in master, stable-2.9 and stable-2.8. Thanks!

Jérémie

On 21 December 2016 at 17:59, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> When performing the "cleanup" of sessiond, consumerd, and relayd, we
> destroy data structures that may still be concurrently accessed by
> call_rcu worker thread.
>
> Ensure no more work is present in the call_rcu worker thread by issuing
> a rcu_barrier barrier. Note that this expects call_rcu handlers don't
> chain work to other call_rcu handlers.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/bin/lttng-consumerd/lttng-consumerd.c | 6 ++++++
>  src/bin/lttng-relayd/main.c               | 6 ++++++
>  src/bin/lttng-sessiond/main.c             | 6 ++++++
>  3 files changed, 18 insertions(+)
>
> diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c
> index 1373a74..7f78c4e 100644
> --- a/src/bin/lttng-consumerd/lttng-consumerd.c
> +++ b/src/bin/lttng-consumerd/lttng-consumerd.c
> @@ -622,6 +622,12 @@ exit_init_data:
>         tmp_ctx = ctx;
>         ctx = NULL;
>         cmm_barrier();  /* Clear ctx for signal handler. */
> +       /*
> +        * Wait for all pending call_rcu work to complete before tearing
> +        * down data structures. call_rcu worker may be trying to
> +        * perform lookups in those structures.
> +        */
> +       rcu_barrier();
>         lttng_consumer_destroy(tmp_ctx);
>         lttng_consumer_cleanup();
>
> diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c
> index dc19a69..9f26be5 100644
> --- a/src/bin/lttng-relayd/main.c
> +++ b/src/bin/lttng-relayd/main.c
> @@ -2932,6 +2932,12 @@ exit_init_data:
>         health_app_destroy(health_relayd);
>  exit_health_app_create:
>  exit_options:
> +       /*
> +        * Wait for all pending call_rcu work to complete before tearing
> +        * down data structures. call_rcu worker may be trying to
> +        * perform lookups in those structures.
> +        */
> +       rcu_barrier();
>         relayd_cleanup();
>
>         /* Ensure all prior call_rcu are done. */
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index 85a3518..40670dd 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -6148,6 +6148,12 @@ exit_health:
>
>  exit_init_data:
>         /*
> +        * Wait for all pending call_rcu work to complete before tearing
> +        * down data structures. call_rcu worker may be trying to
> +        * perform lookups in those structures.
> +        */
> +       rcu_barrier();
> +       /*
>          * sessiond_cleanup() is called when no other thread is running, except
>          * the ht_cleanup thread, which is needed to destroy the hash tables.
>          */
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list