Module Name: src
Committed By: pooka
Date: Sun Aug 15 18:55:03 UTC 2010
Modified Files:
src/sys/rump/net/lib/libshmif: if_shmem.c shmif_busops.c shmifvar.h
Log Message:
Move the lockops together with the interface -- they are needed
only at runtime.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/rump/net/lib/libshmif/if_shmem.c
cvs rdiff -u -r1.3 -r1.4 src/sys/rump/net/lib/libshmif/shmif_busops.c
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libshmif/shmifvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.22 src/sys/rump/net/lib/libshmif/if_shmem.c:1.23
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.22 Sun Aug 15 18:48:38 2010
+++ src/sys/rump/net/lib/libshmif/if_shmem.c Sun Aug 15 18:55:03 2010
@@ -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)
{
Index: src/sys/rump/net/lib/libshmif/shmif_busops.c
diff -u src/sys/rump/net/lib/libshmif/shmif_busops.c:1.3 src/sys/rump/net/lib/libshmif/shmif_busops.c:1.4
--- src/sys/rump/net/lib/libshmif/shmif_busops.c:1.3 Sun Aug 15 18:47:38 2010
+++ src/sys/rump/net/lib/libshmif/shmif_busops.c Sun Aug 15 18:55:03 2010
@@ -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)
{
Index: src/sys/rump/net/lib/libshmif/shmifvar.h
diff -u src/sys/rump/net/lib/libshmif/shmifvar.h:1.4 src/sys/rump/net/lib/libshmif/shmifvar.h:1.5
--- src/sys/rump/net/lib/libshmif/shmifvar.h:1.4 Fri Aug 13 10:13:44 2010
+++ src/sys/rump/net/lib/libshmif/shmifvar.h Sun Aug 15 18:55:03 2010
@@ -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 *);