From nobody Tue Dec 26 02:50:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SzfQz6skkz55P1b; Tue, 26 Dec 2023 02:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SzfQz6RNPz4Xb4; Tue, 26 Dec 2023 02:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703559051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mOB9mGDD2YxaySWJZFEsvFnqCosCT+xQDq5MQRqYphI=; b=L1sWqQPMvgYVvPeqYfmSXeFhR+m4j8hiJZL40IxSbXYsJoUb7Ct2w4oBQjdQAFeT+iKuoA Y+uOqKZkbz2ZY60NgnnoZaLcqMrVDnZhD5F+2xJnkLUpY2EMl4wa81EfQB1vo0ZoFpNXIl joIy568O9EwDwbEGTnbTFj49aoKKkpv4yw7OrVRm0lR37WO762OZTPsEK9qyVWO4N0w444 6tZbhU2jqp5jzxhVC/Rw62I2snVu8I/CLYD00Zi+qGp/VvvhG/Bkkl7rogGTmF/8nDS4kp SlALgBklQSn2IZjSVSrKSM9eOmOY6Xxw7R/kzhSLkF9KNPCgA8eaiShHHXR67g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703559051; a=rsa-sha256; cv=none; b=CKoFi+ekgdv5zMcd1XgCnt/B6iAfmmqbCXjq3OfZTjQjH8QKG4p581ouAVxSnDf3hbzvse k71wzsyVa9hiiaqRsbRPEFVgZHFv94RB1U5A4IsWDsrt0wj3I1j/5Uyy48YiPp7x7sPNI2 8tlAwpAXgDPzksCb9qI3rRxstqkdJ69sLbI8a5w5VxtiXca2jSNiCIDhLKH3UqDPBI6qab AY3lh2BmSSfqGILDEq0G4DekfjQ4iiha9h3AIpVfNr6mIMBMZlBzYLVskluweRIoCPNuoQ /RFt8nvZVcdLrnF18O2EoM9XOJ1nbRn8fQNHZFaFQ5YuCzVjS5fnlcFF3n0TGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703559051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mOB9mGDD2YxaySWJZFEsvFnqCosCT+xQDq5MQRqYphI=; b=ltmkwXg+aMptlHToUu6VuvdnL1RDW0cZkaEvPyQA6b2AgxudePcGB6y5lkgi0DHzlhfhV5 FU43Qvsl2ujDMtzGlkV05PUWwgRgidQoR9umOoGBorzd7XXwlDWZbnyr4pD6wnRNVhXeHf MJN/Y1QJZZuH0tl8kEBl2wRtJfVbcBkpxY82G2eci55u17EbtLWkdsX68025JdRUXBfMRG cGIesHQLNh8DO6v4lKwbyL0jXYqhlN9dVG1cOXIcqDBft3LH5PJSFm7yIajyN3qjBKZRuy rZMqOCnjEGR0xMPc4oipbAHdscbil31Dt0UQDc5tBJjB4R1p0Tvk94X5Z0LWXQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SzfQz5DpkzchN; Tue, 26 Dec 2023 02:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BQ2opm6080917; Tue, 26 Dec 2023 02:50:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BQ2ophi080914; Tue, 26 Dec 2023 02:50:51 GMT (envelope-from git) Date: Tue, 26 Dec 2023 02:50:51 GMT Message-Id: <202312260250.3BQ2ophi080914@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 5bc10feacc9d - main - acpi_cpu: Reduce BUS_MASTER_RLD manipulations List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5bc10feacc9d81e3bba9d28734a85e996682b408 Auto-Submitted: auto-generated The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=5bc10feacc9d81e3bba9d28734a85e996682b408 commit 5bc10feacc9d81e3bba9d28734a85e996682b408 Author: Alexander Motin AuthorDate: 2023-12-26 02:19:28 +0000 Commit: Alexander Motin CommitDate: 2023-12-26 02:43:20 +0000 acpi_cpu: Reduce BUS_MASTER_RLD manipulations Instead of setting and clearing BUS_MASTER_RLD register on every C3 state enter/exit, set it only once if the system supports C3 state and we are going to "disable" bus master arbitration while in it. This is what Linux does for the past 14 years, and for even more time this register is not implemented in a relevant hardware. Same time since this is only a single bit in a bigger register, ACPI has to do take a global lock and do read-modify-write for it, that is too expensive, saved only by C3 not entered frequently, but enough to be seen in idle system CPU profiles. MFC after: 1 month --- sys/dev/acpica/acpi_cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 8460cd245b0d..80855cf168e9 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -512,6 +512,9 @@ static void enable_idle(struct acpi_cpu_softc *sc) { + if (sc->cpu_cx_count > sc->cpu_non_c3 + 1 && + (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) + AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); sc->cpu_disable_idle = FALSE; } @@ -1164,14 +1167,13 @@ acpi_cpu_idle(sbintime_t sbt) } /* - * For C3, disable bus master arbitration and enable bus master wake - * if BM control is available, otherwise flush the CPU cache. + * For C3, disable bus master arbitration if BM control is available. + * CPU may have to wake up to handle it. Otherwise flush the CPU cache. */ if (cx_next->type == ACPI_STATE_C3) { - if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { + if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1); - AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1); - } else + else ACPI_FLUSH_CPU_CACHE(); } @@ -1206,12 +1208,10 @@ acpi_cpu_idle(sbintime_t sbt) else end_ticks = cpu_ticks(); - /* Enable bus master arbitration and disable bus master wakeup. */ + /* Enable bus master arbitration. */ if (cx_next->type == ACPI_STATE_C3 && - (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) { + (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0); - AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0); - } ACPI_ENABLE_IRQS(); if (cx_next->type == ACPI_STATE_C3)