Replace `want_resched' and `want_ast' globals by per-CPU variables.

This commit is contained in:
pk 2003-01-10 16:34:14 +00:00
parent fc3c2cbc33
commit 30cc38bdb5
4 changed files with 40 additions and 34 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.56 2003/01/06 12:50:43 pk Exp $ */
/* $NetBSD: cpu.h,v 1.57 2003/01/10 16:34:18 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -130,27 +130,38 @@ void *softnet_cookie;
#define setsoftnet() softintr_schedule(softnet_cookie);
extern int want_ast;
/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
* Preempt the current process on the target CPU if in interrupt from
* user mode, or after the current trap/syscall if in system mode.
*/
extern int want_resched; /* resched() was called */
#define need_resched(ci) (want_resched = 1, want_ast = 1)
#if schedcpu_is_fixed
#define need_resched(ci) do { \
(ci)->want_resched = 1; \
(ci)->want_ast = 1; \
\
/* Just interrupt the target CPU, so it can notice its AST */ \
if ((ci)->ci_cpuid != cpu_number()) \
XCALL0(sparc_noop, 1U << (ci)->ci_cpuid); \
} while(0)
#else
#define need_resched(ci) do { \
(ci)->want_resched = 1; \
(ci)->want_ast = 1; \
} while(0)
#endif
/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the sparc, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
*/
#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, want_ast = 1)
#define need_proftick(p) ((p)->p_flag |= P_OWEUPC, cpuinfo.want_ast = 1)
/*
* Notify the current process (p) that it has a signal pending,
* process as soon as possible.
*/
#define signotify(p) (want_ast = 1)
#define signotify(p) (cpuinfo.want_ast = 1)
/* CPU architecture version */
extern int cpu_arch;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.156 2003/01/09 05:55:30 mrg Exp $ */
/* $NetBSD: cpu.c,v 1.157 2003/01/10 16:34:16 pk Exp $ */
/*
* Copyright (c) 1996
@ -678,7 +678,7 @@ xcall(func, arg0, arg1, arg2, arg3, cpuset)
#ifdef DEBUG
if (!cold) {
u_int pc, lvl = ((u_int)s & PSR_PIL) >> 8;
if (lvl > IPL_CLOCK) {
if (lvl > IPL_SCHED) {
__asm("mov %%i7, %0" : "=r" (pc) : );
printf("%d: xcall at lvl %u from 0x%x\n",
cpu_number(), lvl, pc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.178 2003/01/07 12:09:00 pk Exp $ */
/* $NetBSD: locore.s,v 1.179 2003/01/10 16:34:14 pk Exp $ */
/*
* Copyright (c) 1996 Paul Kranenburg
@ -163,8 +163,12 @@ _EINTSTACKP = CPUINFO_VA + CPUINFO_EINTSTACK
* virtual address for the same structure. It must be stored in p->p_cpu
* upon context switch.
*/
_CISELFP = CPUINFO_VA + CPUINFO_SELF
_CIFLAGS = CPUINFO_VA + CPUINFO_FLAGS
_CISELFP = CPUINFO_VA + CPUINFO_SELF
_CIFLAGS = CPUINFO_VA + CPUINFO_FLAGS
/* Per-cpu AST and reschedule requests */
_WANT_AST = CPUINFO_VA + CPUINFO_WANT_AST
_WANT_RESCHED = CPUINFO_VA + CPUINFO_WANT_RESCHED
/*
* When a process exits and its u. area goes away, we set cpcb to point
@ -3298,8 +3302,8 @@ rft_kernel:
* If returning to a valid window, just set psr and return.
*/
rft_user:
! sethi %hi(_C_LABEL(want_ast)), %l7 ! (done below)
ld [%l7 + %lo(_C_LABEL(want_ast))], %l7
! sethi %hi(_WANT_AST)), %l7 ! (done below)
ld [%l7 + %lo(_WANT_AST)], %l7
tst %l7 ! want AST trap?
bne,a softtrap ! yes, re-enter trap with type T_AST
mov T_AST, %o0
@ -3410,7 +3414,7 @@ rft_user_or_recover_pcb_windows:
ld [%l6 + PCB_NSAVED], %l7
tst %l7
bz,a rft_user
sethi %hi(_C_LABEL(want_ast)), %l7 ! first instr of rft_user
sethi %hi(_WANT_AST), %l7 ! first instr of rft_user
bg,a softtrap ! if (pcb_nsaved > 0)
mov T_WINOF, %o0 ! trap(T_WINOF);
@ -4531,15 +4535,6 @@ ENTRY(write_user_windows)
nop
.comm _C_LABEL(want_resched),4
.comm _C_LABEL(want_ast),4
/*
* Masterpaddr is the p->p_addr of the last process on the processor.
* XXX masterpaddr is almost the same as cpcb
* XXX should delete this entirely
*/
.comm _C_LABEL(masterpaddr), 4
/*
* Switch statistics (for later tweaking):
* nswitchdiff = p1 => p2 (i.e., chose different process)
@ -4869,12 +4864,12 @@ Lsw_load:
st %o0, [%l3 + P_CPU]
#endif
sethi %hi(_C_LABEL(want_resched)), %o0 ! want_resched = 0;
sethi %hi(_WANT_RESCHED), %o0 ! want_resched = 0;
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
/* Done with the run queues; release the scheduler lock */
call _C_LABEL(sched_unlock_idle)
#endif
st %g0, [%o0 + %lo(_C_LABEL(want_resched))]! delay slot
st %g0, [%o0 + %lo(_WANT_RESCHED)]! delay slot
ld [%l3 + P_ADDR], %g5 ! newpcb = p->p_addr;
st %g0, [%l3 + 4] ! p->p_back = NULL;
st %l3, [%l7 + %lo(curproc)] ! curproc = p;
@ -5422,8 +5417,8 @@ Lsw_scan:
st %o0, [%g3 + P_CPU]
#endif
sethi %hi(_C_LABEL(want_resched)), %o0 ! want_resched = 0;
st %g0, [%o0 + %lo(_C_LABEL(want_resched))]
sethi %hi(_WANT_RESCHED), %o0 ! want_resched = 0;
st %g0, [%o0 + %lo(_WANT_RESCHED)]
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
/* Done with the run queues; release the scheduler lock */
SAVE_GLOBALS_AND_CALL(sched_unlock_idle)

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.126 2003/01/09 04:58:58 mrg Exp $ */
/* $NetBSD: trap.c,v 1.127 2003/01/10 16:34:15 pk Exp $ */
/*
* Copyright (c) 1996
@ -219,14 +219,14 @@ userret(p, pc, oticks)
while ((sig = CURSIG(p)) != 0)
postsig(sig);
p->p_priority = p->p_usrpri;
if (want_ast) {
want_ast = 0;
if (cpuinfo.want_ast) {
cpuinfo.want_ast = 0;
if (p->p_flag & P_OWEUPC) {
p->p_flag &= ~P_OWEUPC;
ADDUPROF(p);
}
}
if (want_resched) {
if (cpuinfo.want_resched) {
/*
* We are being preempted.
*/