From nobody Fri Jan 19 16:29:33 2024 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 4TGlSZ0GTXz56qqg; Fri, 19 Jan 2024 16:29:34 +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 4TGlSY6sBMz43ql; Fri, 19 Jan 2024 16:29:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705681774; 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=eSYryErFOKb5OFkT9L9wLoLD2pQ6fkl9QyFBAhLLR1E=; b=lrMgJLdf3PXHWEhm91SHbwHJ1TnVaS11aGsgd51tAPDx7GAjHTCbjbfdjuP/uycN5tk8VI BGB671GZ8Qa1wYm8zoN5vrDg3bi5bDe31RAYuyxwQv7K55D0EeDuIPW9VDyX1B5GMqPNgZ fteUsELJshYEULJ6n3zyXntMh+ebOyBSdjaJ4VsHTWqlBittLs0d3lgYgc9yi9GZN9pXpP YZNWkxHX5lPuHa6Nfb8ze7fzW3XzWTbBdpzRFxpFphl4JYrlEg1MYBG3eTwihXSY7reJv9 F9bxT2v+Qseqs+qM/ndrkYqOmwmoYACu+z0otxZnU0lKNX7v0NKdV9BdPLUyaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705681774; 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=eSYryErFOKb5OFkT9L9wLoLD2pQ6fkl9QyFBAhLLR1E=; b=ZvOYVr2uptM6WyeMSqBX0MqfbwlRecUBwv21/bEXT1Pe4p9+NnGRcaz1NBEvMNIv93Z9FS EjszuGzyv5MEHcwv6W2xKAwL3iGd1+zhnbPgp+g0pMv78KoXMDZO4Mu5cthG8SYBpDhiO/ ttvVOW0DRJv89g/JHjiBlK43JBFxTm9aVLZnK/TrYr2nIBXJL5hGAOR6mN0VZrW7wDwfJr 0qptzjwvWpbYNgpO27g5+L6aJgkMYnxEgmN9Ik/0CL7sBue9XPsCrDC9F3g8ykK5VYqhhW MP5g+JR2Gd0O0yHKaFoMbBNS7ulwSYqhRZh8f0SSczqpBRpXMN4ipmwk3yDf/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705681774; a=rsa-sha256; cv=none; b=mLgtYLEh/YQXZSWWeZ4IKxB5fi2lpwFnCQAkchjD7kD3nyrWFibLHgBs0OnsVDAtievZJj 67sk27X+bT8PjtQMl1+/kyjoumAwIp1Lq4f2ZO03c7+skN8ZjeYXI3snzh4rAqENxWZsce v2aDWBONYXhoDuDpLJTdJMesAEY8LP98OQo1MiXJZna8IDklBlUlunwPBSTqNswDoDmW2Q RxqiPKKlURRdgK1kqOYhFyvxgdo2pmorXcmSrJcNWyasVnLLLqA5y7n7NBZ1LYy9bvmJcF xWaMvcKlliqYHOyIVa4z+K/X7qRLlIpHR3b/8JBl7O/NHTwDhJ578l23MledtQ== 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 4TGlSY5cJCzyW5; Fri, 19 Jan 2024 16:29:33 +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 40JGTXLT009857; Fri, 19 Jan 2024 16:29:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40JGTXvC009854; Fri, 19 Jan 2024 16:29:33 GMT (envelope-from git) Date: Fri, 19 Jan 2024 16:29:33 GMT Message-Id: <202401191629.40JGTXvC009854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 4eec3ce0d387 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 4eec3ce0d38752f9b226c3cbae2d749dd37e5fdc Auto-Submitted: auto-generated The branch stable/14 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=4eec3ce0d38752f9b226c3cbae2d749dd37e5fdc commit 4eec3ce0d38752f9b226c3cbae2d749dd37e5fdc Author: Alexander Motin AuthorDate: 2023-12-26 02:19:28 +0000 Commit: Alexander Motin CommitDate: 2024-01-19 16:29:21 +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 (cherry picked from commit 5bc10feacc9d81e3bba9d28734a85e996682b408) --- 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)