Skip to content

Commit 941d613

Browse files
committed
atomically read page_bitmaps
page_bitmaps does not need to be volatile since it is going to be treated as atomic. In fact, as long as each variable is treated as atomic, we do not need volatile at all, as that means it is modified by outside means, aka hardware, etc. The atomic macros already ensure optimizations that could cause incorrect values to be used do not happen. Finally, the first loop is redundant as they are iterated over again in the loop below.
1 parent ee39300 commit 941d613

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/shims/atomic_sfb.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// Returns UINT_MAX if all the bits in p were already set.
3333
DISPATCH_ALWAYS_INLINE
3434
static inline unsigned int
35-
os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max)
35+
os_atomic_set_first_bit(unsigned long *p, unsigned int max)
3636
{
3737
unsigned long val, bit;
3838
if (max > (sizeof(val) * 8)) {
@@ -82,7 +82,7 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max)
8282

8383
DISPATCH_ALWAYS_INLINE
8484
static inline unsigned int
85-
os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max_index)
85+
os_atomic_set_first_bit(unsigned long *p, unsigned int max)
8686
{
8787
unsigned int index;
8888
unsigned long b, b_masked;
@@ -94,7 +94,7 @@ os_atomic_set_first_bit(volatile unsigned long *p, unsigned int max_index)
9494
os_atomic_rmw_loop_give_up(return UINT_MAX);
9595
}
9696
index--;
97-
if (unlikely(index > max_index)) {
97+
if (unlikely(index > max)) {
9898
os_atomic_rmw_loop_give_up(return UINT_MAX);
9999
}
100100
b_masked = b | (1UL << index);

0 commit comments

Comments
 (0)