Module Name: src
Committed By: dyoung
Date: Tue Nov 24 17:28:32 UTC 2009
Modified Files:
src/sys/kern: subr_spldebug.c
Log Message:
Address some of the concerns that SPLDEBUG is not machine-independent,
Part 1 of N:
There is not an MI ordering of interrupt priority levels,
so use == IPL_HIGH and != IPL_HIGH instead of >= IPL_HIGH
and < IPL_HIGH. Ignore 'cold' and always use curcpu(),
since cpu_info_primary is MD.
Other changes:
There is no need to create symbols named _spldebug_* and
strong aliases to them. Just use symbols spldebug_*,
instead. Use a temporary variable instead of repeat
cpu_index(9) calls. KASSERT() that cpu_index(9) is <
MAXCPUS.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/subr_spldebug.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/subr_spldebug.c
diff -u src/sys/kern/subr_spldebug.c:1.1 src/sys/kern/subr_spldebug.c:1.2
--- src/sys/kern/subr_spldebug.c:1.1 Tue Nov 3 05:23:28 2009
+++ src/sys/kern/subr_spldebug.c Tue Nov 24 17:28:32 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_spldebug.c,v 1.1 2009/11/03 05:23:28 dyoung Exp $ */
+/* $NetBSD: subr_spldebug.c,v 1.2 2009/11/24 17:28:32 dyoung Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_spldebug.c,v 1.1 2009/11/03 05:23:28 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_spldebug.c,v 1.2 2009/11/24 17:28:32 dyoung Exp $");
#include <sys/param.h>
#include <sys/spldebug.h>
@@ -43,9 +43,6 @@
#include <sys/cpu.h>
#include <machine/return.h>
-__strong_alias(spldebug_start, _spldebug_start);
-__strong_alias(spldebug_stop, _spldebug_stop);
-
#define SPLRAISE_STACKLEN 32
void *splraise_retaddrs[MAXCPUS][SPLRAISE_STACKLEN][4];
@@ -54,17 +51,17 @@
void *spllowered_from[MAXCPUS][2] = {{0}};
bool spldebug = false;
-void _spldebug_start(void);
-void _spldebug_stop(void);
+void spldebug_start(void);
+void spldebug_stop(void);
void
-_spldebug_start(void)
+spldebug_start(void)
{
spldebug = true;
}
void
-_spldebug_stop(void)
+spldebug_stop(void)
{
spldebug = false;
}
@@ -72,27 +69,23 @@
void
spldebug_lower(int ipl)
{
- struct cpu_info *ci;
+ u_int cidx;
if (!spldebug)
return;
- if (ipl >= IPL_HIGH)
+ if (ipl == IPL_HIGH)
return;
- if (cold)
- ci = &cpu_info_primary;
- else
- ci = curcpu();
+ cidx = cpu_index(curcpu());
- if (cpu_index(ci) > MAXCPUS)
- return;
+ KASSERT(cidx < MAXCPUS);
- splraise_depth[cpu_index(ci)] = 0;
- spllowered_to[cpu_index(ci)] = ipl;
+ splraise_depth[cidx] = 0;
+ spllowered_to[cidx] = ipl;
#if 0
- spllowered_from[cpu_index(ci)][0] = return_address(0);
- spllowered_from[cpu_index(ci)][1] = return_address(1);
+ spllowered_from[cidx][0] = return_address(0);
+ spllowered_from[cidx][1] = return_address(1);
#endif
}
@@ -100,28 +93,23 @@
spldebug_raise(int ipl)
{
int i;
+ u_int cidx;
void **retaddrs;
- struct cpu_info *ci;
if (!spldebug)
return;
- if (ipl < IPL_HIGH)
+ if (ipl != IPL_HIGH)
return;
- if (cold)
- ci = &cpu_info_primary;
- else
- ci = curcpu();
+ cidx = cpu_index(curcpu());
- if (cpu_index(ci) >= MAXCPUS)
- return;
+ KASSERT(cidx < MAXCPUS);
- if (splraise_depth[cpu_index(ci)] >= SPLRAISE_STACKLEN)
+ if (splraise_depth[cidx] >= SPLRAISE_STACKLEN)
return;
- retaddrs = &splraise_retaddrs[cpu_index(ci)]
- [splraise_depth[cpu_index(ci)]++][0];
+ retaddrs = &splraise_retaddrs[cidx][splraise_depth[cidx]++][0];
retaddrs[0] = retaddrs[1] = retaddrs[2] = retaddrs[3] = NULL;