+struct side_statedump_request_handle *side_statedump_request_notification_register(void (*statedump_cb)(void))
+{
+ struct side_statedump_request_handle *handle;
+
+ if (finalized)
+ return NULL;
+ if (!initialized)
+ side_init();
+ /*
+ * The statedump request notification should not be registered
+ * from a notification callback.
+ */
+ assert(filter_key == NULL);
+ handle = (struct side_statedump_request_handle *)
+ calloc(1, sizeof(struct side_statedump_request_handle));
+ if (!handle)
+ return NULL;
+ handle->cb = statedump_cb;
+
+ pthread_mutex_lock(&side_statedump_lock);
+ side_list_insert_node_tail_rcu(&side_statedump_list, &handle->node);
+ pthread_mutex_unlock(&side_statedump_lock);
+
+ /* Invoke callback for all tracers. */
+ statedump_cb();
+
+ return handle;
+}
+
+void side_statedump_request_notification_unregister(struct side_statedump_request_handle *handle)
+{
+ if (finalized)
+ return;
+ if (!initialized)
+ side_init();
+ assert(filter_key == NULL);
+
+ pthread_mutex_lock(&side_statedump_lock);
+ side_list_remove_node_rcu(&handle->node);
+ pthread_mutex_unlock(&side_statedump_lock);
+
+ side_rcu_wait_grace_period(&statedump_rcu_gp);
+ free(handle);
+}
+
+void side_tracer_statedump_request(void *key)
+{
+ struct side_statedump_request_handle *handle;
+ struct side_rcu_read_state rcu_read_state;
+
+ /* Invoke the state dump callback specifically for the tracer key. */
+ filter_key = key;
+ side_rcu_read_begin(&statedump_rcu_gp, &rcu_read_state);
+ side_list_for_each_entry_rcu(handle, &side_statedump_list, node)
+ handle->cb();
+ side_rcu_read_end(&statedump_rcu_gp, &rcu_read_state);
+ filter_key = NULL;
+}
+