Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Address some of the concerns that SPLDEBUG is not m...
details: https://anonhg.NetBSD.org/src/rev/cd3b3d660e03
branches: trunk
changeset: 749276:cd3b3d660e03
user: dyoung <dyoung%NetBSD.org@localhost>
date: Tue Nov 24 17:28:32 2009 +0000
description:
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.
diffstat:
sys/kern/subr_spldebug.c | 56 ++++++++++++++++++-----------------------------
1 files changed, 22 insertions(+), 34 deletions(-)
diffs (123 lines):
diff -r 2d7c12be0caa -r cd3b3d660e03 sys/kern/subr_spldebug.c
--- a/sys/kern/subr_spldebug.c Tue Nov 24 16:55:11 2009 +0000
+++ b/sys/kern/subr_spldebug.c Tue Nov 24 17:28:32 2009 +0000
@@ -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());
+
+ KASSERT(cidx < MAXCPUS);
- if (cpu_index(ci) > MAXCPUS)
- return;
-
- 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)
+ KASSERT(cidx < MAXCPUS);
+
+ if (splraise_depth[cidx] >= SPLRAISE_STACKLEN)
return;
- if (splraise_depth[cpu_index(ci)] >= 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;
Home |
Main Index |
Thread Index |
Old Index