Date: Wed, 7 Apr 2021 00:31:48 GMT From: Alexander Motin <mav@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 40074783d818 - stable/12 - Do not read timer extra time when MWAIT is used. Message-ID: <202104070031.1370Vm9J020516@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=40074783d8189c1f278d4fe5c373e45a85168534 commit 40074783d8189c1f278d4fe5c373e45a85168534 Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2021-03-08 23:43:47 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2021-04-07 00:31:43 +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 (cherry picked from commit 075e4807df3e6b0d9196d56e4dbc33765d57e1f8) --- 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 94f5b981b3c1..44662741a040 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -1222,18 +1222,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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104070031.1370Vm9J020516>