Date: Sat, 19 Apr 2008 00:56:44 -1000 (HST) From: Jeff Roberson <jroberson@jroberson.net> To: arch@freebsd.org Subject: monitor/mwait support for idle Message-ID: <20080419004911.R942@desktop>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080419004911.R942>