diff options
author | dillon <dillon@FreeBSD.org> | 2002-03-27 05:39:23 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2002-03-27 05:39:23 +0000 |
commit | dc5aafeb94ddee4f835e390dffaecbb0eec5d5e2 (patch) | |
tree | 8233f61cf29e01829b91c6a5cf27defe60e6b8d8 /sys/sparc64 | |
parent | 9b5143f94f573dc8954cb0913f3edb055e6caf0f (diff) | |
download | FreeBSD-src-dc5aafeb94ddee4f835e390dffaecbb0eec5d5e2.zip FreeBSD-src-dc5aafeb94ddee4f835e390dffaecbb0eec5d5e2.tar.gz |
Compromise for critical*()/cpu_critical*() recommit. Cleanup the interrupt
disablement assumptions in kern_fork.c by adding another API call,
cpu_critical_fork_exit(). Cleanup the td_savecrit field by moving it
from MI to MD. Temporarily move cpu_critical*() from <arch>/include/cpufunc.h
to <arch>/<arch>/critical.c (stage-2 will clean this up).
Implement interrupt deferral for i386 that allows interrupts to remain
enabled inside critical sections. This also fixes an IPI interlock bug,
and requires uses of icu_lock to be enclosed in a true interrupt disablement.
This is the stage-1 commit. Stage-2 will occur after stage-1 has stabilized,
and will move cpu_critical*() into its own header file(s) + other things.
This commit may break non-i386 architectures in trivial ways. This should
be temporary.
Reviewed by: core
Approved by: core
Diffstat (limited to 'sys/sparc64')
-rw-r--r-- | sys/sparc64/include/cpufunc.h | 25 | ||||
-rw-r--r-- | sys/sparc64/include/proc.h | 1 | ||||
-rw-r--r-- | sys/sparc64/sparc64/critical.c | 60 |
3 files changed, 68 insertions, 18 deletions
diff --git a/sys/sparc64/include/cpufunc.h b/sys/sparc64/include/cpufunc.h index 4e59bb3..4a3dd7a 100644 --- a/sys/sparc64/include/cpufunc.h +++ b/sys/sparc64/include/cpufunc.h @@ -32,6 +32,8 @@ #include <machine/asi.h> #include <machine/pstate.h> +struct thread; + /* * membar operand macros for use in other macros when # is a special * character. Keep these in sync with what the hardware expects. @@ -160,30 +162,12 @@ STNC_GEN(u_long, stxa); : : "r" (val), "rI" (xor)); \ } while (0) -#define CRITICAL_FORK (0) - static __inline void breakpoint(void) { __asm __volatile("ta %%xcc, 1" : :); } -static __inline critical_t -cpu_critical_enter(void) -{ - critical_t pil; - - pil = rdpr(pil); - wrpr(pil, 0, 14); - return (pil); -} - -static __inline void -cpu_critical_exit(critical_t pil) -{ - wrpr(pil, pil, 0); -} - static __inline register_t intr_disable(void) { @@ -240,4 +224,9 @@ ffs(int mask) #undef LDNC_GEN #undef STNC_GEN +void cpu_critical_enter(void); +void cpu_critical_exit(void); +void cpu_critical_fork_exit(void); +void cpu_thread_link(struct thread *td); + #endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/sys/sparc64/include/proc.h b/sys/sparc64/include/proc.h index e261b24..108bc42 100644 --- a/sys/sparc64/include/proc.h +++ b/sys/sparc64/include/proc.h @@ -47,6 +47,7 @@ struct md_utrap { }; struct mdthread { + register_t md_savecrit; }; struct mdproc { diff --git a/sys/sparc64/sparc64/critical.c b/sys/sparc64/sparc64/critical.c new file mode 100644 index 0000000..8c2df1c --- /dev/null +++ b/sys/sparc64/sparc64/critical.c @@ -0,0 +1,60 @@ +/*- + * Copyright (c) 2001 Matthew Dillon. This code is distributed under + * the BSD copyright, /usr/src/COPYRIGHT. + * + * $FreeBSD$ + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/pcpu.h> +#include <sys/eventhandler.h> /* XX */ +#include <sys/ktr.h> /* XX */ +#include <sys/signalvar.h> +#include <sys/sysproto.h> /* XX */ +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/sysctl.h> +#include <sys/ucontext.h> + +void +cpu_critical_enter(void) +{ + critical_t pil; + struct thread *td = curthread; + + pil = rdpr(pil); + wrpr(pil, 0, 14); + td->td_md.md_savecrit = pil; +} + +void +cpu_critical_exit(void) +{ + struct thread *td = curthread; + wrpr(td->td_md.md_savecrit, td->td_md.md_savecrit, 0); +} + +/* + * cpu_critical_fork_exit() - cleanup after fork + */ +void +cpu_critical_fork_exit(void) +{ + struct thread *td = curthread; + + td->td_critnest = 1; + td->td_md.md_savecrit = 0; +} + +/* + * cpu_thread_link() - thread linkup, initialize machine-dependant fields + */ +void +cpu_thread_link(struct thread *td) +{ + td->td_md.md_savecrit = 0; +} + |