From nobody Mon Jul 04 18:09:29 2022 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 496241C3F752; Mon, 4 Jul 2022 18:09:31 +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 4LcDNB47GFz4kSC; Mon, 4 Jul 2022 18:09:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656958171; 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=q81gRKOb6UWAemo4P17Te7kARuArRJY76UOqrwwaJzk=; b=dHZIG6wRYRyw/WM/8jSQibnQxNGal1GrkO+eUwWAHc4KcD2qSsKitxpE/5pXDIYCz3OisH 30MEP4tUNJzqO78osAsyNhQ2CKnYSn4tNbsk6bBjBVNxAAkTwoxuj8cW7xlZ3Qlul0lg7V GSb5OxJaMBcTAaSFFe9cf0qfOSO6UtAIdW1w+z1do4kevNNyZGe8J95yh6NuHqYJp5HcvH 3h9EEtiAq/vVSlKN1UCNqAW/jZS1yh2n6k/1qZcFF37Q0sFDI5wysyLPhr0YI06V7I8SAJ yyt6qsfVe72N9a5GaRofNsgMn5miugsSqIhIEHXZdAycbUlx90fncaWldQn3qQ== 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 C0D3B15DEB; Mon, 4 Jul 2022 18:09:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 264I9Tn5064559; Mon, 4 Jul 2022 18:09:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 264I9Tvo064558; Mon, 4 Jul 2022 18:09:29 GMT (envelope-from git) Date: Mon, 4 Jul 2022 18:09:29 GMT Message-Id: <202207041809.264I9Tvo064558@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: 2bd4b5475fc5 - stable/13 - hwpmc: Skip GLOBAL_CTRL updates on stop_pmc(). 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/13 X-Git-Reftype: branch X-Git-Commit: 2bd4b5475fc57ba72c8b06c8bcdec4da47f2bb85 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656958171; 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=q81gRKOb6UWAemo4P17Te7kARuArRJY76UOqrwwaJzk=; b=Fo8fkRBclNTve69w4BQNZAAXDivNH4rDUWbUJ0RW2QIpbLrFWPS7RC2dR+2Sp5n4/s2AqS 8ZS6XpQiOzp8NBmCnrcdVXPp74ixsrD7EZXOL9MVlAfyFBkicYyKACP994dgCD9jvxxaCK pqL5HTRC3qLuAELtBclPs1U+jMmxe/1eYSbscyRMl9vhXHNMHUe4ilyveyJUDAspFWztZw Rd2qQLgzjNLGA+q1ot7El+4NZ12TxJw7FHAOzmFK2pqw5KKPqonrXTDglDW48M4pVrFMbl S/asMMBJ251F/1vfhxFNhQz17VmQYSF2p0bYDcKRQidWLE00ak3C6cCENgT2Cg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656958171; a=rsa-sha256; cv=none; b=M5i4vsiiOPiWeXKKuEjqqIrTmv9jB1tE5x8xrD9HyLDxcfP8fj9ttPHwSq8iH1IOcgAz/m 7KMnqRS+vNdJ1BMG6rhccxG0z1BmG0j5nohgKSi8BCpdoqUlNvVqQKKnHjdjYI7yWxGhtw Q/Kh62CIgybXhnOgtAp3nPCr1YubLH+1kHkZvaLUg/qSbE//I4xUMkaZzTAdb361S7miiX 37Zq0zJdHSDDHhl5qgwPD9rAQ23y7q9tXtqKJOsulRGS2ZURMf4fuSp/9gEDDaJVp8EzT5 xO1qDsmaT76zj6Z54QjqSX+WcbPbJ7vbOM5iXnxigFFTtT2oVyFkX3Ut9blXNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=2bd4b5475fc57ba72c8b06c8bcdec4da47f2bb85 commit 2bd4b5475fc57ba72c8b06c8bcdec4da47f2bb85 Author: Alexander Motin AuthorDate: 2022-06-02 22:20:33 +0000 Commit: Alexander Motin CommitDate: 2022-07-04 17:48:10 +0000 hwpmc: Skip GLOBAL_CTRL updates on stop_pmc(). After we wipe PMC configuration, including its local enable bit(s), we don't really care about its global enable bit. Global enable bits now may only be cleared by interrupt handler in case of error (sample buffer overflow). Being set is actually a reset default for them. This saves one WRMSR per process-scope PMC per context switch, that is clearly visible in profiles. MFC after: 1 month (cherry picked from commit 326a8d3e085dda2b82c99cf1eb2997cb4dc99a71) --- sys/dev/hwpmc/hwpmc_core.c | 8 ++------ sys/dev/hwpmc/hwpmc_uncore.c | 6 ++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 56efc72aed80..22e6adbd778d 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -474,8 +474,7 @@ iaf_stop_pmc(int cpu, int ri) cc->pc_iafctrl &= ~(IAF_MASK << (ri * 4)); wrmsr(IAF_CTRL, cc->pc_iafctrl); - cc->pc_globalctrl &= ~(1ULL << (ri + IAF_OFFSET)); - wrmsr(IA_GLOBAL_CTRL, cc->pc_globalctrl); + /* Don't need to write IA_GLOBAL_CTRL, one disable is enough. */ PMCDBG4(MDP,STO,1,"iafctrl=%x(%x) globalctrl=%jx(%jx)", cc->pc_iafctrl, (uint32_t) rdmsr(IAF_CTRL), @@ -979,10 +978,7 @@ iap_stop_pmc(int cpu, int ri) wrmsr(IAP_EVSEL0 + ri, 0); - if (core_version >= 2) { - cc->pc_globalctrl &= ~(1ULL << ri); - wrmsr(IA_GLOBAL_CTRL, cc->pc_globalctrl); - } + /* Don't need to write IA_GLOBAL_CTRL, one disable is enough. */ return (0); } diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c index 1a1d3c744351..f87b36616d18 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -369,8 +369,7 @@ ucf_stop_pmc(int cpu, int ri) PMCDBG1(MDP,STO,1,"ucf-stop ucfctrl=%x", ucfc->pc_ucfctrl); wrmsr(UCF_CTRL, ucfc->pc_ucfctrl); - ucfc->pc_globalctrl &= ~(1ULL << (ri + SELECTOFF(uncore_cputype))); - wrmsr(UC_GLOBAL_CTRL, ucfc->pc_globalctrl); + /* Don't need to write UC_GLOBAL_CTRL, one disable is enough. */ PMCDBG4(MDP,STO,1,"ucfctrl=%x(%x) globalctrl=%jx(%jx)", ucfc->pc_ucfctrl, (uint32_t) rdmsr(UCF_CTRL), @@ -730,8 +729,7 @@ ucp_stop_pmc(int cpu, int ri) /* stop hw. */ wrmsr(SELECTSEL(uncore_cputype) + ri, 0); - cc->pc_globalctrl &= ~(1ULL << ri); - wrmsr(UC_GLOBAL_CTRL, cc->pc_globalctrl); + /* Don't need to write UC_GLOBAL_CTRL, one disable is enough. */ return (0); }