From nobody Tue May 31 00:05:22 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 70B251B407AE; Tue, 31 May 2022 00:05:22 +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 4LBswy2MgKz4sVk; Tue, 31 May 2022 00:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653955522; 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=hn9I7jUscogC0JKUNxIyjlLAUzb2QIb5pBYG4TDJLmA=; b=Vpkpjuths470U2VbevE4U+/PnFRd0/0a2Pqsw4UB7j0CAPTRn0KBvCoC8wtWo+dqzIxUlv +Gri6hD5Q3i5Xy+PTRIgKX54PjN6ztEwi7aN2bXxxO9OhfR7dRSbXRzh6qCBrl8xxiy/iv UzR5TVuWspavZhzXMNL+IK99z1svRgP8pyyV6Gkwdttm1Nk13SgMMhAI7F3+EgGeYE9/fc BF36srbPV5X0MzYGU+ZqhmaXNhPtSidZ5Nt3gGb9zdSgZIai2yrHpwdheu+ni6ZAkNt+pB Yh/wa40wjjwrpB8VZiPqzyAZfMlwl+v2tVIkdqMReG+ISnXjp52nr5uJP2XjZA== 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 32800208EF; Tue, 31 May 2022 00:05:22 +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 24V05MQe034089; Tue, 31 May 2022 00:05:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24V05MTi034088; Tue, 31 May 2022 00:05:22 GMT (envelope-from git) Date: Tue, 31 May 2022 00:05:22 GMT Message-Id: <202205310005.24V05MTi034088@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: c1e813d12309 - main - hwpmc: Correct selection of Intel fixed counters. 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: c1e813d1230915e19a236ec687cadc1051841e56 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653955522; 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=hn9I7jUscogC0JKUNxIyjlLAUzb2QIb5pBYG4TDJLmA=; b=Y3GNyQfaJe6qWXyZyNqDLuDq9AeC2KvP8G62iNOjP/gR3I2xVdM4vk6wBEblXKRBATKCG5 QgxIQZh/joUWWCXVEsNRSw9OA396OvRG6NYRoH4GrfFLfpo8iWDd1ool1WCg2/N592JnA5 9K+yOpgUK+ngLiQsORE78L6a8kW7SxqcN2egFNkfH1vL/oBk5Bhu05yhUxDRXEEubm+DCU Gvms8oE9kfP4lXFOs6NXXyr4kbUhfyAs53iKp8KK2A8M5xCR7nD7++Sr4x16h6mGqaN4B6 81ExCoFrMLffCWOvEbdZgVrxQNEohAapxKGGUNZTAUI5MbFsA6+c7byQEiohbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653955522; a=rsa-sha256; cv=none; b=h50QfA6AVd3N2C5t51C687KM2/Hy+UX5d9h46gXuGEGzjrHzR/aXMufP45WmB2KyW9x4CC 1SNty0nUV8/r8zap78EVBZoN5/mOvGG0I43bDXhn/xJDaiQAMw0dZphkI90S7/wSU3aeKi mUMcz0o/gE1v3AImqilVoDPVburN6ObuetwoSKGMMX3gUlhmpzYRW/bxWj4AqgLmZSYWs1 UMzUSVGWzYNHVTnRqRsYRET1vMdmgaNFph/WPf2edA2HVxDuV6kM1mCUDiSqdAIU5Cpfg4 7uNa4iIct4YUbiXju7gubOmjTVwvjqwZ0pOjFOc6jl4w5b7hZLK0tzfqY4Jn1w== 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=c1e813d1230915e19a236ec687cadc1051841e56 commit c1e813d1230915e19a236ec687cadc1051841e56 Author: Alexander Motin AuthorDate: 2022-05-30 23:46:48 +0000 Commit: Alexander Motin CommitDate: 2022-05-31 00:05:15 +0000 hwpmc: Correct selection of Intel fixed counters. Intel json's use event=0 to specify fixed counter number via umask. Alternatively fixed counters have equivalent programmable event/umask. MFC after: 1 month --- sys/dev/hwpmc/hwpmc_core.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index fce97cbd5b8e..73cfee0b3975 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -245,15 +245,31 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, ev = IAP_EVSEL_GET(config); umask = IAP_UMASK_GET(config); - /* INST_RETIRED.ANY */ - if (ev == 0xC0 && ri != 0) - return (EINVAL); - /* CPU_CLK_UNHALTED.THREAD */ - if (ev == 0x3C && ri != 1) - return (EINVAL); - /* CPU_CLK_UNHALTED.REF */ - if (ev == 0x0 && umask == 0x3 && ri != 2) - return (EINVAL); + if (ev == 0x0) { + if (umask != ri + 1) + return (EINVAL); + } else { + switch (ri) { + case 0: /* INST_RETIRED.ANY */ + if (ev != 0xC0 || umask != 0x00) + return (EINVAL); + break; + case 1: /* CPU_CLK_UNHALTED.THREAD */ + if (ev != 0x3C || umask != 0x00) + return (EINVAL); + break; + case 2: /* CPU_CLK_UNHALTED.REF */ + if (ev != 0x3C || umask != 0x01) + return (EINVAL); + break; + case 3: /* TOPDOWN.SLOTS */ + if (ev != 0xA4 || umask != 0x01) + return (EINVAL); + break; + default: + return (EINVAL); + } + } pmc_alloc_refs++; if ((cpu_stdext_feature3 & CPUID_STDEXT3_TSXFA) != 0 &&