Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_trap.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
#include <sys/msan.h> | #include <sys/msan.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/pmckern.h> | #include <sys/pmckern.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/ptrace.h> | #include <sys/ptrace.h> | ||||
#include <sys/racct.h> | #include <sys/racct.h> | ||||
#include <sys/resourcevar.h> | #include <sys/resourcevar.h> | ||||
#include <sys/rseq.h> | |||||
#include <sys/sched.h> | #include <sys/sched.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/syscall.h> | #include <sys/syscall.h> | ||||
#include <sys/syscallsubr.h> | #include <sys/syscallsubr.h> | ||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/vmmeter.h> | #include <sys/vmmeter.h> | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | ast(struct trapframe *framep) | ||||
* If another AST is triggered while we are handling the | * If another AST is triggered while we are handling the | ||||
* AST's saved in flags, the astpending flag will be set and | * AST's saved in flags, the astpending flag will be set and | ||||
* ast() will be called again. | * ast() will be called again. | ||||
*/ | */ | ||||
thread_lock(td); | thread_lock(td); | ||||
flags = td->td_flags; | flags = td->td_flags; | ||||
td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK | | td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK | | ||||
TDF_NEEDRESCHED | TDF_ALRMPEND | TDF_PROFPEND | TDF_MACPEND | | TDF_NEEDRESCHED | TDF_ALRMPEND | TDF_PROFPEND | TDF_MACPEND | | ||||
TDF_KQTICKLED); | TDF_KQTICKLED | TDF_RSEQ); | ||||
thread_unlock(td); | thread_unlock(td); | ||||
VM_CNT_INC(v_trap); | VM_CNT_INC(v_trap); | ||||
if (td->td_cowgen != p->p_cowgen) | if (td->td_cowgen != p->p_cowgen) | ||||
thread_cow_update(td); | thread_cow_update(td); | ||||
if (td->td_pflags & TDP_OWEUPC && p->p_flag & P_PROFIL) { | if (td->td_pflags & TDP_OWEUPC && p->p_flag & P_PROFIL) { | ||||
addupc_task(td, td->td_profil_addr, td->td_profil_ticks); | addupc_task(td, td->td_profil_addr, td->td_profil_ticks); | ||||
td->td_profil_ticks = 0; | td->td_profil_ticks = 0; | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | #endif | ||||
/* | /* | ||||
* Check for signals. Unlocked reads of p_pendingcnt or | * Check for signals. Unlocked reads of p_pendingcnt or | ||||
* p_siglist might cause process-directed signal to be handled | * p_siglist might cause process-directed signal to be handled | ||||
* later. | * later. | ||||
*/ | */ | ||||
if (flags & TDF_NEEDSIGCHK || p->p_pendingcnt > 0 || | if (flags & TDF_NEEDSIGCHK || p->p_pendingcnt > 0 || | ||||
!SIGISEMPTY(p->p_siglist)) { | !SIGISEMPTY(p->p_siglist)) { | ||||
sigfastblock_fetch(td); | sigfastblock_fetch(td); | ||||
rseq_before_sig(td); | |||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
mtx_lock(&p->p_sigacts->ps_mtx); | mtx_lock(&p->p_sigacts->ps_mtx); | ||||
while ((sig = cursig(td)) != 0) { | while ((sig = cursig(td)) != 0) { | ||||
KASSERT(sig >= 0, ("sig %d", sig)); | KASSERT(sig >= 0, ("sig %d", sig)); | ||||
postsig(sig); | postsig(sig); | ||||
} | } | ||||
mtx_unlock(&p->p_sigacts->ps_mtx); | mtx_unlock(&p->p_sigacts->ps_mtx); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
resched_sigs = true; | resched_sigs = true; | ||||
} else { | } else { | ||||
resched_sigs = false; | resched_sigs = false; | ||||
} | } | ||||
if ((flags & TDF_KQTICKLED) != 0) | if ((flags & TDF_KQTICKLED) != 0) | ||||
kqueue_drain_schedtask(); | kqueue_drain_schedtask(); | ||||
/* | /* | ||||
* Handle deferred update of the fast sigblock value, after | * Handle deferred update of the fast sigblock value, after | ||||
* the postsig() loop was performed. | * the postsig() loop was performed. | ||||
*/ | */ | ||||
sigfastblock_setpend(td, resched_sigs); | sigfastblock_setpend(td, resched_sigs); | ||||
if ((flags & TDF_RSEQ) != 0) | |||||
rseq_ast(td); | |||||
#ifdef KTRACE | #ifdef KTRACE | ||||
KTRUSERRET(td); | KTRUSERRET(td); | ||||
#endif | #endif | ||||
/* | /* | ||||
* We need to check to see if we have to exit or wait due to a | * We need to check to see if we have to exit or wait due to a | ||||
* single threading requirement or some other STOP condition. | * single threading requirement or some other STOP condition. | ||||
Show All 31 Lines |