Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libshmif Move the lockops together with the...
details: https://anonhg.NetBSD.org/src/rev/6cc4a9d40d16
branches: trunk
changeset: 757122:6cc4a9d40d16
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Aug 15 18:55:03 2010 +0000
description:
Move the lockops together with the interface -- they are needed
only at runtime.
diffstat:
sys/rump/net/lib/libshmif/if_shmem.c | 44 ++++++++++++++++++++++++++++++-
sys/rump/net/lib/libshmif/shmif_busops.c | 44 +------------------------------
sys/rump/net/lib/libshmif/shmifvar.h | 4 +--
3 files changed, 45 insertions(+), 47 deletions(-)
diffs (148 lines):
diff -r e2af5f033b9e -r 6cc4a9d40d16 sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c Sun Aug 15 18:48:38 2010 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c Sun Aug 15 18:55:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_shmem.c,v 1.22 2010/08/15 18:48:38 pooka Exp $ */
+/* $NetBSD: if_shmem.c,v 1.23 2010/08/15 18:55:03 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.22 2010/08/15 18:48:38 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.23 2010/08/15 18:55:03 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -79,6 +79,46 @@
static uint32_t numif;
+#define LOCK_UNLOCKED 0
+#define LOCK_LOCKED 1
+#define LOCK_COOLDOWN 1001
+
+/*
+ * This locking needs work and will misbehave severely if:
+ * 1) the backing memory has to be paged in
+ * 2) some lockholder exits while holding the lock
+ */
+static void
+shmif_lockbus(struct shmif_mem *busmem)
+{
+ int i = 0;
+
+ while (__predict_false(atomic_cas_32(&busmem->shm_lock,
+ LOCK_UNLOCKED, LOCK_LOCKED) == LOCK_LOCKED)) {
+ if (__predict_false(++i > LOCK_COOLDOWN)) {
+ uint64_t sec, nsec;
+ int error;
+
+ sec = 0;
+ nsec = 1000*1000; /* 1ms */
+ rumpuser_nanosleep(&sec, &nsec, &error);
+ i = 0;
+ }
+ continue;
+ }
+ membar_enter();
+}
+
+static void
+shmif_unlockbus(struct shmif_mem *busmem)
+{
+ unsigned int old;
+
+ membar_exit();
+ old = atomic_swap_32(&busmem->shm_lock, LOCK_UNLOCKED);
+ KASSERT(old == LOCK_LOCKED);
+}
+
int
rump_shmif_create(const char *path, int *ifnum)
{
diff -r e2af5f033b9e -r 6cc4a9d40d16 sys/rump/net/lib/libshmif/shmif_busops.c
--- a/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:48:38 2010 +0000
+++ b/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:55:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shmif_busops.c,v 1.3 2010/08/15 18:47:38 pooka Exp $ */
+/* $NetBSD: shmif_busops.c,v 1.4 2010/08/15 18:55:03 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.3 2010/08/15 18:47:38 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shmif_busops.c,v 1.4 2010/08/15 18:55:03 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -42,46 +42,6 @@
#include <rump/rumpuser.h>
#endif
-#define LOCK_UNLOCKED 0
-#define LOCK_LOCKED 1
-#define LOCK_COOLDOWN 1001
-
-/*
- * This locking needs work and will misbehave severely if:
- * 1) the backing memory has to be paged in
- * 2) some lockholder exits while holding the lock
- */
-void
-shmif_lockbus(struct shmif_mem *busmem)
-{
- int i = 0;
-
- while (__predict_false(atomic_cas_32(&busmem->shm_lock,
- LOCK_UNLOCKED, LOCK_LOCKED) == LOCK_LOCKED)) {
- if (__predict_false(++i > LOCK_COOLDOWN)) {
- uint64_t sec, nsec;
- int error;
-
- sec = 0;
- nsec = 1000*1000; /* 1ms */
- rumpuser_nanosleep(&sec, &nsec, &error);
- i = 0;
- }
- continue;
- }
- membar_enter();
-}
-
-void
-shmif_unlockbus(struct shmif_mem *busmem)
-{
- unsigned int old;
-
- membar_exit();
- old = atomic_swap_32(&busmem->shm_lock, LOCK_UNLOCKED);
- KASSERT(old == LOCK_LOCKED);
-}
-
uint32_t
shmif_advance(uint32_t oldoff, uint32_t delta)
{
diff -r e2af5f033b9e -r 6cc4a9d40d16 sys/rump/net/lib/libshmif/shmifvar.h
--- a/sys/rump/net/lib/libshmif/shmifvar.h Sun Aug 15 18:48:38 2010 +0000
+++ b/sys/rump/net/lib/libshmif/shmifvar.h Sun Aug 15 18:55:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shmifvar.h,v 1.4 2010/08/13 10:13:44 pooka Exp $ */
+/* $NetBSD: shmifvar.h,v 1.5 2010/08/15 18:55:03 pooka Exp $ */
/*-
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -71,8 +71,6 @@
#define DPRINTF(x)
#endif
-void shmif_lockbus(struct shmif_mem *);
-void shmif_unlockbus(struct shmif_mem *);
uint32_t shmif_advance(uint32_t, uint32_t);
uint32_t shmif_busread(struct shmif_mem *,
void *, uint32_t, size_t, bool *);
- Prev by Date:
[src/trunk]: src/share/misc BGA, DSDT, DVFS, FSB, GPE, GSI, HFM, HPET, LAPIC, ...
- Next by Date:
[src/trunk]: src/sys/rump/net/lib/libshmif Take kernel lock before passing da...
- Previous by Thread:
[src/trunk]: src/share/misc BGA, DSDT, DVFS, FSB, GPE, GSI, HFM, HPET, LAPIC, ...
- Next by Thread:
[src/trunk]: src/sys/rump/net/lib/libshmif Take kernel lock before passing da...
- Indexes:
Home |
Main Index |
Thread Index |
Old Index