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.10.0-rc1~73 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4d62fbf82e90a66f7196331bf515f58e63801d35;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 1373a74b2..7f78c4ec2 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 7b313818e..919c5a96a 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2937,6 +2937,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 85a35183f..40670ddd5 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -6147,6 +6147,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.