Date: Tue, 28 Feb 2006 18:35:22 -0500 From: Stephan Uphoff <ups@tree.com> To: John Baldwin <jhb@freebsd.org> Cc: ups@freebsd.org, freebsd-hackers@freebsd.org, Kazuaki Oda <kaakun@highway.ne.jp> Subject: Re: question about preemption code Message-ID: <4404DE3A.7070500@tree.com> In-Reply-To: <200602281331.26100.jhb@freebsd.org> References: <440039A1.9030500@highway.ne.jp> <200602281331.26100.jhb@freebsd.org>
index | next in thread | previous in thread | raw e-mail
John Baldwin wrote:
> 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.
I agree.
> 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).
>
>
yeah - but this only affects multi-threaded applications running on idle
priority.
( maybe_preempt_in_kseg() only preempts between threads from the same
process)
If nobody beats me to it I will try to commit changes (hopefully) early
next week.
Stephan
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4404DE3A.7070500>
