Module Name:    src
Committed By:   pooka
Date:           Tue Oct  9 13:35:51 UTC 2012

Modified Files:
        src/sys/rump/librump/rumpkern: klock.c rump.c rump_private.h

Log Message:
Gather some statistics about biglock usage.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/rump/librump/rumpkern/klock.c
cvs rdiff -u -r1.246 -r1.247 src/sys/rump/librump/rumpkern/rump.c
cvs rdiff -u -r1.70 -r1.71 src/sys/rump/librump/rumpkern/rump_private.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/librump/rumpkern/klock.c
diff -u src/sys/rump/librump/rumpkern/klock.c:1.4 src/sys/rump/librump/rumpkern/klock.c:1.5
--- src/sys/rump/librump/rumpkern/klock.c:1.4	Mon Feb 20 22:35:14 2012
+++ src/sys/rump/librump/rumpkern/klock.c	Tue Oct  9 13:35:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: klock.c,v 1.4 2012/02/20 22:35:14 mrg Exp $	*/
+/*	$NetBSD: klock.c,v 1.5 2012/10/09 13:35:50 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -29,10 +29,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: klock.c,v 1.4 2012/02/20 22:35:14 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: klock.c,v 1.5 2012/10/09 13:35:50 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/evcnt.h>
 
 #include <rump/rumpuser.h>
 
@@ -46,6 +47,22 @@ struct rumpuser_mtx *rump_giantlock;
 static int giantcnt;
 static struct lwp *giantowner;
 
+static struct evcnt ev_biglock_fast;
+static struct evcnt ev_biglock_slow;
+static struct evcnt ev_biglock_recurse;
+
+void 
+rump_biglock_init(void)
+{
+
+	evcnt_attach_dynamic(&ev_biglock_fast, EVCNT_TYPE_MISC, NULL,
+	    "rump biglock", "fast");
+	evcnt_attach_dynamic(&ev_biglock_slow, EVCNT_TYPE_MISC, NULL,
+	    "rump biglock", "slow");
+	evcnt_attach_dynamic(&ev_biglock_recurse, EVCNT_TYPE_MISC, NULL,
+	    "rump biglock", "recurse");
+}
+
 void
 rump_kernel_bigwrap(int *nlocks)
 {
@@ -74,11 +91,15 @@ _kernel_lock(int nlocks)
 		if (giantowner == l) {
 			giantcnt += nlocks;
 			nlocks = 0;
+			ev_biglock_recurse.ev_count++;
 		} else {
 			if (!rumpuser_mutex_tryenter(rump_giantlock)) {
 				rump_unschedule_cpu1(l, NULL);
 				rumpuser_mutex_enter_nowrap(rump_giantlock);
 				rump_schedule_cpu(l);
+				ev_biglock_slow.ev_count++;
+			} else {
+				ev_biglock_fast.ev_count++;
 			}
 			giantowner = l;
 			giantcnt = 1;

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.246 src/sys/rump/librump/rumpkern/rump.c:1.247
--- src/sys/rump/librump/rumpkern/rump.c:1.246	Thu Aug 16 19:40:48 2012
+++ src/sys/rump/librump/rumpkern/rump.c	Tue Oct  9 13:35:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.246 2012/08/16 19:40:48 pgoyette Exp $	*/
+/*	$NetBSD: rump.c,v 1.247 2012/10/09 13:35:50 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.246 2012/08/16 19:40:48 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.247 2012/10/09 13:35:50 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -340,6 +340,8 @@ rump__init(int rump_version)
 	lwpinit_specificdata();
 	lwp_initspecific(&lwp0);
 
+	rump_biglock_init();
+
 	rump_scheduler_init(numcpu);
 	/* revert temporary context and schedule a semireal context */
 	rumpuser_set_curlwp(NULL);

Index: src/sys/rump/librump/rumpkern/rump_private.h
diff -u src/sys/rump/librump/rumpkern/rump_private.h:1.70 src/sys/rump/librump/rumpkern/rump_private.h:1.71
--- src/sys/rump/librump/rumpkern/rump_private.h:1.70	Mon Mar 21 16:41:09 2011
+++ src/sys/rump/librump/rumpkern/rump_private.h	Tue Oct  9 13:35:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump_private.h,v 1.70 2011/03/21 16:41:09 pooka Exp $	*/
+/*	$NetBSD: rump_private.h,v 1.71 2012/10/09 13:35:50 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -103,6 +103,7 @@ extern bool rump_ttycomponent;
 struct lwp *	rump__lwproc_alloclwp(struct proc *);
 
 void	rump_cpus_bootstrap(int *);
+void	rump_biglock_init(void);
 void	rump_scheduler_init(int);
 void	rump_schedule(void);
 void	rump_unschedule(void);

Reply via email to