From 8582ec21c73abb71e84b8e5e996bcd6c8fdfbf38 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 12 Feb 2011 08:46:18 -0800 Subject: [PATCH] kernel - Add per-process token, adjust signal code to use it (2). * In order to avoid a hard-code-section assertion from hardclock()'s itimer code the per-process token must be held on the call to ksignal(). --- sys/kern/kern_clock.c | 10 ++++++---- sys/kern/kern_sig.c | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 2636219a9f..a26c450e02 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -538,10 +538,12 @@ hardclock(systimer_t info, struct intrframe *frame) need_lwkt_resched(); /* - * ITimer handling is per-tick, per-cpu. I don't think ksignal() - * is mpsafe on curproc, so XXX get the mplock. + * ITimer handling is per-tick, per-cpu. + * + * We must acquire the per-process token in order for ksignal() + * to be non-blocking. */ - if ((p = curproc) != NULL && lwkt_trytoken(&proc_token)) { + if ((p = curproc) != NULL && lwkt_trytoken(&p->p_token)) { crit_enter_hard(); if (frame && CLKF_USERMODE(frame) && timevalisset(&p->p_timer[ITIMER_VIRTUAL].it_value) && @@ -551,7 +553,7 @@ hardclock(systimer_t info, struct intrframe *frame) itimerdecr(&p->p_timer[ITIMER_PROF], ustick) == 0) ksignal(p, SIGPROF); crit_exit_hard(); - lwkt_reltoken(&proc_token); + lwkt_reltoken(&p->p_token); } setdelayed(); } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index c27536409e..e0adbe954e 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1004,6 +1004,9 @@ find_lwp_for_signal(struct proc *p, int sig) * * Other ignored signals are discarded immediately. * + * If the caller wishes to call this function from a hard code section the + * caller must already hold p->p_token (see kern_clock.c). + * * No requirements. */ void @@ -1016,6 +1019,9 @@ ksignal(struct proc *p, int sig) * The core for ksignal. lp may be NULL, then a suitable thread * will be chosen. If not, lp MUST be a member of p. * + * If the caller wishes to call this function from a hard code section the + * caller must already hold p->p_token. + * * No requirements. */ void -- 2.41.0