Skip to content

Commit 96487df

Browse files
colesburyDinoV
authored andcommitted
mimalloc: use relaxed atomics for block->next
1 parent a4a4b1d commit 96487df

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Include/mimalloc/mimalloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ terms of the MIT license. A copy of the license can be found in the file
9595
// Includes
9696
// ------------------------------------------------------
9797

98+
#include "Python.h"
9899
#include <stddef.h> // size_t
99100
#include <stdbool.h> // bool
100101
#include <stdint.h> // INTPTR_MAX

Include/mimalloc/mimalloc/internal.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static inline mi_slice_t* mi_page_to_slice(mi_page_t* p) {
430430

431431
// Segment belonging to a page
432432
static inline mi_segment_t* _mi_page_segment(const mi_page_t* page) {
433-
mi_segment_t* segment = _mi_ptr_segment(page);
433+
mi_segment_t* segment = _mi_ptr_segment(page);
434434
mi_assert_internal(segment == NULL || ((mi_slice_t*)page >= segment->slices && (mi_slice_t*)page < segment->slices + segment->slice_entries));
435435
return segment;
436436
}
@@ -676,10 +676,10 @@ static inline mi_block_t* mi_block_nextx( const void* null, const mi_block_t* bl
676676
static inline void mi_block_set_nextx(const void* null, mi_block_t* block, const mi_block_t* next, const uintptr_t* keys) {
677677
mi_track_mem_undefined(block,sizeof(mi_block_t));
678678
#ifdef MI_ENCODE_FREELIST
679-
block->next = mi_ptr_encode(null, next, keys);
679+
_Py_atomic_store_uintptr_relaxed(&block->next, mi_ptr_encode(null, next, keys));
680680
#else
681681
MI_UNUSED(keys); MI_UNUSED(null);
682-
block->next = (mi_encoded_t)next;
682+
_Py_atomic_store_uintptr_relaxed(&block->next, (mi_encoded_t)next);
683683
#endif
684684
mi_track_mem_noaccess(block,sizeof(mi_block_t));
685685
}
@@ -746,12 +746,12 @@ size_t _mi_commit_mask_next_run(const mi_commit_mask_t* cm, size_t* idx);
746746

747747
#define mi_commit_mask_foreach(cm,idx,count) \
748748
idx = 0; \
749-
while ((count = _mi_commit_mask_next_run(cm,&idx)) > 0) {
750-
749+
while ((count = _mi_commit_mask_next_run(cm,&idx)) > 0) {
750+
751751
#define mi_commit_mask_foreach_end() \
752752
idx += count; \
753753
}
754-
754+
755755

756756

757757
/* -----------------------------------------------------------

0 commit comments

Comments
 (0)