Module Name: src
Committed By: ad
Date: Sat May 23 18:21:20 UTC 2009
Modified Files:
src/sys/kern: kern_lwp.c
Log Message:
- Add lwp_pctr(), get an LWP's preemption/ctxsw counter.
- Fix a preemption bug in CURCPU_IDLE_P() that can lead to a bogus
assertion failure on DEBUG kernels.
- Fix MP/preemption races with timecounter detachment.
To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/kern/kern_lwp.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/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.129 src/sys/kern/kern_lwp.c:1.130
--- src/sys/kern/kern_lwp.c:1.129 Sat Apr 4 22:34:03 2009
+++ src/sys/kern/kern_lwp.c Sat May 23 18:21:20 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lwp.c,v 1.129 2009/04/04 22:34:03 ad Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.130 2009/05/23 18:21:20 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -210,7 +210,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.129 2009/04/04 22:34:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.130 2009/05/23 18:21:20 ad Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -1724,6 +1724,18 @@
p->p_lwpctl = NULL;
}
+/*
+ * Return the current LWP's "preemption counter". Used to detect
+ * preemption across operations that can tolerate preemption without
+ * crashing, but which may generate incorrect results if preempted.
+ */
+uint64_t
+lwp_pctr(void)
+{
+
+ return curlwp->l_ncsw;
+}
+
#if defined(DDB)
void
lwp_whatis(uintptr_t addr, void (*pr)(const char *, ...))