Module Name:    src
Committed By:   pooka
Date:           Tue May 18 15:12:19 UTC 2010

Modified Files:
        src/sys/rump/librump/rumpkern: Makefile.rumpkern locks.c
Added Files:
        src/sys/rump/librump/rumpkern: klock.c

Log Message:
Move routines related to kernel locking and scheduling from
locks.c to klock.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/rump/librump/rumpkern/Makefile.rumpkern
cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpkern/klock.c
cvs rdiff -u -r1.40 -r1.41 src/sys/rump/librump/rumpkern/locks.c

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/librump/rumpkern/Makefile.rumpkern
diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.84 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.85
--- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.84	Tue May 11 22:21:05 2010
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern	Tue May 18 15:12:19 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rumpkern,v 1.84 2010/05/11 22:21:05 pooka Exp $
+#	$NetBSD: Makefile.rumpkern,v 1.85 2010/05/18 15:12:19 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -15,9 +15,9 @@
 #
 # Source modules, first the ones specifically implemented for librump.
 # 
-SRCS=	rump.c rumpcopy.c emul.c intr.c kobj_rename.c locks.c	\
-	ltsleep.c memalloc.c scheduler.c signals.c sleepq.c	\
-	sysproxy_socket.c threads.c vm.c
+SRCS=	rump.c rumpcopy.c emul.c intr.c klock.c kobj_rename.c	\
+	locks.c ltsleep.c memalloc.c scheduler.c signals.c	\
+	sleepq.c sysproxy_socket.c threads.c vm.c
 
 vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh
 	${_MKMSG_CREATE} vers.c

Index: src/sys/rump/librump/rumpkern/locks.c
diff -u src/sys/rump/librump/rumpkern/locks.c:1.40 src/sys/rump/librump/rumpkern/locks.c:1.41
--- src/sys/rump/librump/rumpkern/locks.c:1.40	Tue May 18 14:58:42 2010
+++ src/sys/rump/librump/rumpkern/locks.c	Tue May 18 15:12:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks.c,v 1.40 2010/05/18 14:58:42 pooka Exp $	*/
+/*	$NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.40 2010/05/18 14:58:42 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -281,109 +281,3 @@
 
 	return RUMPCV(cv) != NULL;
 }
-
-/*
- * giant lock
- */
-
-static volatile int lockcnt;
-
-bool
-kernel_biglocked()
-{
-
-	return rumpuser_mutex_held(rump_giantlock) && lockcnt > 0;
-}
-
-void
-kernel_unlock_allbutone(int *countp)
-{
-	int minusone = lockcnt-1;
-
-	KASSERT(kernel_biglocked());
-	if (minusone) {
-		_kernel_unlock(minusone, countp);
-	}
-	KASSERT(lockcnt == 1);
-	*countp = minusone;
-
-	/*
-	 * We drop lockcnt to 0 since rumpuser doesn't know that the
-	 * kernel biglock is being used as the interlock for cv in
-	 * tsleep.
-	 */
-	lockcnt = 0;
-}
-
-void
-kernel_ununlock_allbutone(int nlocks)
-{
-
-	KASSERT(rumpuser_mutex_held(rump_giantlock) && lockcnt == 0);
-	lockcnt = 1;
-	_kernel_lock(nlocks);
-}
-
-void
-_kernel_lock(int nlocks)
-{
-
-	while (nlocks--) {
-		if (!rumpuser_mutex_tryenter(rump_giantlock)) {
-			struct lwp *l = curlwp;
-
-			rump_unschedule_cpu1(l, NULL);
-			rumpuser_mutex_enter_nowrap(rump_giantlock);
-			rump_schedule_cpu(l);
-		}
-		lockcnt++;
-	}
-}
-
-void
-_kernel_unlock(int nlocks, int *countp)
-{
-
-	if (!rumpuser_mutex_held(rump_giantlock)) {
-		KASSERT(nlocks == 0);
-		if (countp)
-			*countp = 0;
-		return;
-	}
-
-	if (countp)
-		*countp = lockcnt;
-	if (nlocks == 0)
-		nlocks = lockcnt;
-	if (nlocks == -1) {
-		KASSERT(lockcnt == 1);
-		nlocks = 1;
-	}
-	KASSERT(nlocks <= lockcnt);
-	while (nlocks--) {
-		lockcnt--;
-		rumpuser_mutex_exit(rump_giantlock);
-	}
-}
-
-void
-rump_user_unschedule(int nlocks, int *countp, void *interlock)
-{
-
-	_kernel_unlock(nlocks, countp);
-	/*
-	 * XXX: technically we should unschedule_cpu1() here, but that
-	 * requires rump_intr_enter/exit to be implemented.
-	 */
-	rump_unschedule_cpu_interlock(curlwp, interlock);
-}
-
-void
-rump_user_schedule(int nlocks, void *interlock)
-{
-
-	rump_schedule_cpu_interlock(curlwp, interlock);
-
-	if (nlocks)
-		_kernel_lock(nlocks);
-}

