From nobody Fri Oct 02 13:58:53 2026 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 4hx9P940v2z6vRvV for ; Fri, 02 Oct 2026 13:58:53 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hx9P92FThz4NKM for ; Fri, 02 Oct 2026 13:58:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790949533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wVupE6NeuyjhttphVijCIVaqBlU76yhip3b32sWJFsU=; b=TORqa/66Ax0OSy8uWtvvHJC/lcnq2+f0jar7TPYdB1O2tZQuVcm3QSl3w+CdeXneS+IZya zH91lX8uKzN4g4bFJ2TlJwlOQp5aNSFjJ9VeTgx1uLX4E9PWpBM41dr2ZERH04ZVDWAJq4 VZLQWV/05fDglW0MhFk++XNVM9hzcQX6KZ672IQ3N3Az2NFvk+2C0jghbuaCWdkW7y82HV JwFflgBbxh5wBbawYGY4ehgISOAqdF4NI3ZFSJ9LwWWtd2DKbtJIiF/HmPQs46XynWOixg xmpFAG0slBGqguaZ3vtIZeGmRxLgrZvmve3HYFzw8mDs3P8ilU6aPgKDZVuUFw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1790949533; b=lIYZyJouPu/rOuy69Bwb3AgZuuTW/EpUDj6wT+PRviX0SpG9aKcMLvhMe2kIzgJqf0c1x5 5kV4u0gA7tI52aYocVRua10b9N5RxxK9g/WCg2QJTTWrMm5FPppBKolzZLQyAdSsgrccsK cXrMeAy6xLKYJnZpsmmwCHYJn7GMx6d+LyG57OL5TbFZXYfq8eJ+6sdHL1WYfnV2Mi2mmI yoq+5BHMX0p8dsgnF+RtYcms50xFacS1P/I8/vNyHTNruZZpnRPY4dUydAis1jX21f5ytD 9rbAT4gKMUJtDqOklGQICc+urC6QUNjDNnAVkUGdTDkagyY4grWsmRC4vW6zmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1790949533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wVupE6NeuyjhttphVijCIVaqBlU76yhip3b32sWJFsU=; b=oMD4nn6Ur0mZlohkxKdpfUmwGlUwtPLIbMX+6N+5dU/kmqxQpBJpvd9jBE4QqS3x65ss74 CHOm5HTUsSDMdOTuNRm4AXADMTLwnL+Czk4Ph0q6bIz1iCKt4hSG7PjC63n5kiqrHFT7rK Qlnj67IVvfKpfNRVbNEhyljjNCCzX5pWWq7V1Y17YInhmKkG3D5URparAuGSxJN0xDf3Pz bW5g/6g6fOoWA4f1s8Jmg0sjXYhP5J2eOmPkU1IsfLTTj55LeoksMMuD3kDv0mRkZLvWsP UpqV4CFDjWoi4Ql4wZRi2DwXgACvDI+tAcrEvPLzO8qAB905YdGfpoyMcYqS6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hx9P91HSXzLBm for ; Fri, 02 Oct 2026 13:58:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 34690 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Oct 2026 13:58:53 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Andre Silva From: Mitchell Horne Subject: git: 4b267d4e4f6a - main - hwpmc: fix stopping process PMCs on exit with PerfMonV2 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4b267d4e4f6a6cd7bd08b9c4854fcb26fab8c18c Auto-Submitted: auto-generated Date: Fri, 02 Oct 2026 13:58:53 +0000 Message-Id: <6abfb89d.34690.e2541e7@gitrepo.freebsd.org> The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4b267d4e4f6a6cd7bd08b9c4854fcb26fab8c18c commit 4b267d4e4f6a6cd7bd08b9c4854fcb26fab8c18c Author: Andre Silva AuthorDate: 2026-10-02 13:55:26 +0000 Commit: Mitchell Horne CommitDate: 2026-10-02 13:55:41 +0000 hwpmc: fix stopping process PMCs on exit with PerfMonV2 Since 9d3064010590, pmc_process_exit() calls pmc_process_csw_stop_all() first. That clears pps_cpustate for every virtual PMC on the CPU, so the exit loop then skips the stop and the final read. On AMD PerfMonV2 this has two effects: - The count from the last time slice is lost. A process that never switches out before exit reports 0 with pmcstat -p. - The EVSEL enable bit stays set. After kldunload, the next kldload sees it and says "PMCs maybe in use by firmware!". It is not required that pmc_process_csw_stop_all() should touch the ppc_cpustate field at all; remove this to fix the issues. Reviewed by: mhorne Fixes: 9d3064010590 ("hwpmc_amd: add PerfMonV2 global-control path") Sponsored by: AMD Differential Revision: https://reviews.freebsd.org/D60141 --- sys/dev/hwpmc/hwpmc_mod.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 1a333e137d0a..7db73b5c78c9 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -248,7 +248,6 @@ static void pmc_post_callchain_callback(void); static void pmc_process_allproc(struct pmc *pm); static void pmc_process_csw_in(struct thread *td); static void pmc_process_csw_out(struct thread *td); -static void pmc_process_csw_out_prepare(int cpu); static void pmc_process_csw_start_all(int cpu); static void pmc_process_csw_stop_all(int cpu); static void pmc_process_exec(struct thread *td, @@ -1449,8 +1448,6 @@ pmc_process_csw_stop_all(int cpu) struct pmc_classdep *pcd; u_int class; - pmc_process_csw_out_prepare(cpu); - for (class = 0; class < md->pmd_nclass; class++) { pcd = &md->pmd_classdep[class]; if (pcd->pcd_stop_all != NULL) @@ -1458,32 +1455,6 @@ pmc_process_csw_stop_all(int cpu) } } -/* - * Mark virtual PMCs stopped, before you close hardware gates. - */ -static void -pmc_process_csw_out_prepare(int cpu) -{ - struct pmc *pm; - struct pmc_classdep *pcd; - u_int class; - int adjri; - - for (class = 0; class < md->pmd_nclass; class++) { - pcd = &md->pmd_classdep[class]; - if (pcd->pcd_stop_all == NULL) - continue; - for (adjri = 0; adjri < pcd->pcd_num; adjri++) { - pm = NULL; - (void)pcd->pcd_get_config(cpu, adjri, &pm); - if (pm == NULL || - !PMC_IS_VIRTUAL_MODE(PMC_TO_MODE(pm))) - continue; - pm->pm_pcpu_state[cpu].pps_cpustate = 0; - } - } -} - /* * Thread context switch IN. */