git: 075e4807df3e - main - Do not read timer extra time when MWAIT is used.
Alexander Motin
mav at FreeBSD.org
Mon Mar 8 23:54:31 UTC 2021
The branch main has been updated by mav:
URL: https://cgit.FreeBSD.org/src/commit/?id=075e4807df3e6b0d9196d56e4dbc33765d57e1f8
commit 075e4807df3e6b0d9196d56e4dbc33765d57e1f8
Author: Alexander Motin <mav at FreeBSD.org>
AuthorDate: 2021-03-08 23:43:47 +0000
Commit: Alexander Motin <mav at FreeBSD.org>
CommitDate: 2021-03-08 23:43:47 +0000
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
---
sys/dev/acpica/acpi_cpu.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 436dd9ddaa93..56182ed743de 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -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);
More information about the dev-commits-src-main
mailing list