Added files:

Index: src/sys/rump/librump/rumpkern/klock.c
diff -u /dev/null src/sys/rump/librump/rumpkern/klock.c:1.1
--- /dev/null	Tue May 18 15:12:19 2010
+++ src/sys/rump/librump/rumpkern/klock.c	Tue May 18 15:12:19 2010
@@ -0,0 +1,145 @@
+/*	$NetBSD: klock.c,v 1.1 2010/05/18 15:12:19 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
+ *
+ * Development of this software was supported by the
+ * Finnish Cultural Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: klock.c,v 1.1 2010/05/18 15:12:19 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <rump/rumpuser.h>
+
+#include "rump_private.h"
+
+/*
+ * giant lock
+ */
+
+static volatile int lockcnt;
+
+bool
+kernel_biglocked()
+{
+
+	return rumpuser_mutex_held(rump_giantlock) && lockcnt > 0;
+}
+
+void
+kernel_unlock_allbutone(int *countp)
+{
+	int minusone = lockcnt-1;
+
+	KASSERT(kernel_biglocked());
+	if (minusone) {
+		_kernel_unlock(minusone, countp);
+	}
+	KASSERT(lockcnt == 1);
+	*countp = minusone;
+
+	/*
+	 * We drop lockcnt to 0 since rumpuser doesn't know that the
+	 * kernel biglock is being used as the interlock for cv in
+	 * tsleep.
+	 */
+	lockcnt = 0;
+}
+
+void
+kernel_ununlock_allbutone(int nlocks)
+{
+
+	KASSERT(rumpuser_mutex_held(rump_giantlock) && lockcnt == 0);
+	lockcnt = 1;
+	_kernel_lock(nlocks);
+}
+
+void
+_kernel_lock(int nlocks)
+{
+
+	while (nlocks--) {
+		if (!rumpuser_mutex_tryenter(rump_giantlock)) {
+			struct lwp *l = curlwp;
+
+			rump_unschedule_cpu1(l, NULL);
+			rumpuser_mutex_enter_nowrap(rump_giantlock);
+			rump_schedule_cpu(l);
+		}
+		lockcnt++;
+	}
+}
+
+void
+_kernel_unlock(int nlocks, int *countp)
+{
+
+	if (!rumpuser_mutex_held(rump_giantlock)) {
+		KASSERT(nlocks == 0);
+		if (countp)
+			*countp = 0;
+		return;
+	}
+
+	if (countp)
+		*countp = lockcnt;
+	if (nlocks == 0)
+		nlocks = lockcnt;
+	if (nlocks == -1) {
+		KASSERT(lockcnt == 1);
+		nlocks = 1;
+	}
+	KASSERT(nlocks <= lockcnt);
+	while (nlocks--) {
+		lockcnt--;
+		rumpuser_mutex_exit(rump_giantlock);
+	}
+}
+
+void
+rump_user_unschedule(int nlocks, int *countp, void *interlock)
+{
+
+	_kernel_unlock(nlocks, countp);
+	/*
+	 * XXX: technically we should unschedule_cpu1() here, but that
+	 * requires rump_intr_enter/exit to be implemented.
+	 */
+	rump_unschedule_cpu_interlock(curlwp, interlock);
+}
+
+void
+rump_user_schedule(int nlocks, void *interlock)
+{
+
+	rump_schedule_cpu_interlock(curlwp, interlock);
+
+	if (nlocks)
+		_kernel_lock(nlocks);
+}

Reply via email to