diff options
author | Daan Leijen <daan@microsoft.com> | 2021-06-17 19:38:51 -0700 |
---|---|---|
committer | Daan Leijen <daan@microsoft.com> | 2021-06-17 19:38:51 -0700 |
commit | 728be93977152e0be222a54e6247aa60415e60bc (patch) | |
tree | e762e99d71448ad0042226180b455b4c719d1993 /include/mimalloc-internal.h | |
parent | a83bca72b3f98b55c564713176c40e44698e2c43 (diff) |
fix for #414 making numa node count atomic
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r-- | include/mimalloc-internal.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 4a803ff..1e1a796 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -667,13 +667,14 @@ static inline uintptr_t _mi_random_shuffle(uintptr_t x) { int _mi_os_numa_node_get(mi_os_tld_t* tld); size_t _mi_os_numa_node_count_get(void); -extern size_t _mi_numa_node_count; +extern _Atomic(size_t) _mi_numa_node_count; static inline int _mi_os_numa_node(mi_os_tld_t* tld) { - if (mi_likely(_mi_numa_node_count == 1)) return 0; + if (mi_likely(mi_atomic_load_relaxed(&_mi_numa_node_count) == 1)) return 0; else return _mi_os_numa_node_get(tld); } static inline size_t _mi_os_numa_node_count(void) { - if (mi_likely(_mi_numa_node_count>0)) return _mi_numa_node_count; + const size_t count = mi_atomic_load_relaxed(&_mi_numa_node_count); + if (mi_likely(count>0)) return count; else return _mi_os_numa_node_count_get(); } |