Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Feb 2006 13:31:23 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        ups@freebsd.org, Kazuaki Oda <kaakun@highway.ne.jp>
Subject:   Re: question about preemption code
Message-ID:  <200602281331.26100.jhb@freebsd.org>
In-Reply-To: <440039A1.9030500@highway.ne.jp>
References:  <440039A1.9030500@highway.ne.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 25 February 2006 06:04, Kazuaki Oda wrote:
> Hi,
> 
> When reading kern_switch.c, I noticed odd difference between !SMP and
> SMP in maybe_preempt_in_ksegrp().
> 
> In !SMP case:
> =================================================================
> #ifdef PREEMPTION
> #ifndef FULL_PREEMPTION
> 	if (td->td_priority > PRI_MAX_ITHD) {
> 		running_thread->td_flags |= TDF_NEEDRESCHED;
> 		return;
> 	}
> #endif /* FULL_PREEMPTION */
> =================================================================
> 
> In SMP case:
> =================================================================
> #ifdef PREEMPTION
> 
> #if !defined(FULL_PREEMPTION)
> 	if (td->td_priority > PRI_MAX_ITHD) {
> 		running_thread->td_flags |= TDF_NEEDRESCHED;
> 	}
> #endif /* ! FULL_PREEMPTION */
> =================================================================
> 
> Is there any reason not to return after setting TDF_NEEDRESCHED flag
> in SMP case?  Because of this, we do context switch even if td's
> priority is lower than PRI_MAX_ITHD.  And, I think, it is not
> PREEMPTION, but FULL_PREEMPTION.

Yes, that is a bug, but it only would affect multithreaded applications
I think.  Also, the maybe_preempt_in_kseg() stuff doesn't handle idle
priority threads correctly in the !FULL_PREEMPTION case (the maybe_preempt()
function in !FULL_PREEMPTION always preempts _to_ interrupt threads and
always preempts _from_ idle priority threads).

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602281331.26100.jhb>