Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107614499
D27536.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D27536.diff
View Options
Index: head/sys/riscv/include/counter.h
===================================================================
--- head/sys/riscv/include/counter.h
+++ head/sys/riscv/include/counter.h
@@ -30,14 +30,12 @@
#define _MACHINE_COUNTER_H_
#include <sys/pcpu.h>
-#ifdef INVARIANTS
-#include <sys/proc.h>
-#endif
+#include <machine/atomic.h>
#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter
-#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
@@ -54,19 +52,17 @@
int i;
r = 0;
- for (i = 0; i < mp_ncpus; i++)
- r += counter_u64_read_one((uint64_t *)p, i);
+ CPU_FOREACH(i)
+ r += counter_u64_read_one(p, i);
return (r);
}
-/* XXXKIB might interrupt increment */
static void
counter_u64_zero_one_cpu(void *arg)
{
- *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE *
- PCPU_GET(cpuid))) = 0;
+ *(zpcpu_get((counter_u64_t *)arg)) = 0;
}
static inline void
@@ -78,18 +74,13 @@
}
#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_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 4:51 PM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15840746
Default Alt Text
D27536.diff (1 KB)
Attached To
Mode
D27536: riscv: small counter(9) improvements
Attached
Detach File
Event Timeline
Log In to Comment