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@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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();
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. */
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.