Skip to content

Commit bf48bb4

Browse files
committed
Using a _PyRecursiveMutex for executors lock
1 parent fa0dd0b commit bf48bb4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99

1010
#include "pycore_ast_state.h" // struct ast_state
1111
#include "pycore_llist.h" // struct llist_node
12+
#include "pycore_lock.h" // _PyRecursiveMutex
1213
#include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS
1314
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
1415
#include "pycore_structs.h" // PyHamtObject
@@ -30,10 +31,15 @@ extern "C" {
3031
#endif
3132

3233
// Executor list lock macros for thread-safe access to executor linked lists
34+
#ifdef Py_GIL_DISABLED
3335
#define EXECUTOR_LIST_LOCK(interp) \
34-
FT_MUTEX_LOCK(&(interp)->executor_list_lock)
36+
_PyRecursiveMutex_Lock(&(interp)->executor_list_lock)
3537
#define EXECUTOR_LIST_UNLOCK(interp) \
36-
FT_MUTEX_UNLOCK(&(interp)->executor_list_lock)
38+
_PyRecursiveMutex_Unlock(&(interp)->executor_list_lock)
39+
#else
40+
#define EXECUTOR_LIST_LOCK(interp)
41+
#define EXECUTOR_LIST_UNLOCK(interp)
42+
#endif
3743

3844
typedef int (*_Py_pending_call_func)(void *);
3945

@@ -946,7 +952,7 @@ struct _is {
946952
struct _PyExecutorObject *cold_executor;
947953
int executor_deletion_list_remaining_capacity;
948954
#ifdef Py_GIL_DISABLED
949-
PyMutex executor_list_lock;
955+
_PyRecursiveMutex executor_list_lock;
950956
#endif
951957
size_t executor_creation_counter;
952958
_rare_events rare_events;

Python/pystate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ init_interpreter(PyInterpreterState *interp,
576576
interp->executor_deletion_list_head = NULL;
577577
interp->executor_deletion_list_remaining_capacity = 0;
578578
#ifdef Py_GIL_DISABLED
579-
interp->executor_list_lock = (PyMutex){0};
579+
interp->executor_list_lock = (_PyRecursiveMutex){0};
580580
#endif
581581
interp->executor_creation_counter = JIT_CLEANUP_THRESHOLD;
582582
if (interp != &runtime->_main_interpreter) {

0 commit comments

Comments
 (0)