summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_trap.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2003-02-01 12:17:09 +0000
committerjulian <julian@FreeBSD.org>2003-02-01 12:17:09 +0000
commite8efa7328e487806fb77d3ec54bf5fa5f8b017ed (patch)
tree5ab8f2c0a0aaeb3da3779201a31e710dee48d388 /sys/kern/subr_trap.c
parent1c5753d03f1205c6e2831f320c4007946a4b050f (diff)
downloadFreeBSD-src-e8efa7328e487806fb77d3ec54bf5fa5f8b017ed.zip
FreeBSD-src-e8efa7328e487806fb77d3ec54bf5fa5f8b017ed.tar.gz
Reversion of commit by Davidxu plus fixes since applied.
I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while.
Diffstat (limited to 'sys/kern/subr_trap.c')
-rw-r--r--sys/kern/subr_trap.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 92835a0..eec2ae6 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -73,22 +73,15 @@ userret(td, frame, oticks)
u_int oticks;
{
struct proc *p = td->td_proc;
-#ifdef INVARIANTS
- struct kse *ke;
-#endif
- u_int64_t eticks;
+ struct kse *ke = td->td_kse;
CTR3(KTR_SYSC, "userret: thread %p (pid %d, %s)", td, p->p_pid,
p->p_comm);
#ifdef INVARIANTS
- /*
- * Check that we called signotify() enough.
- * XXXKSE this checking is bogus for threaded program,
- */
+ /* Check that we called signotify() enough. */
mtx_lock(&Giant);
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
- ke = td->td_kse;
if (SIGPENDING(p) && ((p->p_sflag & PS_NEEDSIGCHK) == 0 ||
(td->td_kse->ke_flags & KEF_ASTPENDING) == 0))
printf("failed to set signal flags properly for ast()\n");
@@ -103,18 +96,6 @@ userret(td, frame, oticks)
sched_userret(td);
/*
- * Charge system time if profiling.
- *
- * XXX should move PS_PROFIL to a place that can obviously be
- * accessed safely without sched_lock.
- */
-
- if (p->p_sflag & PS_PROFIL) {
- eticks = td->td_sticks - oticks;
- addupc_task(td, TRAPF_PC(frame), (u_int)eticks * psratio);
- }
-
- /*
* We need to check to see if we have to exit or wait due to a
* single threading requirement or some other STOP condition.
* Don't bother doing all the work if the stop bits are not set
@@ -132,6 +113,21 @@ userret(td, frame, oticks)
if (p->p_flag & P_KSES) {
thread_userret(td, frame);
}
+
+ /*
+ * Charge system time if profiling.
+ *
+ * XXX should move PS_PROFIL to a place that can obviously be
+ * accessed safely without sched_lock.
+ */
+ if (p->p_sflag & PS_PROFIL) {
+ quad_t ticks;
+
+ mtx_lock_spin(&sched_lock);
+ ticks = ke->ke_sticks - oticks;
+ mtx_unlock_spin(&sched_lock);
+ addupc_task(ke, TRAPF_PC(frame), (u_int)ticks * psratio);
+ }
}
/*
@@ -150,7 +146,6 @@ ast(struct trapframe *framep)
u_int prticks, sticks;
int sflag;
int flags;
- int tflags;
int sig;
#if defined(DEV_NPX) && !defined(SMP)
int ucode;
@@ -180,21 +175,19 @@ ast(struct trapframe *framep)
*/
mtx_lock_spin(&sched_lock);
ke = td->td_kse;
- sticks = td->td_sticks;
- tflags = td->td_flags;
+ sticks = ke->ke_sticks;
flags = ke->ke_flags;
sflag = p->p_sflag;
p->p_sflag &= ~(PS_ALRMPEND | PS_NEEDSIGCHK | PS_PROFPEND | PS_XCPU);
#ifdef MAC
p->p_sflag &= ~PS_MACPEND;
#endif
- ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED);
- td->td_flags &= ~(TDF_ASTPENDING | TDF_OWEUPC);
+ ke->ke_flags &= ~(KEF_ASTPENDING | KEF_NEEDRESCHED | KEF_OWEUPC);
cnt.v_soft++;
prticks = 0;
- if (tflags & TDF_OWEUPC && sflag & PS_PROFIL) {
- prticks = td->td_prticks;
- td->td_prticks = 0;
+ 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);
/*
@@ -207,9 +200,8 @@ ast(struct trapframe *framep)
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
- if (tflags & TDF_OWEUPC && sflag & PS_PROFIL) {
- addupc_task(td, td->td_praddr, prticks);
- }
+ 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);
OpenPOWER on IntegriCloud