From ca6f6cfd39b42dad774ba17c48666bb06fd0740a Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 2 Jul 2004 03:50:48 +0000 Subject: Tidy up uprof locking. Mostly the fields are protected by both the proc lock and sched_lock so they can be read with either lock held. Document the locking as well. The one remaining bogosity is that pr_addr and pr_ticks should be per-thread but profiling of multithreaded apps is currently undefined. --- sys/kern/subr_trap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'sys/kern/subr_trap.c') diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 35f85ee..11550c0 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -142,7 +142,7 @@ ast(struct trapframe *framep) struct proc *p; struct ksegrp *kg; struct rlimit rlim; - u_int prticks, sticks; + u_int sticks; int sflag; int flags; int sig; @@ -180,11 +180,6 @@ ast(struct trapframe *framep) td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDRESCHED | TDF_OWEUPC | TDF_INTERRUPT); cnt.v_soft++; - prticks = 0; - if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL) { - prticks = p->p_stats->p_prof.pr_ticks; - p->p_stats->p_prof.pr_ticks = 0; - } mtx_unlock_spin(&sched_lock); /* * XXXKSE While the fact that we owe a user profiling @@ -196,8 +191,11 @@ ast(struct trapframe *framep) if (td->td_ucred != p->p_ucred) cred_update_thread(td); - if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL) - addupc_task(td, p->p_stats->p_prof.pr_addr, prticks); + if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL) { + addupc_task(td, p->p_stats->p_prof.pr_addr, + p->p_stats->p_prof.pr_ticks); + p->p_stats->p_prof.pr_ticks = 0; + } if (sflag & PS_ALRMPEND) { PROC_LOCK(p); psignal(p, SIGVTALRM); -- cgit v1.1