From 2454094f8f15fffbaddf468b46752b9a972a80aa Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 31 Jan 2020 20:30:50 +0000 Subject: [PATCH] smrstress: Add 'publishing' fences to operations on smrs_current. Reported and tested by: andrew Reviewed by: jeff Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D23440 --- tools/uma/smrstress/smrstress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/uma/smrstress/smrstress.c b/tools/uma/smrstress/smrstress.c index 1d0143b47abb..0e4dcfeddf47 100644 --- a/tools/uma/smrstress/smrstress.c +++ b/tools/uma/smrstress/smrstress.c @@ -84,7 +84,7 @@ smrs_read(void) /* Wait for the writer to exit. */ while (smrs_completed == 0) { smr_enter(smrs_smr); - cur = (void *)atomic_load_ptr(&smrs_current); + cur = (void *)atomic_load_acq_ptr(&smrs_current); if (cur->generation == -1) smrs_error(cur, "read early: Use after free!\n"); atomic_add_int(&cur->count, 1); @@ -107,6 +107,7 @@ smrs_write(void) for (i = 0; i < smrs_iterations; i++) { cur = uma_zalloc_smr(smrs_zone, M_WAITOK); + atomic_thread_fence_rel(); cur = (void *)atomic_swap_ptr(&smrs_current, (uintptr_t)cur); uma_zfree_smr(smrs_zone, cur); }