1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
1994-06-06 14:54:41 +00:00
|
|
|
* Copyright (C) 1994, David Greenman
|
|
|
|
* Copyright (c) 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-06-12 14:58:17 +00:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the University of Utah, and William Jolitz.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
genassym.c:
Remove NKMEMCLUSTERS, it is no longer define or used.
locores.s:
Fix comment on PTDpde and APTDpde to be pde instead of pte
Add new equation for calculating location of Sysmap
Remove Bill's old #ifdef garbage for counting up memory,
that stuff will never be made to work and was just cluttering
up the file.
Add code that places the PTD, page table pages, and kernel
stack below the 640k ISA hole if there is room for it, otherwise
put this stuff all at 1MB. This fixes the 28K bogusity in
the boot blocks, that can now go away!
Fix the caclulation of where first is to be dependent on
NKPDE so that we can skip over the above mentioned areas.
The 28K thing is now 44K in size due to the increase in
kernel virtual memory space, but since we no longer have
to worry about that this is no big deal.
Use if NNPX > 0 instead of ifdef NPX for floating point code.
machdep.c
Change the calculation of for the buffer cache to be
20% of all memory above 2MB and add back the upper limit
of 2/5's of the VM_KMEM_SIZE so that we do not eat ALL
of the kernel memory space on large memory machines, note
that this will not even come into effect unless you have
more than 32MB. The current buffer cache limit is 6.7MB
due to this caclulation.
It seems that we where erroniously allocating bufpages pages
for buffer_map. buffer_map is UNUSED in this implementation
of the buffer cache, but since the map is referenced in
several if statements a quick fix was to simply allocate
1 vm page (but no real memory) to it.
pmap.h
Remove rcsid, don't want them in the kernel files!
Removed some cruft inside an #ifdef DEBUGx that caused
compiler errors if you where compiling this for debug.
Use the #defines for PD_SHIFT and PG_SHIFT in place of
constants.
trap.c:
Remove patch kit header and rcsid, fix $Id$.
Now include "npx.h" and use NNPX for controlling the
floating point code.
Remove a now completly invalid check for a maximum virtual
address, the virtual address now ends at 0xFFFFFFFF so
there is no more MAX!! (Thanks David, I completly missed
that one!)
vm_machdep.c
Remove patch kit header and rcsid, fix $Id$.
Now include "npx.h" and use NNPX for controlling the
floating point code.
Replace several 0xFE00000 constants with KERNBASE
1993-10-15 10:34:29 +00:00
|
|
|
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-29 19:51:37 +00:00
|
|
|
#ifdef __i386__
|
2001-01-19 13:19:02 +00:00
|
|
|
#include "opt_npx.h"
|
2001-06-29 19:51:37 +00:00
|
|
|
#endif
|
1996-01-03 21:42:35 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <sys/param.h>
|
2000-09-07 01:33:02 +00:00
|
|
|
#include <sys/bus.h>
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-06-29 19:51:37 +00:00
|
|
|
#include <sys/lock.h>
|
2000-10-20 07:58:15 +00:00
|
|
|
#include <sys/mutex.h>
|
2001-06-29 19:51:37 +00:00
|
|
|
#include <sys/proc.h>
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
#include <sys/kse.h>
|
|
|
|
#include <sys/ktr.h>
|
1997-11-24 13:25:37 +00:00
|
|
|
#include <sys/resourcevar.h>
|
|
|
|
#include <sys/signalvar.h>
|
2001-06-29 19:51:37 +00:00
|
|
|
#include <sys/systm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <sys/vmmeter.h>
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <machine/cpu.h>
|
1997-11-24 13:25:37 +00:00
|
|
|
#include <machine/pcb.h>
|
2000-12-12 01:14:32 +00:00
|
|
|
|
2001-06-29 19:51:37 +00:00
|
|
|
/*
|
|
|
|
* Define the code needed before returning to user mode, for
|
|
|
|
* trap and syscall.
|
2001-08-30 18:50:57 +00:00
|
|
|
*
|
|
|
|
* MPSAFE
|
2001-06-29 19:51:37 +00:00
|
|
|
*/
|
2001-01-24 09:53:49 +00:00
|
|
|
void
|
2001-09-12 08:38:13 +00:00
|
|
|
userret(td, frame, oticks)
|
|
|
|
struct thread *td;
|
1994-06-06 14:54:41 +00:00
|
|
|
struct trapframe *frame;
|
2001-08-10 22:53:32 +00:00
|
|
|
u_int oticks;
|
1994-06-06 14:54:41 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct proc *p = td->td_proc;
|
|
|
|
struct kse *ke = td->td_kse;
|
|
|
|
struct ksegrp *kg = td->td_ksegrp;
|
1994-06-06 14:54:41 +00:00
|
|
|
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
CTR3(KTR_SYSC, "userret: thread %p (pid %d, %s)", td, p->p_pid,
|
|
|
|
p->p_comm);
|
2002-04-04 17:49:48 +00:00
|
|
|
#ifdef INVARIANTS
|
|
|
|
/* Check that we called signotify() enough. */
|
2001-07-03 05:27:53 +00:00
|
|
|
mtx_lock(&Giant);
|
2001-06-22 23:05:11 +00:00
|
|
|
PROC_LOCK(p);
|
2002-04-04 17:49:48 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
|
|
|
if (SIGPENDING(p) && ((p->p_sflag & PS_NEEDSIGCHK) == 0 ||
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
(ke->ke_flags & KEF_ASTPENDING) == 0))
|
2002-04-04 17:49:48 +00:00
|
|
|
printf("failed to set signal flags proprly for ast()\n");
|
|
|
|
mtx_unlock_spin(&sched_lock);
|
2001-08-10 22:53:32 +00:00
|
|
|
PROC_UNLOCK(p);
|
2001-08-30 18:50:57 +00:00
|
|
|
mtx_unlock(&Giant);
|
2002-04-04 17:49:48 +00:00
|
|
|
#endif
|
2000-03-28 07:16:37 +00:00
|
|
|
|
2002-04-04 17:49:48 +00:00
|
|
|
/*
|
|
|
|
* XXX we cheat slightly on the locking here to avoid locking in
|
|
|
|
* the usual case. Setting td_priority here is essentially an
|
|
|
|
* incomplete workaround for not setting it properly elsewhere.
|
|
|
|
* Now that some interrupt handlers are threads, not setting it
|
|
|
|
* properly elsewhere can clobber it in the window between setting
|
|
|
|
* it here and returning to user mode, so don't waste time setting
|
|
|
|
* it perfectly here.
|
|
|
|
*/
|
|
|
|
if (td->td_priority != kg->kg_user_pri) {
|
2001-12-18 09:06:10 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
2002-04-04 17:49:48 +00:00
|
|
|
td->td_priority = kg->kg_user_pri;
|
|
|
|
mtx_unlock_spin(&sched_lock);
|
2001-12-18 09:06:10 +00:00
|
|
|
}
|
2001-01-24 09:53:49 +00:00
|
|
|
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
/*
|
|
|
|
* We need to check to see if we have to exit or wait due to a
|
|
|
|
* single threading requirement or some other STOP condition.
|
|
|
|
*/
|
|
|
|
PROC_LOCK(p);
|
|
|
|
thread_suspend_check(0); /* Can suspend or kill */
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DO special thread processing, e.g. upcall tweaking and such
|
|
|
|
*/
|
|
|
|
if (p->p_flag & P_KSES) {
|
|
|
|
thread_userret(p, kg, ke, td, frame);
|
|
|
|
/* printf("KSE thread returned"); */
|
|
|
|
}
|
|
|
|
|
1995-02-10 06:25:14 +00:00
|
|
|
/*
|
|
|
|
* Charge system time if profiling.
|
2002-04-04 17:49:48 +00:00
|
|
|
*
|
|
|
|
* XXX should move PS_PROFIL to a place that can obviously be
|
|
|
|
* accessed safely without sched_lock.
|
1995-02-10 06:25:14 +00:00
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
if (p->p_sflag & PS_PROFIL) {
|
2001-12-18 09:06:10 +00:00
|
|
|
quad_t ticks;
|
|
|
|
|
2002-04-04 17:49:48 +00:00
|
|
|
mtx_lock_spin(&sched_lock);
|
2001-12-18 09:06:10 +00:00
|
|
|
ticks = ke->ke_sticks - oticks;
|
|
|
|
mtx_unlock_spin(&sched_lock);
|
|
|
|
addupc_task(ke, TRAPF_PC(frame), (u_int)ticks * psratio);
|
2002-04-04 17:49:48 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
}
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
2001-06-29 19:51:37 +00:00
|
|
|
* Process an asynchronous software trap.
|
|
|
|
* This is relatively easy.
|
2001-08-10 22:53:32 +00:00
|
|
|
* This function will return with preemption disabled.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
2000-09-07 01:33:02 +00:00
|
|
|
void
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
ast(struct trapframe *framep)
|
2000-09-07 01:33:02 +00:00
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = curthread;
|
|
|
|
struct proc *p = td->td_proc;
|
|
|
|
struct kse *ke = td->td_kse;
|
2002-04-04 17:49:48 +00:00
|
|
|
struct ksegrp *kg = td->td_ksegrp;
|
2001-08-10 22:53:32 +00:00
|
|
|
u_int prticks, sticks;
|
|
|
|
int sflag;
|
2001-09-12 08:38:13 +00:00
|
|
|
int flags;
|
2002-04-04 17:49:48 +00:00
|
|
|
int sig;
|
2001-05-22 21:20:49 +00:00
|
|
|
#if defined(DEV_NPX) && !defined(SMP)
|
|
|
|
int ucode;
|
|
|
|
#endif
|
2000-09-07 01:33:02 +00:00
|
|
|
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td, p->p_pid,
|
|
|
|
p->p_comm);
|
2001-02-22 18:05:15 +00:00
|
|
|
KASSERT(TRAPF_USERMODE(framep), ("ast in kernel mode"));
|
2001-08-10 22:53:32 +00:00
|
|
|
#ifdef WITNESS
|
2001-09-12 08:38:13 +00:00
|
|
|
if (witness_list(td))
|
2001-08-10 22:53:32 +00:00
|
|
|
panic("Returning to user mode with mutex(s) held");
|
|
|
|
#endif
|
|
|
|
mtx_assert(&Giant, MA_NOTOWNED);
|
2002-04-04 17:49:48 +00:00
|
|
|
mtx_assert(&sched_lock, MA_NOTOWNED);
|
2001-12-18 09:06:10 +00:00
|
|
|
prticks = 0; /* XXX: Quiet warning. */
|
2002-03-29 16:45:03 +00:00
|
|
|
td->td_frame = framep;
|
|
|
|
/*
|
|
|
|
* This updates the p_sflag's for the checks below in one
|
|
|
|
* "atomic" operation with turning off the astpending flag.
|
|
|
|
* If another AST is triggered while we are handling the
|
|
|
|
* AST's saved in sflag, the astpending flag will be set and
|
|
|
|
* ast() will be called again.
|
|
|
|
*/
|
|
|
|
mtx_lock_spin(&sched_lock);
|
|
|
|
sticks = ke->ke_sticks;
|
|
|
|
sflag = p->p_sflag;
|
|
|
|
flags = ke->ke_flags;
|
2002-04-04 17:49:48 +00:00
|
|
|
p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND);
|
|
|
|
ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC);
|
2002-03-29 16:45:03 +00:00
|
|
|
cnt.v_soft++;
|
|
|
|
if (flags & KEF_OWEUPC && sflag & PS_PROFIL) {
|
|
|
|
prticks = p->p_stats->p_prof.pr_ticks;
|
|
|
|
p->p_stats->p_prof.pr_ticks = 0;
|
|
|
|
}
|
|
|
|
mtx_unlock_spin(&sched_lock);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
/*
|
|
|
|
* XXXKSE While the fact that we owe a user profiling
|
|
|
|
* tick is stored per KSE in this code, the statistics
|
|
|
|
* themselves are still stored per process.
|
|
|
|
* This should probably change, by which I mean that
|
|
|
|
* possibly the location of both might change.
|
|
|
|
*/
|
2002-02-22 23:58:22 +00:00
|
|
|
|
2002-03-29 16:45:03 +00:00
|
|
|
if (td->td_ucred != p->p_ucred)
|
|
|
|
cred_update_thread(td);
|
|
|
|
if (flags & KEF_OWEUPC && sflag & PS_PROFIL)
|
|
|
|
addupc_task(ke, p->p_stats->p_prof.pr_addr, prticks);
|
|
|
|
if (sflag & PS_ALRMPEND) {
|
|
|
|
PROC_LOCK(p);
|
|
|
|
psignal(p, SIGVTALRM);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
}
|
2001-05-22 21:20:49 +00:00
|
|
|
#if defined(DEV_NPX) && !defined(SMP)
|
2002-03-29 16:45:03 +00:00
|
|
|
if (PCPU_GET(curpcb)->pcb_flags & PCB_NPXTRAP) {
|
|
|
|
atomic_clear_int(&PCPU_GET(curpcb)->pcb_flags,
|
|
|
|
PCB_NPXTRAP);
|
|
|
|
ucode = npxtrap();
|
|
|
|
if (ucode != -1) {
|
|
|
|
trapsignal(p, SIGFPE, ucode);
|
2001-05-22 21:20:49 +00:00
|
|
|
}
|
2002-03-29 16:45:03 +00:00
|
|
|
}
|
2001-05-22 21:20:49 +00:00
|
|
|
#endif
|
2002-03-29 16:45:03 +00:00
|
|
|
if (sflag & PS_PROFPEND) {
|
|
|
|
PROC_LOCK(p);
|
|
|
|
psignal(p, SIGPROF);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
}
|
2002-04-04 17:49:48 +00:00
|
|
|
if (flags & KEF_NEEDRESCHED) {
|
|
|
|
mtx_lock_spin(&sched_lock);
|
|
|
|
td->td_priority = kg->kg_user_pri;
|
|
|
|
p->p_stats->p_ru.ru_nivcsw++;
|
|
|
|
mi_switch();
|
|
|
|
mtx_unlock_spin(&sched_lock);
|
|
|
|
}
|
|
|
|
if (sflag & PS_NEEDSIGCHK) {
|
|
|
|
PROC_LOCK(p);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
while ((sig = cursig(td)) != 0)
|
2002-04-04 17:49:48 +00:00
|
|
|
postsig(sig);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
}
|
1997-04-07 07:16:06 +00:00
|
|
|
|
2002-03-29 16:45:03 +00:00
|
|
|
userret(td, framep, sticks);
|
2001-08-10 22:53:32 +00:00
|
|
|
mtx_assert(&Giant, MA_NOTOWNED);
|
1997-04-07 07:16:06 +00:00
|
|
|
}
|