From nobody Wed Oct 18 18:05:58 2023 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 4S9f0k5DqQz4xLCn; Wed, 18 Oct 2023 18:05:58 +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 4S9f0k4WsQz4dtH; Wed, 18 Oct 2023 18:05:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697652358; 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=GQU1+t/qiqHTdWs+EwgcH2PDgfic+6XHrQZzSFuQrMA=; b=PMEs6sGmPe1W0+hyYeKeecMHOdGthifYv9f88PORuOvTn5rNI28w25d6RmkU5REeeB2BA7 J1WPOfCodMkM/IvKgsgWqk+nd81uQjsOegL8dqzNvF//tg00jZH43KFCmxgT1xTdu/+Saz s0a5FIG7o93vPb64Gm4vlwMONZXOpsbcHQzRQf9L2WnY+xexuFn3CCIf++q9AnYeaQ6Tkh y1Q4HOWW0Sg62YIzXQusARZoBe7EJJaBzx6t0Lb7+v0FChBh25dIIfFVMrzGmhevQD8StH IiKf01bMt3iwj/v+2hS/hmGFGuYEe8grqYMknBKruiT0uLsr+GmoJZzARbLkag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697652358; a=rsa-sha256; cv=none; b=eJenwygW69r27kd7kOsjJwoDoP61ZEEMEjKcjLFMujjGEG0d30m8Kh7w+7rpZc0sSgSquT 3z2W39m3jDAdGHo4pL9u4fOA5Ien47mKI+8YqpKhzogN/q+MEsIxi73dA2UjGi5hddBmEx p4DsJWvCOroUJ1T+lMRSMQ9YV2wjFhgLw7iXjlUSKijKqOQQS+sMx6uVE4EKycjWN/8tz5 9C6giN6za74Hlz8rrzScwQQGd+e8Fi0SrlA8u8c7g4ruNW4eIMwZ8iwZj5D+ciRKFQCz7h oantsPYvRANQ4pWp6RA1q1/HFGVuDYAInuEmvW+a7USBgQC7PBm/J0tLMoy/qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697652358; 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=GQU1+t/qiqHTdWs+EwgcH2PDgfic+6XHrQZzSFuQrMA=; b=Y/0TZCJ7bYmBQEUB9GqGWUCF/4ezgC1/LNfKRY+M0W/Cisd8RMgN+X4hB8gnJYLMrIeIf+ hiVbcRL+ryBeXMg0AaLIRe4gaPtR+bUGfqNiQ4EccHVbuxqAxzOZXUwJZEgBTKVtpbR2lL Yie/nun26eKyewtGZOEA3oQB4vzNZOZOXhtiNsDF57i0WcKjQ3qCHIYQkcr8xN88rz2D9m Fe2VIak9A6DHaF4YPkGdSwd+nPiM08NO/WbId2FOTwEnXkbZnZ66l7BKX51hQvEeB+S29D cSLGVpBQ+FIdlJ1mWMCJw43kyyvsFkWEqr+bUgaTVQmsj50F/PQ2qScDjuwvCw== 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 4S9f0k3994z2S3; Wed, 18 Oct 2023 18:05:58 +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 39II5wBx045778; Wed, 18 Oct 2023 18:05:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39II5wAL045775; Wed, 18 Oct 2023 18:05:58 GMT (envelope-from git) Date: Wed, 18 Oct 2023 18:05:58 GMT Message-Id: <202310181805.39II5wAL045775@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 90a6ea5ca0b1 - main - hwpmc: tidy pcd_finalize methods 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 90a6ea5ca0b1b578e265d2479511bd04347f9510 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=90a6ea5ca0b1b578e265d2479511bd04347f9510 commit 90a6ea5ca0b1b578e265d2479511bd04347f9510 Author: Mitchell Horne AuthorDate: 2023-10-18 17:50:49 +0000 Commit: Mitchell Horne CommitDate: 2023-10-18 18:05:44 +0000 hwpmc: tidy pcd_finalize methods Make them a little bit more consistent with one another in terms of what is done: - Add/reduce assertions to what is most useful: a loop to ensure pcpu_fini freed everything - Add PMCDBG trace entries The exception is the dmc620/cmn600 classes, which behave a little differently, so leave them untouched. Reviewed by: jkoshy MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41270 --- sys/dev/hwpmc/hwpmc_amd.c | 32 ++++---------------------------- sys/dev/hwpmc/hwpmc_arm64.c | 4 ++++ sys/dev/hwpmc/hwpmc_armv7.c | 4 ++++ sys/dev/hwpmc/hwpmc_core.c | 4 ++++ sys/dev/hwpmc/hwpmc_powerpc.c | 5 +++++ sys/dev/hwpmc/hwpmc_soft.c | 9 ++------- sys/dev/hwpmc/hwpmc_tsc.c | 10 ++-------- sys/dev/hwpmc/hwpmc_uncore.c | 4 ++++ 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index fbbaf92a1547..000958eb9945 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -1173,37 +1173,13 @@ pmc_amd_initialize(void) void pmc_amd_finalize(struct pmc_mdep *md) { -#if defined(INVARIANTS) - int classindex, i, ncpus, pmcclass; -#endif + PMCDBG0(MDP, INI, 1, "amd-finalize"); pmc_tsc_finalize(md); - KASSERT(amd_pcpu != NULL, ("[amd,%d] NULL per-cpu array pointer", - __LINE__)); - -#if defined(INVARIANTS) - switch (md->pmd_cputype) { -#if defined(__i386__) - case PMC_CPU_AMD_K7: - classindex = PMC_MDEP_CLASS_INDEX_K7; - pmcclass = PMC_CLASS_K7; - break; -#endif - default: - classindex = PMC_MDEP_CLASS_INDEX_K8; - pmcclass = PMC_CLASS_K8; - } - - KASSERT(md->pmd_classdep[classindex].pcd_class == pmcclass, - ("[amd,%d] pmc class mismatch", __LINE__)); - - ncpus = pmc_cpu_max(); - - for (i = 0; i < ncpus; i++) - KASSERT(amd_pcpu[i] == NULL, ("[amd,%d] non-null pcpu", - __LINE__)); -#endif + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(amd_pcpu[i] == NULL, + ("[amd,%d] non-null pcpu cpu %d", __LINE__, i)); free(amd_pcpu, M_PMC); amd_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 9a5debb8016b..4c38a4ae6183 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -611,5 +611,9 @@ pmc_arm64_finalize(struct pmc_mdep *md) { PMCDBG0(MDP, INI, 1, "arm64-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(arm64_pcpu[i] == NULL, + ("[arm64,%d] non-null pcpu cpu %d", __LINE__, i)); + free(arm64_pcpu, M_PMC); } diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c index 5bb6c6fce291..1488af2ae54e 100644 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -535,5 +535,9 @@ pmc_armv7_finalize(struct pmc_mdep *md) { PMCDBG0(MDP, INI, 1, "armv7-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(armv7_pcpu[i] == NULL, + ("[armv7,%d] non-null pcpu cpu %d", __LINE__, i)); + free(armv7_pcpu, M_PMC); } diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 3829a03eb729..ddaff0b5955e 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -1260,6 +1260,10 @@ pmc_core_finalize(struct pmc_mdep *md) { PMCDBG0(MDP,INI,1, "core-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(core_pcpu[i] == NULL, + ("[core,%d] non-null pcpu cpu %d", __LINE__, i)); + free(core_pcpu, M_PMC); core_pcpu = NULL; } diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c index a4bd951fab40..0380988f909f 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -581,6 +581,11 @@ pmc_md_initialize(void) void pmc_md_finalize(struct pmc_mdep *md) { + PMCDBG0(MDP, INI, 1, "powerpc-finalize"); + + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(powerpc_pcpu[i] == NULL, + ("[powerpc,%d] non-null pcpu cpu %d", __LINE__, i)); free(powerpc_pcpu, M_PMC); powerpc_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c index 5606164b3e0f..4679969fb45c 100644 --- a/sys/dev/hwpmc/hwpmc_soft.c +++ b/sys/dev/hwpmc/hwpmc_soft.c @@ -456,17 +456,12 @@ pmc_soft_initialize(struct pmc_mdep *md) void pmc_soft_finalize(struct pmc_mdep *md) { -#ifdef INVARIANTS - int i, ncpus; + PMCDBG0(MDP, INI, 1, "soft-finalize"); - ncpus = pmc_cpu_max(); - for (i = 0; i < ncpus; i++) + for (int i = 0; i < pmc_cpu_max(); i++) KASSERT(soft_pcpu[i] == NULL, ("[soft,%d] non-null pcpu cpu %d", __LINE__, i)); - KASSERT(md->pmd_classdep[PMC_CLASS_INDEX_SOFT].pcd_class == - PMC_CLASS_SOFT, ("[soft,%d] class mismatch", __LINE__)); -#endif ast_deregister(TDA_HWPMC); free(soft_pcpu, M_PMC); soft_pcpu = NULL; diff --git a/sys/dev/hwpmc/hwpmc_tsc.c b/sys/dev/hwpmc/hwpmc_tsc.c index f86b93d58bfb..5d31f8a9c61c 100644 --- a/sys/dev/hwpmc/hwpmc_tsc.c +++ b/sys/dev/hwpmc/hwpmc_tsc.c @@ -339,18 +339,12 @@ pmc_tsc_initialize(struct pmc_mdep *md, int maxcpu) void pmc_tsc_finalize(struct pmc_mdep *md __diagused) { -#ifdef INVARIANTS - int i, ncpus; + PMCDBG0(MDP, INI, 1, "tsc-finalize"); - ncpus = pmc_cpu_max(); - for (i = 0; i < ncpus; i++) + for (int i = 0; i < pmc_cpu_max(); i++) KASSERT(tsc_pcpu[i] == NULL, ("[tsc,%d] non-null pcpu cpu %d", __LINE__, i)); - KASSERT(md->pmd_classdep[PMC_MDEP_CLASS_INDEX_TSC].pcd_class == - PMC_CLASS_TSC, ("[tsc,%d] class mismatch", __LINE__)); -#endif - free(tsc_pcpu, M_PMC); tsc_pcpu = NULL; } diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c index fd4266b605ef..0ee41db0658d 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -758,6 +758,10 @@ pmc_uncore_finalize(struct pmc_mdep *md) { PMCDBG0(MDP,INI,1, "uncore-finalize"); + for (int i = 0; i < pmc_cpu_max(); i++) + KASSERT(uncore_pcpu[i] == NULL, + ("[uncore,%d] non-null pcpu cpu %d", __LINE__, i)); + free(uncore_pcpu, M_PMC); uncore_pcpu = NULL; }