From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 5 15:12:11 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E404F106564A for ; Wed, 5 Oct 2011 15:12:11 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from agogare.doit.wisc.edu (agogare.doit.wisc.edu [144.92.197.211]) by mx1.freebsd.org (Postfix) with ESMTP id B899E8FC15 for ; Wed, 5 Oct 2011 15:12:11 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Received: from avs-daemon.smtpauth2.wiscmail.wisc.edu by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0LSL00B00M8ATI00@smtpauth2.wiscmail.wisc.edu> for freebsd-hackers@freebsd.org; Wed, 05 Oct 2011 10:12:11 -0500 (CDT) Received: from comporellon.tachypleus.net ([unknown] [76.210.75.72]) by smtpauth2.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0LSL008WSM85D700@smtpauth2.wiscmail.wisc.edu> for freebsd-hackers@freebsd.org; Wed, 05 Oct 2011 10:12:06 -0500 (CDT) Date: Wed, 05 Oct 2011 10:12:05 -0500 From: Nathan Whitehorn In-reply-to: <4E86DC86.3040204@FreeBSD.org> To: freebsd-hackers@freebsd.org Message-id: <4E8C73C5.3020809@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.75.72 X-Spam-PmxInfo: Server=avs-11, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.10.5.145714, SenderIP=76.210.75.72 References: <4E86DC86.3040204@FreeBSD.org> User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:7.0) Gecko/20110928 Thunderbird/7.0 Subject: Re: how are callouts handled in cpu_idle() ? 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: Wed, 05 Oct 2011 15:12:12 -0000 On 10/01/11 04:25, Alexander Motin wrote: > Hi. > > Adrian Chadd wrote: >> What happens if this occurs: >> >> * cpu_idle() is entered >> * you enter critical_enter() and call cpu_idleclock() >> * an interrupt occurs, scheduling an immediate callout >> * .. but you've already set the clock register, so it won't be >> serviced until the wait returns. >> >> Perhaps interrupts have to be disabled before critical_enter() and >> cpu_idletick() to ensure an interrupt-driven callout doesn't get >> delayed? > Use of critical section in cpu_idle() from the beginning was based on > number of assumptions about filter interrupt handler's limitations. > These handlers are not guarantied to get updated system time/ticks and > they are discouraged to use callouts. If callout scheduled from > interrupt filter during system wake up, system has no ticks counter > updated yet and you may get callout scheduled into the past (it will be > run immediately) or at least much earlier (up to 250ms) then requested. > In your case callout indeed may get delayed (up to the same 250ms). All > that is not a problem for regular interrupt threaded interrupts -- > interrupt thread execution will be delayed until all stuff get updated. > Can you explain why the critical section is there in more detail? It seems like all of our problems arise because of it. -Nathan