Module Name: src
Committed By: ad
Date: Thu Apr 16 21:19:24 UTC 2009
Modified Files:
src/sys/kern: kern_synch.c
Log Message:
kpreempt: fix another bug, uintptr_t -> bool truncation.
To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/kern/kern_synch.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_synch.c
diff -u src/sys/kern/kern_synch.c:1.263 src/sys/kern/kern_synch.c:1.264
--- src/sys/kern/kern_synch.c:1.263 Thu Apr 16 00:17:19 2009
+++ src/sys/kern/kern_synch.c Thu Apr 16 21:19:23 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_synch.c,v 1.263 2009/04/16 00:17:19 rmind Exp $ */
+/* $NetBSD: kern_synch.c,v 1.264 2009/04/16 21:19:23 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.263 2009/04/16 00:17:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.264 2009/04/16 21:19:23 ad Exp $");
#include "opt_kstack.h"
#include "opt_perfctrs.h"
@@ -383,7 +383,7 @@
{
uintptr_t failed;
lwp_t *l;
- int s, dop;
+ int s, dop, lsflag;
l = curlwp;
failed = 0;
@@ -452,26 +452,27 @@
l->l_nopreempt--;
}
+ if (__predict_true(!failed)) {
+ return false;
+ }
+
/* Record preemption failure for reporting via lockstat. */
- if (__predict_false(failed)) {
- int lsflag = 0;
- atomic_or_uint(&l->l_dopreempt, DOPREEMPT_COUNTED);
- LOCKSTAT_ENTER(lsflag);
- /* Might recurse, make it atomic. */
- if (__predict_false(lsflag)) {
- if (where == 0) {
- where = (uintptr_t)__builtin_return_address(0);
- }
- if (atomic_cas_ptr_ni((void *)&l->l_pfailaddr,
- NULL, (void *)where) == NULL) {
- LOCKSTAT_START_TIMER(lsflag, l->l_pfailtime);
- l->l_pfaillock = failed;
- }
+ atomic_or_uint(&l->l_dopreempt, DOPREEMPT_COUNTED);
+ lsflag = 0;
+ LOCKSTAT_ENTER(lsflag);
+ if (__predict_false(lsflag)) {
+ if (where == 0) {
+ where = (uintptr_t)__builtin_return_address(0);
+ }
+ /* Preemption is on, might recurse, so make it atomic. */
+ if (atomic_cas_ptr_ni((void *)&l->l_pfailaddr, NULL,
+ (void *)where) == NULL) {
+ LOCKSTAT_START_TIMER(lsflag, l->l_pfailtime);
+ l->l_pfaillock = failed;
}
- LOCKSTAT_EXIT(lsflag);
}
-
- return failed;
+ LOCKSTAT_EXIT(lsflag);
+ return true;
}
/*