From nobody Thu Jun 02 22:35:59 2022 X-Original-To: dev-commits-src-main@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 7F6851B4C90B; Thu, 2 Jun 2022 22:35:59 +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 4LDgpR3CqSz4spr; Thu, 2 Jun 2022 22:35:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654209359; 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=S5+zaZ5f1YONEdtNv6OkSoUzC4nELqQPlhCINr+M+Jg=; b=oBpY+NO6dR/+naMeAC7mSGdz/5ONDsepV2mDoEsRqiqGllsD0JSuktoA2ncfxk07D3jg76 EwSmUB6w3rcIzG49sBJZws3cViuXKE0t3hlf5nPu282I+BuhuAHVHFWJ2eun0r2piNRuif EG6d02c1QwiD14KTh/VnfI/peN9Y64TfYlhDJMzUt8TIs10qzSlRDzROvNxZw+Rccws6FA IeBXHGs7hrGoAlSxDBF8DeikDN+1cU6tOS7enfVWFGshC/KlBEYBu+8hNBcB2vPDIfEw+6 uaO5FB3CVn2JFuynLxASZv9k5ypxgjhW0Ux61snk/neaJ06WZlnKN3M5lf8zCA== 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 405FD1D25D; Thu, 2 Jun 2022 22:35:59 +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 252MZxGa037290; Thu, 2 Jun 2022 22:35:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 252MZxpR037289; Thu, 2 Jun 2022 22:35:59 GMT (envelope-from git) Date: Thu, 2 Jun 2022 22:35:59 GMT Message-Id: <202206022235.252MZxpR037289@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: 326a8d3e085d - main - hwpmc: Skip GLOBAL_CTRL updates on stop_pmc(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 326a8d3e085dda2b82c99cf1eb2997cb4dc99a71 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654209359; 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=S5+zaZ5f1YONEdtNv6OkSoUzC4nELqQPlhCINr+M+Jg=; b=JUoK1jMAxRd32ola0atYRDkVEIs53MVu4/hAhTYoSLHoEP21lZEwM4hRJioycVLli3DpIO p15xPxW8LZnHuyFquU/tUlh+q0Yg1/ARQ1wRETBQC0z1mH2tQd+iaIu59HaDzAvZPGX377 VQ8xJ4kyAtL2VP4N2UeFwmBzbno0k4mPhWwvhz+NP9UMi/yq9me1zyTeQvR9ZlSLt+G8CH MKeNPFp79Xkk2ADyd39OF6H2utc9GzS3yK23797Ai6WbhgVDFYPfVj/rV315zv9SdBooy8 k72NAA0pA55r9Zyx2Sec8hbsqXltMDJO3WzQ978MApqBFJmgLSZyyYbV8juCUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654209359; a=rsa-sha256; cv=none; b=DxaY+Z0rWFTCeewBXkQw+FzOK8I9EY5cHAVq9r954wkYHM8N+tVIYP7YUjg5O6nJ0QSUek /O9sUt4doyK8SHNSuOSIe5bSOIiaqOyuvP22iRplW0RGO8ijNpQuQLasDEPYvq1CJ3WEn1 CAJv/2mqQSnuqHPT2iLOy2LdIwVtn3vABtUquD2oV3z4Dyxx7y2VBs80lxqezQkDE4HL/0 Vk203t7NUk/qHlbzktdyAJHyG7Wthk+ugqIWODRZuo9fUVI9BEC/BIjDXYVzQDeIuVcQLQ uEQDRCY2SwCr8JTphGlsee2cKj+hzrY+RSCvyUSWpkSMYe+iKMo5tv2VMQCudQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=326a8d3e085dda2b82c99cf1eb2997cb4dc99a71 commit 326a8d3e085dda2b82c99cf1eb2997cb4dc99a71 Author: Alexander Motin AuthorDate: 2022-06-02 22:20:33 +0000 Commit: Alexander Motin CommitDate: 2022-06-02 22:35:55 +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 --- 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 a2607ca1d9e3..5d6ca02ea792 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -472,8 +472,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), @@ -975,10 +974,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 f69b21e173d5..0d9085564c2a 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -366,8 +366,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), @@ -724,8 +723,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); }