From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 28 23:35:37 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B63D316A420; Tue, 28 Feb 2006 23:35:37 +0000 (GMT) (envelope-from ups@tree.com) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E48A43D4C; Tue, 28 Feb 2006 23:35:36 +0000 (GMT) (envelope-from ups@tree.com) Received: from [192.168.5.101] (unverified [66.23.216.54]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 12719267 for multiple; Tue, 28 Feb 2006 18:34:18 -0500 Message-ID: <4404DE3A.7070500@tree.com> Date: Tue, 28 Feb 2006 18:35:22 -0500 From: Stephan Uphoff User-Agent: Thunderbird 1.5 (Macintosh/20051201) MIME-Version: 1.0 To: John Baldwin References: <440039A1.9030500@highway.ne.jp> <200602281331.26100.jhb@freebsd.org> In-Reply-To: <200602281331.26100.jhb@freebsd.org> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: ups@freebsd.org, freebsd-hackers@freebsd.org, Kazuaki Oda Subject: Re: question about preemption code X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2006 23:35:37 -0000 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