From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 28 19:19:09 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 5E21416A420; Tue, 28 Feb 2006 19:19:09 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10C6F43D92; Tue, 28 Feb 2006 19:18:52 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k1SJIlmf019026; Tue, 28 Feb 2006 14:18:47 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 28 Feb 2006 13:31:23 -0500 User-Agent: KMail/1.9.1 References: <440039A1.9030500@highway.ne.jp> In-Reply-To: <440039A1.9030500@highway.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200602281331.26100.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1306/Tue Feb 28 04:50:04 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: ups@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 19:19:09 -0000 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 <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org