On Fri, Jun 07, 2019 at 08:22:35PM +0200, Paolo Bonzini wrote: > On 07/06/19 19:16, Marcelo Tosatti wrote: > > There is no "target residency" concept in the virtualized use-case > > (which is what poll_state.c uses to calculate the poll time). > > Actually there is: it is the cost of a vmexit, and it be calibrated with > a very short CPUID loop (e.g. run 100 CPUID instructions and take the > smallest TSC interval---it should take less than 50 microseconds, and > less than a millisecond even on nested virt). For a given application, you want to configure the poll time to the maximum time an event happen after starting the idle procedure. For SAP HANA, that value is between 200us - 800us (most tests require less than 800us, but some require 800us, to significantly avoid the IPIs). "The target residency is the minimum time the hardware must spend in the given state, including the time needed to enter it (which may be substantial), in order to save more energy than it would save by entering one of the shallower idle states instead." Clearly these are two different things... > I think it would make sense to improve poll_state.c to use an adaptive > algorithm similar to the one you implemented, which includes optionally > allowing to poll for an interval larger than the target residency. > > Paolo Ok, so i'll move the adaptive code to poll_state.c, where the driver selects whether to use target_residency or the adaptive value (based on module parameters). Not sure if its an adaptible value is desirable for the non virtualized case.