summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-11-20 14:58:41 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-11-20 14:58:41 +0000
commit435bef7a2fac8b100cc5259b25165db1c08da49d (patch)
tree00e1e6a8c40db20412922134fdf54073f1a2b1ec
parentabfc3b2fef13ff0cd1bc061c11629ecbf4912e6f (diff)
Notes
-rw-r--r--sys/kern/subr_unit.c13
-rw-r--r--sys/sys/systm.h26
2 files changed, 39 insertions, 0 deletions
diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c
index f2eafad41175..9855deeba1b4 100644
--- a/sys/kern/subr_unit.c
+++ b/sys/kern/subr_unit.c
@@ -98,6 +98,19 @@ static struct mtx unitmtx;
MTX_SYSINIT(unit, &unitmtx, "unit# allocation", MTX_DEF);
+#ifdef UNR64_LOCKED
+uint64_t
+alloc_unr64(struct unrhdr64 *unr64)
+{
+ uint64_t item;
+
+ mtx_lock(&unitmtx);
+ item = unr64->counter++;
+ mtx_unlock(&unitmtx);
+ return (item);
+}
+#endif
+
#else /* ...USERLAND */
#include <bitstring.h>
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index e02a4e3a34c5..a1b98c5660c2 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -523,6 +523,32 @@ int alloc_unr_specific(struct unrhdr *uh, u_int item);
int alloc_unrl(struct unrhdr *uh);
void free_unr(struct unrhdr *uh, u_int item);
+#if defined(__mips__) || defined(__powerpc__)
+#define UNR64_LOCKED
+#endif
+
+struct unrhdr64 {
+ uint64_t counter;
+};
+
+static __inline void
+new_unrhdr64(struct unrhdr64 *unr64, uint64_t low)
+{
+
+ unr64->counter = low;
+}
+
+#ifdef UNR64_LOCKED
+uint64_t alloc_unr64(struct unrhdr64 *);
+#else
+static __inline uint64_t
+alloc_unr64(struct unrhdr64 *unr64)
+{
+
+ return (atomic_fetchadd_64(&unr64->counter, 1));
+}
+#endif
+
void intr_prof_stack_use(struct thread *td, struct trapframe *frame);
void counted_warning(unsigned *counter, const char *msg);