diff options
author | Sam Gross <colesbury@gmail.com> | 2024-02-16 20:25:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 20:25:19 (GMT) |
commit | 590319072773bd6cdcca655c420d3adb84838e96 (patch) | |
tree | b2e7ec5cb49ef21d0fe9f35b9f32d69e8578fb86 /Python/ceval_macros.h | |
parent | 711f42de2e3749208cfa7effa0d45b04e4e1fdd4 (diff) | |
download | cpython-590319072773bd6cdcca655c420d3adb84838e96.zip cpython-590319072773bd6cdcca655c420d3adb84838e96.tar.gz cpython-590319072773bd6cdcca655c420d3adb84838e96.tar.bz2 |
gh-115103: Implement delayed memory reclamation (QSBR) (#115180)
This adds a safe memory reclamation scheme based on FreeBSD's "GUS" and
quiescent state based reclamation (QSBR). The API provides a mechanism
for callers to detect when it is safe to free memory that may be
concurrently accessed by readers.
Diffstat (limited to 'Python/ceval_macros.h')
-rw-r--r-- | Python/ceval_macros.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index c2550f5..1043966 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -86,6 +86,12 @@ #define PRE_DISPATCH_GOTO() ((void)0) #endif +#ifdef Py_GIL_DISABLED +#define QSBR_QUIESCENT_STATE(tstate) _Py_qsbr_quiescent_state(((_PyThreadStateImpl *)tstate)->qsbr) +#else +#define QSBR_QUIESCENT_STATE(tstate) +#endif + /* Do interpreter dispatch accounting for tracing and instrumentation */ #define DISPATCH() \ @@ -117,6 +123,7 @@ #define CHECK_EVAL_BREAKER() \ _Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY(); \ + QSBR_QUIESCENT_STATE(tstate); \ if (_Py_atomic_load_uintptr_relaxed(&tstate->interp->ceval.eval_breaker) & _PY_EVAL_EVENTS_MASK) { \ if (_Py_HandlePending(tstate) != 0) { \ GOTO_ERROR(error); \ |