svn commit: r313345 - in head/sys: arm/include arm64/include
Konstantin Belousov
kib at FreeBSD.org
Mon Feb 6 17:20:38 UTC 2017
Author: kib
Date: Mon Feb 6 17:20:37 2017
New Revision: 313345
URL: https://svnweb.freebsd.org/changeset/base/313345
Log:
Update arm and arm64 counters MD bits.
On arm64 use atomics. Then, both arm and arm64 do not need a critical
section around update. Replace all cpus loop by CPU_FOREACH().
This brings arm and arm64 counter(9) implementation closer to current
amd64, but being more RISC-y, arm* version cannot avoid atomics.
Reported by: Alexandre Martins <alexandre.martins at stormshield.eu>
Reviewed by: andrew
Tested by: Alexandre Martins, andrew
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Modified:
head/sys/arm/include/counter.h
head/sys/arm64/include/counter.h
Modified: head/sys/arm/include/counter.h
==============================================================================
--- head/sys/arm/include/counter.h Mon Feb 6 15:24:52 2017 (r313344)
+++ head/sys/arm/include/counter.h Mon Feb 6 17:20:37 2017 (r313345)
@@ -31,12 +31,9 @@
#include <sys/pcpu.h>
#include <machine/atomic.h>
-#ifdef INVARIANTS
-#include <sys/proc.h>
-#endif
-#define counter_enter() critical_enter()
-#define counter_exit() critical_exit()
+#define counter_enter() do {} while (0)
+#define counter_exit() do {} while (0)
#ifdef IN_SUBR_COUNTER_C
@@ -55,7 +52,7 @@ counter_u64_fetch_inline(uint64_t *p)
int i;
r = 0;
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
r += counter_u64_read_one((uint64_t *)p, i);
return (r);
@@ -78,18 +75,13 @@ counter_u64_zero_inline(counter_u64_t c)
}
#endif
-#define counter_u64_add_protected(c, inc) do { \
- CRITICAL_ASSERT(curthread); \
- atomic_add_64((uint64_t *)zpcpu_get(c), (inc)); \
-} while (0)
+#define counter_u64_add_protected(c, inc) counter_u64_add(c, inc)
static inline void
counter_u64_add(counter_u64_t c, int64_t inc)
{
- counter_enter();
- counter_u64_add_protected(c, inc);
- counter_exit();
+ atomic_add_64((uint64_t *)zpcpu_get(c), inc);
}
#endif /* ! __MACHINE_COUNTER_H__ */
Modified: head/sys/arm64/include/counter.h
==============================================================================
--- head/sys/arm64/include/counter.h Mon Feb 6 15:24:52 2017 (r313344)
+++ head/sys/arm64/include/counter.h Mon Feb 6 17:20:37 2017 (r313345)
@@ -30,12 +30,10 @@
#define _MACHINE_COUNTER_H_
#include <sys/pcpu.h>
-#ifdef INVARIANTS
-#include <sys/proc.h>
-#endif
+#include <machine/atomic.h>
-#define counter_enter() critical_enter()
-#define counter_exit() critical_exit()
+#define counter_enter() do {} while (0)
+#define counter_exit() do {} while (0)
#ifdef IN_SUBR_COUNTER_C
static inline uint64_t
@@ -52,13 +50,12 @@ counter_u64_fetch_inline(uint64_t *p)
int i;
r = 0;
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
r += counter_u64_read_one((uint64_t *)p, i);
return (r);
}
-/* XXXKIB might interrupt increment */
static void
counter_u64_zero_one_cpu(void *arg)
{
@@ -76,18 +73,13 @@ counter_u64_zero_inline(counter_u64_t c)
}
#endif
-#define counter_u64_add_protected(c, inc) do { \
- CRITICAL_ASSERT(curthread); \
- *(uint64_t *)zpcpu_get(c) += (inc); \
-} while (0)
+#define counter_u64_add_protected(c, inc) counter_u64_add(c, inc)
static inline void
counter_u64_add(counter_u64_t c, int64_t inc)
{
- counter_enter();
- counter_u64_add_protected(c, inc);
- counter_exit();
+ atomic_add_64((uint64_t *)zpcpu_get(c), inc);
}
#endif /* ! _MACHINE_COUNTER_H_ */
More information about the svn-src-all
mailing list