Do not read timer extra time when MWAIT is used.

When we enter C2+ state via memory read, it may take chipset some
time to stop CPU.  Extra register read covers that time.  But MWAIT
makes CPU stop immediately, so we don't need to waste time after
wakeup with interrupts still disabled, increasing latency.

On my system it reduces ping localhost latency, waking up all CPUs
once a second, from 277us to 242us.

MFC after:	1 month
This commit is contained in:
Alexander Motin 2021-03-08 18:43:47 -05:00
parent 455219675d
commit 075e4807df

View File

@ -1220,18 +1220,19 @@ acpi_cpu_idle(sbintime_t sbt)
start_time = 0;
cputicks = cpu_ticks();
}
if (cx_next->do_mwait)
if (cx_next->do_mwait) {
acpi_cpu_idle_mwait(cx_next->mwait_hint);
else
} else {
CPU_GET_REG(cx_next->p_lvlx, 1);
/*
* Read the end time twice. Since it may take an arbitrary time
* to enter the idle state, the first read may be executed before
* the processor has stopped. Doing it again provides enough
* margin that we are certain to have a correct value.
*/
AcpiGetTimer(&end_time);
}
/*
* Read the end time twice. Since it may take an arbitrary time
* to enter the idle state, the first read may be executed before
* the processor has stopped. Doing it again provides enough
* margin that we are certain to have a correct value.
*/
AcpiGetTimer(&end_time);
if (cx_next->type == ACPI_STATE_C3) {
AcpiGetTimer(&end_time);
AcpiGetTimerDuration(start_time, end_time, &end_time);