Skip to content

Instantly share code, notes, and snippets.

@agentzh
Last active September 16, 2022 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agentzh/905021679609619ec1b62011870cd926 to your computer and use it in GitHub Desktop.
Save agentzh/905021679609619ec1b62011870cd926 to your computer and use it in GitHub Desktop.
commit 114add4208129cc08bc47175ad505c8b719fe942
Author: Yichun Zhang (agentzh) <yichun@openresty.com>
Date: Fri Sep 16 13:37:38 2022 -0700
Bug: runtime: we might not sync the tracepoint's SRCU state after unregistering the tracepoints
It might lead to issues like PR29577.
diff --git a/tapsets.cxx b/tapsets.cxx
index 50b70aa58..cb4705ffa 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -12570,14 +12570,15 @@ tracepoint_derived_probe_group::emit_module_init (systemtap_session &s)
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";
- // This would be technically proper (on those autoconf-detectable
- // kernels that include this function in tracepoint.h), however we
- // already make several calls to synchronze_sched() during our
- // shutdown processes.
+ // Modern kernels' tracepoint implementation makes use of SRCU and
+ // their tracepoint_synchronize_unregister() function calls
+ // synchronize_srcu(&tracepoint_srcu) right before calling synchronize_rcu().
+ // So it's safer to always call tracepoint_synchronize_unregister() to avoid
+ // any risks.
- // s.op->newline() << "if (rc)";
- // s.op->newline(1) << "tracepoint_synchronize_unregister();";
- // s.op->indent(-1);
+ s.op->newline() << "if (rc)";
+ s.op->newline(1) << "tracepoint_synchronize_unregister();";
+ s.op->indent(-1);
}
@@ -12592,9 +12593,8 @@ tracepoint_derived_probe_group::emit_module_exit (systemtap_session& s)
s.op->newline(1) << "stap_tracepoint_probes[i].unreg();";
s.op->indent(-1);
- // Not necessary: see above.
-
- // s.op->newline() << "tracepoint_synchronize_unregister();";
+ // This is necessary: see above.
+ s.op->newline() << "tracepoint_synchronize_unregister();";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment