[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 2/4] include/uk: fix test_bit atomicity
ukarch_test_bit_sync does not make sense. A barrier() call is not a memory barrier as was said in the comment. Even if it it was, it would not make ukarch_test_bit_sync atomic. This commit merges these two function together, and adds a missing uk_test_bit into bitops.h. Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> --- include/uk/arch/atomic.h | 13 ++----------- include/uk/bitops.h | 1 + 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/uk/arch/atomic.h b/include/uk/arch/atomic.h index 0964e14..44a71e6 100644 --- a/include/uk/arch/atomic.h +++ b/include/uk/arch/atomic.h @@ -127,8 +127,9 @@ static inline int ukarch_test_bit(unsigned int nr, const volatile unsigned long *byte) { const volatile __u8 *ptr = (const __u8 *)byte; + int ret = ((1 << (nr & 7)) & (ptr[nr >> 3])) != 0; - return ((1 << (nr & 7)) & (ptr[nr >> 3])) != 0; + return ret; } /** @@ -188,16 +189,6 @@ static inline void ukarch_clr_bit_sync(unsigned int nr, volatile void *byte) ukarch_test_and_clr_bit_sync(nr, byte); } -/* As test_bit, but with a following memory barrier. */ -static inline int ukarch_test_bit_sync(unsigned int nr, volatile void *byte) -{ - int result; - - result = ukarch_test_bit(nr, byte); - barrier(); - return result; -} - #ifdef __cplusplus } #endif diff --git a/include/uk/bitops.h b/include/uk/bitops.h index e004fdf..5a28410 100644 --- a/include/uk/bitops.h +++ b/include/uk/bitops.h @@ -250,6 +250,7 @@ uk_find_next_zero_bit(const unsigned long *addr, unsigned long size, #define uk_set_bit(i, a) ukarch_set_bit_sync(i, a) #define __uk_clear_bit(i, a) ukarch_clr_bit(i, a) #define uk_clear_bit(i, a) ukarch_clr_bit_sync(i, a) +#define uk_test_bit(i, a) ukarch_test_bit(i, a) static inline int uk_test_and_clear_bit(long bit, volatile unsigned long *var) -- 2.19.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |