From owner-freebsd-arch@FreeBSD.ORG Sat Apr 19 19:21:53 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A6A6106567D for ; Sat, 19 Apr 2008 19:21:53 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 17F188FC14 for ; Sat, 19 Apr 2008 19:21:52 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id ED8B71A4D82; Sat, 19 Apr 2008 12:21:52 -0700 (PDT) Date: Sat, 19 Apr 2008 12:21:52 -0700 From: Alfred Perlstein To: Jeff Roberson Message-ID: <20080419192152.GX95731@elvis.mu.org> References: <20080419004911.R942@desktop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080419004911.R942@desktop> User-Agent: Mutt/1.4.2.3i Cc: arch@freebsd.org Subject: Re: monitor/mwait support for idle X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Apr 2008 19:21:53 -0000 Jeff, this is very interesting! I have a question about your earlier email. You mentioned that the IPIs and communication to enter the idle state (hlt, mwait) is expensive. Perhaps something to track the number of times entering and exiting the state would be a good idea. Additionally a tuneable for the number of spins before entering the state might be a good idea. Perhaps spinning for "1" or "2" (where 1/2 is one unit of hz) before entering idle might be a good compromise to avoid hlt enter/exit thrashing. Let me know your thoughts on this. It may already be implemented so just saying "we do that" would be fine too. :) -Alfred * Jeff Roberson [080419 03:56] wrote: > http://people.freebsd.org/~jeff/mwait.diff > > This patch implements support for the x86/amd64 monitor and mwait > instructions in the idle loop. This also implements idle loop selection > via a sysctl string. The following loops are supported, in > decreasing order of performance and power consumption: > > spin - Simply returns > mwait - Always use mwait to sleep. CPU enters C0 or C1 depending on > how busy it is. > mwait_hlt - Use mwait when busy but fall back to hlt/acpi when not. > hlt - pure hlt loop > acpi - uses acpi_cpu_idle if available and hlt if not. This is the > default. > > This also introduces a new MD function 'cpu_wake_idle' which allows MD to > use a faster mechanism than IPI to wake idle. In the spin case this is a > nop. For hlt and acpi we resort to an IPI. If the processor is sleeping > in mwait we can simply write to a per-cpu buffer to wake it up. This > saves considerable cpu cycles on the initiator and target. > > The prototype for cpu_idle() changed to accept an integer indication of > how busy we are from the scheduler. If we have been busy MD code may > choose to enter a higher power state on idle. ULE now spins for a short > while if we have been very busy regardless of MD settings. > > There seems to be a problem entering C0 on the Xeons I have access to. It > returns from mwait too quickly. Hopefully intel will respond to my email > about that. > > Feedback welcome. > > Thanks, > Jeff > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" -- - Alfred Perlstein