aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_prof.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-08-10 22:53:32 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-08-10 22:53:32 +0000
commit688ebe120c47c9478446c12022b5e4667c2bff7a (patch)
tree1798843f61bbf42ad4e659497c23572b272969ca /sys/kern/subr_prof.c
parent827dcaf663a0a66fd738e030d6c5ecd435a35380 (diff)
downloadsrc-688ebe120c47c9478446c12022b5e4667c2bff7a.tar.gz
src-688ebe120c47c9478446c12022b5e4667c2bff7a.zip
- Close races with signals and other AST's being triggered while we are in
the process of exiting the kernel. The ast() function now loops as long as the PS_ASTPENDING or PS_NEEDRESCHED flags are set. It returns with preemption disabled so that any further AST's that arrive via an interrupt will be delayed until the low-level MD code returns to user mode. - Use u_int's to store the tick counts for profiling purposes so that we do not need sched_lock just to read p_sticks. This also closes a problem where the call to addupc_task() could screw up the arithmetic due to non-atomic reads of p_sticks. - Axe need_proftick(), aston(), astoff(), astpending(), need_resched(), clear_resched(), and resched_wanted() in favor of direct bit operations on p_sflag. - Fix up locking with sched_lock some. In addupc_intr(), use sched_lock to ensure pr_addr and pr_ticks are updated atomically with setting PS_OWEUPC. In ast() we clear pr_ticks atomically with clearing PS_OWEUPC. We also do not grab the lock just to test a flag. - Simplify the handling of Giant in ast() slightly. Reviewed by: bde (mostly)
Notes
Notes: svn path=/head/; revision=81493
Diffstat (limited to 'sys/kern/subr_prof.c')
-rw-r--r--sys/kern/subr_prof.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c
index 18c2863799cb..015f6669447a 100644
--- a/sys/kern/subr_prof.c
+++ b/sys/kern/subr_prof.c
@@ -422,9 +422,11 @@ addupc_intr(p, pc, ticks)
addr = prof->pr_base + i;
if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) {
+ mtx_lock_spin(&sched_lock);
prof->pr_addr = pc;
prof->pr_ticks = ticks;
- need_proftick(p);
+ p->p_sflag |= PS_OWEUPC | PS_ASTPENDING;
+ mtx_unlock_spin(&sched_lock);
}
}