From: Mathieu Desnoyers Date: Wed, 21 Dec 2016 22:59:38 +0000 (-0500) Subject: Fix: add missing rcu_barrier before daemon teardown X-Git-Tag: v2.8.6~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=19154d2ab25daef13e23586d1c5201b6baaf8148;p=lttng-tools.git Fix: add missing rcu_barrier before daemon teardown 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 079bd6024..293654053 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -628,6 +628,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 2714f783b..56efaae34 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2944,6 +2944,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 e810d5614..b29c6745b 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -6221,6 +6221,12 @@ exit_client: 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.