summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-12 20:52:52 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-12 20:52:52 +0100
commit440a0b8dfb88dde1490feeee56c603d2eac7add2 (patch)
tree7f4ab8acf1c4047182c47925783d253e9bddf529
parent091e283bb43fd9e7e50507d20d8f24d1e0f32895 (diff)
kern/sref: relax memory ordering on weak reference operations
-rw-r--r--kern/sref.c4
-rw-r--r--kern/sref_i.h7
2 files changed, 7 insertions, 4 deletions
diff --git a/kern/sref.c b/kern/sref.c
index d2eb8187..1ad9212e 100644
--- a/kern/sref.c
+++ b/kern/sref.c
@@ -248,13 +248,13 @@ sref_weakref_init(struct sref_weakref *weakref, struct sref_counter *counter)
static void
sref_weakref_mark_dying(struct sref_weakref *weakref)
{
- atomic_or(&weakref->addr, SREF_WEAKREF_DYING, ATOMIC_RELEASE);
+ atomic_or(&weakref->addr, SREF_WEAKREF_DYING, ATOMIC_RELAXED);
}
static void
sref_weakref_clear_dying(struct sref_weakref *weakref)
{
- atomic_and(&weakref->addr, SREF_WEAKREF_MASK, ATOMIC_RELEASE);
+ atomic_and(&weakref->addr, SREF_WEAKREF_MASK, ATOMIC_RELAXED);
}
static int
diff --git a/kern/sref_i.h b/kern/sref_i.h
index 09dbbfa8..27f962c5 100644
--- a/kern/sref_i.h
+++ b/kern/sref_i.h
@@ -32,8 +32,11 @@
*
* A weak reference is a pointer to a reference counter in which the
* least-significant bit is used to indicate whether the counter is
- * "dying", i.e. about to be destroyed. It must be accessed with atomic
- * instructions.
+ * "dying", i.e. about to be destroyed.
+ *
+ * It must be accessed with atomic instructions. There is no need to
+ * enforce memory order on access since the only data that depends on
+ * the weak reference are cpu-local deltas.
*/
struct sref_weakref {
uintptr_t addr;