https://github.com/python/cpython/commit/dc5866ab250f641df6ed78c943b0d36d6a4c04c2
commit: dc5866ab250f641df6ed78c943b0d36d6a4c04c2
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: corona10 <donghee.n...@gmail.com>
date: 2025-05-20T16:25:04Z
summary:

[3.14] gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx 
(GH-134238) (gh-134352)

gh-129748: Update mimalloc to use atomic store for mi_block_set_nextx 
(GH-134238)
(cherry picked from commit 317c49622397222b7c7fb49837e6b1fd7e82a80d)

Co-authored-by: Donghee Na <donghee...@python.org>

files:
M Include/internal/mimalloc/mimalloc/internal.h
M Include/internal/mimalloc/mimalloc/types.h

diff --git a/Include/internal/mimalloc/mimalloc/internal.h 
b/Include/internal/mimalloc/mimalloc/internal.h
index d97f51b8eefbe5..71b7ea702d6c5e 100644
--- a/Include/internal/mimalloc/mimalloc/internal.h
+++ b/Include/internal/mimalloc/mimalloc/internal.h
@@ -634,10 +634,10 @@ static inline mi_block_t* mi_block_nextx( const void* 
null, const mi_block_t* bl
   mi_track_mem_defined(block,sizeof(mi_block_t));
   mi_block_t* next;
   #ifdef MI_ENCODE_FREELIST
-  next = (mi_block_t*)mi_ptr_decode(null, block->next, keys);
+  next = (mi_block_t*)mi_ptr_decode(null, 
mi_atomic_load_relaxed(&block->next), keys);
   #else
   MI_UNUSED(keys); MI_UNUSED(null);
-  next = (mi_block_t*)block->next;
+  next = (mi_block_t*)mi_atomic_load_relaxed(&block->next);
   #endif
   mi_track_mem_noaccess(block,sizeof(mi_block_t));
   return next;
@@ -646,10 +646,10 @@ static inline mi_block_t* mi_block_nextx( const void* 
null, const mi_block_t* bl
 static inline void mi_block_set_nextx(const void* null, mi_block_t* block, 
const mi_block_t* next, const uintptr_t* keys) {
   mi_track_mem_undefined(block,sizeof(mi_block_t));
   #ifdef MI_ENCODE_FREELIST
-  block->next = mi_ptr_encode(null, next, keys);
+  mi_atomic_store_relaxed(&block->next, mi_ptr_encode(null, next, keys));
   #else
   MI_UNUSED(keys); MI_UNUSED(null);
-  block->next = (mi_encoded_t)next;
+  mi_atomic_store_relaxed(&block->next, (mi_encoded_t)next);
   #endif
   mi_track_mem_noaccess(block,sizeof(mi_block_t));
 }
diff --git a/Include/internal/mimalloc/mimalloc/types.h 
b/Include/internal/mimalloc/mimalloc/types.h
index 354839ba955b36..4f77bd7bc525db 100644
--- a/Include/internal/mimalloc/mimalloc/types.h
+++ b/Include/internal/mimalloc/mimalloc/types.h
@@ -235,7 +235,7 @@ typedef size_t     mi_threadid_t;
 
 // free lists contain blocks
 typedef struct mi_block_s {
-  mi_encoded_t next;
+  _Atomic(mi_encoded_t) next;
 } mi_block_t;
 
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to