summaryrefslogtreecommitdiff
path: root/sys/kern/subr_percpu.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-01-11 17:46:29 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-01-11 17:46:29 +0000
commit4009b5e2d48bb5ac4159e510e77b93c9bb9d0d7e (patch)
treef820979f8fd6e80145a52bfb7e91498bea633982 /sys/kern/subr_percpu.c
parent535ca4dad3ad8541b5ac1993ef50b0192763d316 (diff)
Move the membar in counters_read(). It has to be between reading
the generation number and the counters. In counters_zero() put a membar after resetting the counters, but before writing the generation number. OK mpi@ patrick@
Diffstat (limited to 'sys/kern/subr_percpu.c')
-rw-r--r--sys/kern/subr_percpu.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/subr_percpu.c b/sys/kern/subr_percpu.c
index 8ff00635165..d009f646e9c 100644
--- a/sys/kern/subr_percpu.c
+++ b/sys/kern/subr_percpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_percpu.c,v 1.5 2016/10/27 09:40:20 dlg Exp $ */
+/* $OpenBSD: subr_percpu.c,v 1.6 2017/01/11 17:46:28 bluhm Exp $ */
/*
* Copyright (c) 2016 David Gwynne <dlg@openbsd.org>
@@ -181,10 +181,10 @@ counters_read(struct cpumem *cm, uint64_t *output, unsigned int n)
/* the generation number is odd during an update */
while (enter & 1) {
yield();
- membar_consumer();
enter = *gen;
}
+ membar_consumer();
for (i = 0; i < n; i++)
temp[i] = counters[i];
@@ -213,12 +213,13 @@ counters_zero(struct cpumem *cm, unsigned int n)
uint64_t *counters;
unsigned int i;
- n++; /* zero the generation numbers too */
-
counters = cpumem_first(&cmi, cm);
do {
for (i = 0; i < n; i++)
counters[i] = 0;
+ /* zero the generation numbers too */
+ membar_producer();
+ counters[i] = 0;
counters = cpumem_next(&cmi, cm);
} while (counters != NULL);
@@ -334,4 +335,3 @@ counters_zero(struct cpumem *cm, unsigned int n)
}
#endif /* MULTIPROCESSOR */
-