aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/smr.h
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2020-02-27 19:05:26 +0000
committerJeff Roberson <jeff@FreeBSD.org>2020-02-27 19:05:26 +0000
commit561af25fa7b21943d96619473c1f7e6493ca74cc (patch)
treef6d0e7580d82ffc47929b37c07fcec12e3930f4f /sys/sys/smr.h
parentff29a952136348eeaa48b4f754eb7ccfdeb9c496 (diff)
downloadsrc-561af25fa7b21943d96619473c1f7e6493ca74cc.tar.gz
src-561af25fa7b21943d96619473c1f7e6493ca74cc.zip
Simplify lazy advance with a 64bit atomic cmpset.
This provides the potential to force a lazy (tick based) SMR to advance when there are blocking waiters by decoupling the wr_seq value from the ticks value. Add some missing compiler barriers. Reviewed by: rlibby Differential Revision: https://reviews.freebsd.org/D23825
Notes
Notes: svn path=/head/; revision=358400
Diffstat (limited to 'sys/sys/smr.h')
-rw-r--r--sys/sys/smr.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/sys/smr.h b/sys/sys/smr.h
index 9e9cc3dec3a5..9218deadbc85 100644
--- a/sys/sys/smr.h
+++ b/sys/sys/smr.h
@@ -56,9 +56,16 @@
#define SMR_SEQ_INVALID 0
/* Shared SMR state. */
+union s_wr {
+ struct {
+ smr_seq_t seq; /* Current write sequence #. */
+ int ticks; /* tick of last update (LAZY) */
+ };
+ uint64_t _pair;
+};
struct smr_shared {
const char *s_name; /* Name for debugging/reporting. */
- smr_seq_t s_wr_seq; /* Current write sequence #. */
+ union s_wr s_wr; /* Write sequence */
smr_seq_t s_rd_seq; /* Minimum observed read sequence. */
};
typedef struct smr_shared *smr_shared_t;
@@ -189,7 +196,7 @@ static inline smr_seq_t
smr_shared_current(smr_shared_t s)
{
- return (atomic_load_int(&s->s_wr_seq));
+ return (atomic_load_int(&s->s_wr.seq));
}
static inline smr_seq_t
@@ -281,7 +288,7 @@ smr_lazy_enter(smr_t smr)
* If we assign a stale wr_seq value due to interrupt we use the
* same algorithm that renders smr_enter() safe.
*/
- smr->c_seq = smr_shared_current(smr->c_shared);
+ atomic_store_int(&smr->c_seq, smr_shared_current(smr->c_shared));
}
/*
@@ -306,7 +313,7 @@ smr_lazy_exit(smr_t smr)
* time and wait 1 tick longer.
*/
atomic_thread_fence_rel();
- smr->c_seq = SMR_SEQ_INVALID;
+ atomic_store_int(&smr->c_seq, SMR_SEQ_INVALID);
critical_exit();
}