diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index eb9bc0677b5..0bc735454be 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -773,7 +773,7 @@ ast(framep) * acquiring and releasing mutexes in assembly is not fun. */ mtx_lock_spin(&sched_lock); - if (!(astpending() || resched_wanted())) { + if (!(astpending(p) || resched_wanted())) { mtx_unlock_spin(&sched_lock); return; } @@ -781,7 +781,7 @@ ast(framep) sticks = p->p_sticks; p->p_md.md_tf = framep; - astoff(); + astoff(p); cnt.v_soft++; mtx_intr_enable(&sched_lock); if (p->p_sflag & PS_OWEUPC) { diff --git a/sys/alpha/include/cpu.h b/sys/alpha/include/cpu.h index 3e0696f0265..798f8ddc59b 100644 --- a/sys/alpha/include/cpu.h +++ b/sys/alpha/include/cpu.h @@ -80,7 +80,7 @@ struct clockframe { #define need_proftick(p) do { \ mtx_lock_spin(&sched_lock); \ (p)->p_sflag |= PS_OWEUPC; \ - aston(); \ + aston(p); \ mtx_unlock_spin(&sched_lock); \ } while (0) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 4a89c399855..f778666aa07 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -1285,14 +1285,14 @@ ast(frame) * acquiring and releasing mutexes in assembly is not fun. */ mtx_lock_spin(&sched_lock); - if (!(astpending() || resched_wanted())) { + if (!(astpending(p) || resched_wanted())) { mtx_unlock_spin(&sched_lock); return; } sticks = p->p_sticks; - astoff(); + astoff(p); mtx_intr_enable(&sched_lock); atomic_add_int(&cnt.v_soft, 1); if (p->p_sflag & PS_OWEUPC) { diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index 9ecc87aa460..74f21b9debf 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -79,7 +79,7 @@ #define need_proftick(p) do { \ mtx_lock_spin(&sched_lock); \ (p)->p_sflag |= PS_OWEUPC; \ - aston(); \ + aston(p); \ mtx_unlock_spin(&sched_lock); \ } while (0) diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 4a89c399855..f778666aa07 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -1285,14 +1285,14 @@ ast(frame) * acquiring and releasing mutexes in assembly is not fun. */ mtx_lock_spin(&sched_lock); - if (!(astpending() || resched_wanted())) { + if (!(astpending(p) || resched_wanted())) { mtx_unlock_spin(&sched_lock); return; } sticks = p->p_sticks; - astoff(); + astoff(p); mtx_intr_enable(&sched_lock); atomic_add_int(&cnt.v_soft, 1); if (p->p_sflag & PS_OWEUPC) { diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h index 9ecc87aa460..74f21b9debf 100644 --- a/sys/i386/include/cpu.h +++ b/sys/i386/include/cpu.h @@ -79,7 +79,7 @@ #define need_proftick(p) do { \ mtx_lock_spin(&sched_lock); \ (p)->p_sflag |= PS_OWEUPC; \ - aston(); \ + aston(p); \ mtx_unlock_spin(&sched_lock); \ } while (0) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index fb4b4a6e3a0..6e99f24b093 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -172,14 +172,14 @@ hardclock(frame) itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) { mtx_lock_spin(&sched_lock); p->p_sflag |= PS_ALRMPEND; - aston(); + aston(p); mtx_unlock_spin(&sched_lock); } if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) && itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) { mtx_lock_spin(&sched_lock); p->p_sflag |= PS_PROFPEND; - aston(); + aston(p); mtx_unlock_spin(&sched_lock); } } diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 4a89c399855..f778666aa07 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -1285,14 +1285,14 @@ ast(frame) * acquiring and releasing mutexes in assembly is not fun. */ mtx_lock_spin(&sched_lock); - if (!(astpending() || resched_wanted())) { + if (!(astpending(p) || resched_wanted())) { mtx_unlock_spin(&sched_lock); return; } sticks = p->p_sticks; - astoff(); + astoff(p); mtx_intr_enable(&sched_lock); atomic_add_int(&cnt.v_soft, 1); if (p->p_sflag & PS_OWEUPC) { diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 4beb0bcec23..224c5ace0ab 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -396,22 +396,26 @@ sigonstack(size_t sp) } while (0) /* - * Notify the current process (p) that it has a signal pending, - * process as soon as possible. + * Schedule an Asynchronous System Trap (AST) on return to user mode. */ -#define aston() signotify(CURPROC) -#define signotify(p) do { \ +#define aston(p) do { \ mtx_assert(&sched_lock, MA_OWNED); \ (p)->p_sflag |= PS_ASTPENDING; \ } while (0) -#define astpending() (curproc->p_sflag & PS_ASTPENDING) +#define astpending(p) ((p)->p_sflag & PS_ASTPENDING) -#define astoff() do { \ +#define astoff(p) do { \ mtx_assert(&sched_lock, MA_OWNED); \ - CURPROC->p_sflag &= ~PS_ASTPENDING; \ + (p)->p_sflag &= ~PS_ASTPENDING; \ } while (0) +/* + * Notify the current process (p) that it has a signal pending, + * process as soon as possible. + */ +#define signotify(p) aston(p) + /* Handy macro to determine if p1 can mangle p2. */ #define PRISON_CHECK(p1, p2) \ ((p1)->p_prison == NULL || (p1)->p_prison == (p2)->p_prison)