From nobody Fri Jun 09 19:58:14 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 4QdBhk6b9Pz4cK5R; Fri, 9 Jun 2023 19:58:14 +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 4QdBhk5tprz4JhQ; Fri, 9 Jun 2023 19:58:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686340694; 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=NgxQA3cCAmzEU/XLhrKvb06ehee3QRzYqTZ/Q9IhnWc=; b=lI6KhZSidVlfv12/TLcTPrrIk/5JmPhCF+akrAyziUjEx1vUyD0KF7fEEzTDbLqEP+81Wu 9jlc5PdMYYW0mcFj6ofGTuvDH3oFHoEu6fuEJjPXIyxH1hwcdHNJZI4TDYMwT+vOXX/YZf cPrad7BXN6yUhmAJVi4jKlnKSkgZuSZQpvywF/FqIY/l49ISYhQLYg3gXDqH4HVPSaS78h JfGFcZPmOYBX7b+XJ4BXplvrrpJ5IZTHlfY3kVoQWvjJh7DZt/Io9q+zDKjZLSaj8bbL2p kjVTzMcPEK5NgYDh4XnUoCugkRRsBSECwuc+/guMT8paOH9lrf1fh9tm3Xc+zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686340694; 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=NgxQA3cCAmzEU/XLhrKvb06ehee3QRzYqTZ/Q9IhnWc=; b=fMJd3UyQvY0APU7/ZWEr8kpb8fpe6o9TCgD/Djm+ccVn6u5Kb/pwBoYfcYhVTY1nMJaevr +paqx1TkF7G+a6j3rEeJiJNCyBTXTBtuHG7YiaC0ROG530CuSZcrVM+m1f7AMzwHx0+eyc Giucw/LfpU7jLPkJ2C7J9w5tB5IDIGakFWHsxgjVssoZViRgBhrFZKbszj2uV3O9QVLnXN RRsm4naFUkjGD3Y2ro94tpeWrnc3ZjfgmWKDp8isHnZNcLGMuOxwA2LrsJ3CTRwtRdB1yV HaSR8vhpF+kBMC1e9MxGu4Hn5+60IM1B7ys5S9D37c4RUMKCS0QeXZqPEKndGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686340694; a=rsa-sha256; cv=none; b=R9YAn9boOyF1Ed4D4z4rz+wzHRO3ZZxmykX7sSY7+He8NGcnMmwasZdUxkhSMpb9zJp4MW HUEZZSr84tTJiIDbjxnwwmnWpfejlu9qXFMB0GkDJL2qLD91zFXht3CTCL9obTpkQAeB/V Ij1pUee8k/1lJB/hNP4EoQAYrp8qNew+HfEuBshESbiex3/lmD6wuy8LFpFhZwusum/+3F XseJ3vIlx5kOa540FTfKTA85mX1Y6Ed5B9ydQHpZW0HMmnRGKz3YCin1LmdaoWI6/oD+kz we5Oo8iAjMJHNAgatasXL2Dt9BN6DtwSiBsVhPtealUOXtqsc1qa7iR4Gr9TYg== 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 4QdBhk4wdPznwv; Fri, 9 Jun 2023 19:58:14 +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 359JwEWi072277; Fri, 9 Jun 2023 19:58:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 359JwElt072276; Fri, 9 Jun 2023 19:58:14 GMT (envelope-from git) Date: Fri, 9 Jun 2023 19:58:14 GMT Message-Id: <202306091958.359JwElt072276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 1b7d148ed773 - stable/13 - hwpmc: pass pmc pointer to more class 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 1b7d148ed773259d1e247c326ff8d500f92f289a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=1b7d148ed773259d1e247c326ff8d500f92f289a commit 1b7d148ed773259d1e247c326ff8d500f92f289a Author: Mitchell Horne AuthorDate: 2023-05-05 22:00:02 +0000 Commit: Mitchell Horne CommitDate: 2023-06-09 19:47:33 +0000 hwpmc: pass pmc pointer to more class methods In many cases this avoids an extra lookup, since the callers always have pm at hand. We can also eliminate several assertions, mostly for pm != NULL. The class methods are an internal interface, and the callers already handle such a scenario. No functional change intended. Reviewed by: jkoshy MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39915 (cherry picked from commit 39f92a76a99a2ceb747250da4f2d627b9c317f8c) --- sys/dev/hwpmc/hwpmc_amd.c | 39 ++++----------------------- sys/dev/hwpmc/hwpmc_arm64.c | 27 +++++-------------- sys/dev/hwpmc/hwpmc_armv7.c | 26 +++++------------- sys/dev/hwpmc/hwpmc_beri.c | 20 +++----------- sys/dev/hwpmc/hwpmc_core.c | 62 ++++++------------------------------------- sys/dev/hwpmc/hwpmc_e500.c | 2 +- sys/dev/hwpmc/hwpmc_mips.c | 26 +++++------------- sys/dev/hwpmc/hwpmc_mod.c | 34 +++++++++++++----------- sys/dev/hwpmc/hwpmc_powerpc.c | 25 +++++------------ sys/dev/hwpmc/hwpmc_powerpc.h | 8 +++--- sys/dev/hwpmc/hwpmc_soft.c | 41 ++++------------------------ sys/dev/hwpmc/hwpmc_tsc.c | 17 ++++-------- sys/dev/hwpmc/hwpmc_uncore.c | 62 ++++++------------------------------------- sys/sys/pmc.h | 12 +++++---- 14 files changed, 90 insertions(+), 311 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index 05584ee1660d..36411da871ea 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -397,11 +397,10 @@ static struct amd_cpu **amd_pcpu; */ static int -amd_read_pmc(int cpu, int ri, pmc_value_t *v) +amd_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { enum pmc_mode mode; const struct amd_descr *pd; - struct pmc *pm; pmc_value_t tmp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -411,13 +410,7 @@ amd_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(amd_pcpu[cpu], ("[amd,%d] null per-cpu, cpu %d", __LINE__, cpu)); - pm = amd_pcpu[cpu]->pc_amdpmcs[ri].phw_pmc; pd = &amd_pmcdesc[ri]; - - KASSERT(pm != NULL, - ("[amd,%d] No owner for HWPMC [cpu%d,pmc%d]", __LINE__, - cpu, ri)); - mode = PMC_TO_MODE(pm); PMCDBG2(MDP,REA,1,"amd-read id=%d class=%d", ri, pd->pm_descr.pd_class); @@ -456,24 +449,17 @@ amd_read_pmc(int cpu, int ri, pmc_value_t *v) */ static int -amd_write_pmc(int cpu, int ri, pmc_value_t v) +amd_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { const struct amd_descr *pd; enum pmc_mode mode; - struct pmc *pm; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[amd,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); - pm = amd_pcpu[cpu]->pc_amdpmcs[ri].phw_pmc; pd = &amd_pmcdesc[ri]; - - KASSERT(pm != NULL, - ("[amd,%d] PMC not owned (cpu%d,pmc%d)", __LINE__, - cpu, ri)); - mode = PMC_TO_MODE(pm); #ifdef HWPMC_DEBUG @@ -705,11 +691,9 @@ amd_release_pmc(int cpu, int ri, struct pmc *pmc) */ static int -amd_start_pmc(int cpu, int ri) +amd_start_pmc(int cpu, int ri, struct pmc *pm) { uint64_t config; - struct pmc *pm; - struct pmc_hw *phw; const struct amd_descr *pd; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -717,14 +701,8 @@ amd_start_pmc(int cpu, int ri) KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); - phw = &amd_pcpu[cpu]->pc_amdpmcs[ri]; - pm = phw->phw_pmc; pd = &amd_pmcdesc[ri]; - KASSERT(pm != NULL, - ("[amd,%d] starting cpu%d,pmc%d with null pmc record", __LINE__, - cpu, ri)); - PMCDBG2(MDP,STA,1,"amd-start cpu=%d ri=%d", cpu, ri); KASSERT(AMD_PMC_IS_STOPPED(pd->pm_evsel), @@ -745,10 +723,8 @@ amd_start_pmc(int cpu, int ri) */ static int -amd_stop_pmc(int cpu, int ri) +amd_stop_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc *pm; - struct pmc_hw *phw; const struct amd_descr *pd; uint64_t config; int i; @@ -758,13 +734,8 @@ amd_stop_pmc(int cpu, int ri) KASSERT(ri >= 0 && ri < AMD_NPMCS, ("[amd,%d] illegal row-index %d", __LINE__, ri)); - phw = &amd_pcpu[cpu]->pc_amdpmcs[ri]; - pm = phw->phw_pmc; - pd = &amd_pmcdesc[ri]; + pd = &amd_pmcdesc[ri]; - KASSERT(pm != NULL, - ("[amd,%d] cpu%d,pmc%d no PMC to stop", __LINE__, - cpu, ri)); KASSERT(!AMD_PMC_IS_STOPPED(pd->pm_evsel), ("[amd,%d] PMC%d, CPU%d \"%s\" already stopped", __LINE__, ri, cpu, pd->pm_descr.pd_name)); diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index a89f26f90dd0..36524072d50c 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -212,10 +212,9 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, static int -arm64_read_pmc(int cpu, int ri, pmc_value_t *v) +arm64_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { pmc_value_t tmp; - struct pmc *pm; register_t s; int reg; @@ -224,8 +223,6 @@ arm64_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < arm64_npmcs, ("[arm64,%d] illegal row index %d", __LINE__, ri)); - pm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc; - /* * Ensure we don't get interrupted while updating the overflow count. */ @@ -261,17 +258,14 @@ arm64_read_pmc(int cpu, int ri, pmc_value_t *v) } static int -arm64_write_pmc(int cpu, int ri, pmc_value_t v) +arm64_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[arm64,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < arm64_npmcs, ("[arm64,%d] illegal row-index %d", __LINE__, ri)); - pm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc; - if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) v = ARMV8_RELOAD_COUNT_TO_PERFCTR_VALUE(v); @@ -307,14 +301,10 @@ arm64_config_pmc(int cpu, int ri, struct pmc *pm) } static int -arm64_start_pmc(int cpu, int ri) +arm64_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc_hw *phw; uint32_t config; - struct pmc *pm; - phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_arm64.pm_arm64_evsel; /* @@ -335,13 +325,8 @@ arm64_start_pmc(int cpu, int ri) } static int -arm64_stop_pmc(int cpu, int ri) +arm64_stop_pmc(int cpu, int ri, struct pmc *pm __unused) { - struct pmc_hw *phw; - struct pmc *pm; - - phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri]; - pm = phw->phw_pmc; /* * Disable the PMCs. @@ -413,10 +398,10 @@ arm64_intr(struct trapframe *tf) error = pmc_process_interrupt(PMC_HR, pm, tf); if (error) - arm64_stop_pmc(cpu, ri); + arm64_stop_pmc(cpu, ri, pm); /* Reload sampling count */ - arm64_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount); + arm64_write_pmc(cpu, ri, pm, pm->pm_sc.pm_reloadcount); } return (retval); diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c index 2cfac1e857bd..052b97f35586 100644 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -163,10 +163,9 @@ armv7_allocate_pmc(int cpu, int ri, struct pmc *pm, static int -armv7_read_pmc(int cpu, int ri, pmc_value_t *v) +armv7_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { pmc_value_t tmp; - struct pmc *pm; register_t s; u_int reg; @@ -175,8 +174,6 @@ armv7_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < armv7_npmcs, ("[armv7,%d] illegal row index %d", __LINE__, ri)); - pm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc; - s = intr_disable(); tmp = armv7_pmcn_read(ri, pm->pm_md.pm_armv7.pm_armv7_evsel); @@ -215,17 +212,14 @@ armv7_read_pmc(int cpu, int ri, pmc_value_t *v) } static int -armv7_write_pmc(int cpu, int ri, pmc_value_t v) +armv7_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[armv7,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < armv7_npmcs, ("[armv7,%d] illegal row-index %d", __LINE__, ri)); - pm = armv7_pcpu[cpu]->pc_armv7pmcs[ri].phw_pmc; - if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) v = ARMV7_RELOAD_COUNT_TO_PERFCTR_VALUE(v); @@ -264,14 +258,10 @@ armv7_config_pmc(int cpu, int ri, struct pmc *pm) } static int -armv7_start_pmc(int cpu, int ri) +armv7_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc_hw *phw; uint32_t config; - struct pmc *pm; - phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_armv7.pm_armv7_evsel; /* @@ -293,14 +283,10 @@ armv7_start_pmc(int cpu, int ri) } static int -armv7_stop_pmc(int cpu, int ri) +armv7_stop_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc_hw *phw; - struct pmc *pm; uint32_t config; - phw = &armv7_pcpu[cpu]->pc_armv7pmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_armv7.pm_armv7_evsel; if (config == PMC_EV_CPU_CYCLES) ri = 31; @@ -377,10 +363,10 @@ armv7_intr(struct trapframe *tf) error = pmc_process_interrupt(PMC_HR, pm, tf); if (error) - armv7_stop_pmc(cpu, ri); + armv7_stop_pmc(cpu, ri, pm); /* Reload sampling count */ - armv7_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount); + armv7_write_pmc(cpu, ri, pm, pm->pm_sc.pm_reloadcount); } return (retval); diff --git a/sys/dev/hwpmc/hwpmc_beri.c b/sys/dev/hwpmc/hwpmc_beri.c index ce15bb57fda4..77a419c6e82b 100644 --- a/sys/dev/hwpmc/hwpmc_beri.c +++ b/sys/dev/hwpmc/hwpmc_beri.c @@ -217,10 +217,9 @@ beri_allocate_pmc(int cpu, int ri, struct pmc *pm, } static int -beri_read_pmc(int cpu, int ri, pmc_value_t *v) +beri_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { uint32_t config; - struct pmc *pm; pmc_value_t new; pmc_value_t start_val; pmc_value_t stop_val; @@ -232,7 +231,6 @@ beri_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < beri_npmcs, ("[beri,%d] illegal row index %d", __LINE__, ri)); - pm = beri_pcpu[cpu]->pc_beripmcs[ri].phw_pmc; config = pm->pm_md.pm_mips_evsel; start_val = beri_pcpu[cpu]->start_values[config]; @@ -260,9 +258,8 @@ beri_read_pmc(int cpu, int ri, pmc_value_t *v) } static int -beri_write_pmc(int cpu, int ri, pmc_value_t v) +beri_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; uint32_t config; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -270,7 +267,6 @@ beri_write_pmc(int cpu, int ri, pmc_value_t v) KASSERT(ri >= 0 && ri < beri_npmcs, ("[beri,%d] illegal row-index %d", __LINE__, ri)); - pm = beri_pcpu[cpu]->pc_beripmcs[ri].phw_pmc; config = pm->pm_md.pm_mips_evsel; if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) @@ -310,15 +306,11 @@ beri_config_pmc(int cpu, int ri, struct pmc *pm) } static int -beri_start_pmc(int cpu, int ri) +beri_start_pmc(int cpu, int ri, struct pmc *pm) { uint32_t config; - struct pmc *pm; - struct pmc_hw *phw; pmc_value_t v; - phw = &beri_pcpu[cpu]->pc_beripmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_mips_evsel; v = beri_event_codes[config].get_func(); @@ -328,15 +320,11 @@ beri_start_pmc(int cpu, int ri) } static int -beri_stop_pmc(int cpu, int ri) +beri_stop_pmc(int cpu, int ri, struct pmc *pm) { uint32_t config; - struct pmc *pm; - struct pmc_hw *phw; pmc_value_t v; - phw = &beri_pcpu[cpu]->pc_beripmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_mips_evsel; v = beri_event_codes[config].get_func(); diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index ad9d323bdb9a..d80edeefb0d0 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -368,9 +368,8 @@ iaf_get_msr(int ri, uint32_t *msr) } static int -iaf_read_pmc(int cpu, int ri, pmc_value_t *v) +iaf_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { - struct pmc *pm; pmc_value_t tmp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -378,12 +377,6 @@ iaf_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < core_iaf_npmc, ("[core,%d] illegal row-index %d", __LINE__, ri)); - pm = core_pcpu[cpu]->pc_corepmcs[ri + core_iaf_ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] cpu %d ri %d(%d) pmc not configured", __LINE__, cpu, - ri, ri + core_iaf_ri)); - tmp = rdpmc(IAF_RI_TO_MSR(ri)); if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) @@ -421,9 +414,8 @@ iaf_release_pmc(int cpu, int ri, struct pmc *pmc) } static int -iaf_start_pmc(int cpu, int ri) +iaf_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc *pm; struct core_cpu *cc; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -434,8 +426,6 @@ iaf_start_pmc(int cpu, int ri) PMCDBG2(MDP,STA,1,"iaf-start cpu=%d ri=%d", cpu, ri); cc = core_pcpu[cpu]; - pm = cc->pc_corepmcs[ri + core_iaf_ri].phw_pmc; - cc->pc_iafctrl |= pm->pm_md.pm_iaf.pm_iaf_ctrl; wrmsr(IAF_CTRL, cc->pc_iafctrl); @@ -450,7 +440,7 @@ iaf_start_pmc(int cpu, int ri) } static int -iaf_stop_pmc(int cpu, int ri) +iaf_stop_pmc(int cpu, int ri, struct pmc *pm) { struct core_cpu *cc; @@ -476,10 +466,9 @@ iaf_stop_pmc(int cpu, int ri) } static int -iaf_write_pmc(int cpu, int ri, pmc_value_t v) +iaf_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { struct core_cpu *cc; - struct pmc *pm; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[core,%d] illegal cpu value %d", __LINE__, cpu)); @@ -487,10 +476,6 @@ iaf_write_pmc(int cpu, int ri, pmc_value_t v) ("[core,%d] illegal row-index %d", __LINE__, ri)); cc = core_pcpu[cpu]; - pm = cc->pc_corepmcs[ri + core_iaf_ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri)); if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) v = iaf_reload_count_to_perfctr_value(v); @@ -846,9 +831,8 @@ iap_get_msr(int ri, uint32_t *msr) } static int -iap_read_pmc(int cpu, int ri, pmc_value_t *v) +iap_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { - struct pmc *pm; pmc_value_t tmp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -856,12 +840,6 @@ iap_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < core_iap_npmc, ("[core,%d] illegal row-index %d", __LINE__, ri)); - pm = core_pcpu[cpu]->pc_corepmcs[ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, - ri)); - tmp = rdpmc(ri); if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) *v = iap_perfctr_value_to_reload_count(tmp); @@ -894,9 +872,8 @@ iap_release_pmc(int cpu, int ri, struct pmc *pm) } static int -iap_start_pmc(int cpu, int ri) +iap_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc *pm; uint64_t evsel; struct core_cpu *cc; @@ -906,11 +883,6 @@ iap_start_pmc(int cpu, int ri) ("[core,%d] illegal row-index %d", __LINE__, ri)); cc = core_pcpu[cpu]; - pm = cc->pc_corepmcs[ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] starting cpu%d,ri%d with no pmc configured", - __LINE__, cpu, ri)); PMCDBG2(MDP,STA,1, "iap-start cpu=%d ri=%d", cpu, ri); @@ -943,23 +915,14 @@ iap_start_pmc(int cpu, int ri) } static int -iap_stop_pmc(int cpu, int ri) +iap_stop_pmc(int cpu, int ri, struct pmc *pm __unused) { - struct pmc *pm __diagused; - struct core_cpu *cc; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[core,%d] illegal cpu value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < core_iap_npmc, ("[core,%d] illegal row index %d", __LINE__, ri)); - cc = core_pcpu[cpu]; - pm = cc->pc_corepmcs[ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] cpu%d ri%d no configured PMC to stop", __LINE__, - cpu, ri)); - PMCDBG2(MDP,STO,1, "iap-stop cpu=%d ri=%d", cpu, ri); wrmsr(IAP_EVSEL0 + ri, 0); @@ -970,23 +933,14 @@ iap_stop_pmc(int cpu, int ri) } static int -iap_write_pmc(int cpu, int ri, pmc_value_t v) +iap_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; - struct core_cpu *cc; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[core,%d] illegal cpu value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < core_iap_npmc, ("[core,%d] illegal row index %d", __LINE__, ri)); - cc = core_pcpu[cpu]; - pm = cc->pc_corepmcs[ri].phw_pmc; - - KASSERT(pm, - ("[core,%d] cpu%d ri%d no configured PMC to stop", __LINE__, - cpu, ri)); - if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) v = iap_reload_count_to_perfctr_value(v); diff --git a/sys/dev/hwpmc/hwpmc_e500.c b/sys/dev/hwpmc/hwpmc_e500.c index b82bada95fe3..020337830eb5 100644 --- a/sys/dev/hwpmc/hwpmc_e500.c +++ b/sys/dev/hwpmc/hwpmc_e500.c @@ -341,7 +341,7 @@ e500_pcpu_init(struct pmc_mdep *md, int cpu) for (i = 0; i < E500_MAX_PMCS; i++) /* Initialize the PMC to stopped */ - powerpc_stop_pmc(cpu, i); + e500_set_pmc(cpu, i, PMCN_NONE); /* Unfreeze global register. */ mtpmr(PMR_PMGC0, PMGC_PMIE | PMGC_FCECE); diff --git a/sys/dev/hwpmc/hwpmc_mips.c b/sys/dev/hwpmc/hwpmc_mips.c index 1ed3fdea8915..cf9550b4cbc9 100644 --- a/sys/dev/hwpmc/hwpmc_mips.c +++ b/sys/dev/hwpmc/hwpmc_mips.c @@ -113,9 +113,8 @@ mips_allocate_pmc(int cpu, int ri, struct pmc *pm, static int -mips_read_pmc(int cpu, int ri, pmc_value_t *v) +mips_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { - struct pmc *pm; pmc_value_t tmp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -123,7 +122,6 @@ mips_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < mips_npmcs, ("[mips,%d] illegal row index %d", __LINE__, ri)); - pm = mips_pcpu[cpu]->pc_mipspmcs[ri].phw_pmc; tmp = mips_pmcn_read(ri); PMCDBG2(MDP,REA,2,"mips-read id=%d -> %jd", ri, tmp); @@ -136,17 +134,14 @@ mips_read_pmc(int cpu, int ri, pmc_value_t *v) } static int -mips_write_pmc(int cpu, int ri, pmc_value_t v) +mips_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[mips,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < mips_npmcs, ("[mips,%d] illegal row-index %d", __LINE__, ri)); - pm = mips_pcpu[cpu]->pc_mipspmcs[ri].phw_pmc; - if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) v = (1UL << (mips_pmc_spec.ps_counter_width - 1)) - v; @@ -181,14 +176,10 @@ mips_config_pmc(int cpu, int ri, struct pmc *pm) } static int -mips_start_pmc(int cpu, int ri) +mips_start_pmc(int cpu, int ri, struct pmc *pm) { uint32_t config; - struct pmc *pm; - struct pmc_hw *phw; - phw = &mips_pcpu[cpu]->pc_mipspmcs[ri]; - pm = phw->phw_pmc; config = pm->pm_md.pm_mips_evsel; /* Enable the PMC. */ @@ -207,13 +198,8 @@ mips_start_pmc(int cpu, int ri) } static int -mips_stop_pmc(int cpu, int ri) +mips_stop_pmc(int cpu, int ri, struct pmc *pm __unused) { - struct pmc *pm; - struct pmc_hw *phw; - - phw = &mips_pcpu[cpu]->pc_mipspmcs[ri]; - pm = phw->phw_pmc; /* * Disable the PMCs. @@ -297,11 +283,11 @@ mips_pmc_intr(struct trapframe *tf) r0 = 0; else if (ri == 1) r2 = 0; - mips_stop_pmc(cpu, ri); + mips_stop_pmc(cpu, ri, pm); } /* Reload sampling count */ - mips_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount); + mips_write_pmc(cpu, ri, pm, pm->pm_sc.pm_reloadcount); } /* diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 7434fbf15d0d..fb8679f65a38 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -1488,7 +1488,7 @@ pmc_process_csw_in(struct thread *td) PMCDBG3(CSW,SWI,1,"cpu=%d ri=%d new=%jd", cpu, ri, newvalue); - pcd->pcd_write_pmc(cpu, adjri, newvalue); + pcd->pcd_write_pmc(cpu, adjri, pm, newvalue); /* If a sampling mode PMC, reset stalled state. */ if (PMC_TO_MODE(pm) == PMC_MODE_TS) @@ -1498,7 +1498,7 @@ pmc_process_csw_in(struct thread *td) pm->pm_pcpu_state[cpu].pps_cpustate = 1; /* Start the PMC. */ - pcd->pcd_start_pmc(cpu, adjri); + pcd->pcd_start_pmc(cpu, adjri, pm); } /* @@ -1601,7 +1601,7 @@ pmc_process_csw_out(struct thread *td) */ pm->pm_pcpu_state[cpu].pps_cpustate = 0; if (pm->pm_pcpu_state[cpu].pps_stalled == 0) - pcd->pcd_stop_pmc(cpu, adjri); + pcd->pcd_stop_pmc(cpu, adjri, pm); KASSERT(counter_u64_fetch(pm->pm_runcount) > 0, ("[pmc,%d] pm=%p runcount %ld", __LINE__, (void *) pm, @@ -1625,7 +1625,7 @@ pmc_process_csw_out(struct thread *td) ("[pmc,%d] pp refcnt = %d", __LINE__, pp->pp_refcnt)); - pcd->pcd_read_pmc(cpu, adjri, &newvalue); + pcd->pcd_read_pmc(cpu, adjri, pm, &newvalue); if (mode == PMC_MODE_TS) { PMCDBG3(CSW,SWO,1,"cpu=%d ri=%d val=%jd (samp)", @@ -2824,7 +2824,7 @@ pmc_release_pmc_descriptor(struct pmc *pm) PMCDBG2(PMC,REL,2, "stopping cpu=%d ri=%d", cpu, ri); critical_enter(); - pcd->pcd_stop_pmc(cpu, adjri); + pcd->pcd_stop_pmc(cpu, adjri, pm); critical_exit(); } @@ -3246,7 +3246,7 @@ pmc_start(struct pmc *pm) pm->pm_state = PMC_STATE_RUNNING; critical_enter(); - if ((error = pcd->pcd_write_pmc(cpu, adjri, + if ((error = pcd->pcd_write_pmc(cpu, adjri, pm, PMC_IS_SAMPLING_MODE(mode) ? pm->pm_sc.pm_reloadcount : pm->pm_sc.pm_initial)) == 0) { @@ -3256,7 +3256,7 @@ pmc_start(struct pmc *pm) /* Indicate that we desire this to run. Start it. */ pm->pm_pcpu_state[cpu].pps_cpustate = 1; - error = pcd->pcd_start_pmc(cpu, adjri); + error = pcd->pcd_start_pmc(cpu, adjri, pm); } critical_exit(); @@ -3321,8 +3321,9 @@ pmc_stop(struct pmc *pm) pm->pm_pcpu_state[cpu].pps_cpustate = 0; critical_enter(); - if ((error = pcd->pcd_stop_pmc(cpu, adjri)) == 0) - error = pcd->pcd_read_pmc(cpu, adjri, &pm->pm_sc.pm_initial); + if ((error = pcd->pcd_stop_pmc(cpu, adjri, pm)) == 0) + error = pcd->pcd_read_pmc(cpu, adjri, pm, + &pm->pm_sc.pm_initial); critical_exit(); pmc_restore_cpu_binding(&pb); @@ -4400,7 +4401,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) if ((pm->pm_flags & PMC_F_ATTACHED_TO_OWNER) && (pm->pm_state == PMC_STATE_RUNNING)) error = (*pcd->pcd_read_pmc)(cpu, adjri, - &oldvalue); + pm, &oldvalue); else oldvalue = pm->pm_gv.pm_savedvalue; } @@ -4425,13 +4426,14 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) critical_enter(); /* save old value */ - if (prw.pm_flags & PMC_F_OLDVALUE) + if (prw.pm_flags & PMC_F_OLDVALUE) { if ((error = (*pcd->pcd_read_pmc)(cpu, adjri, - &oldvalue))) + pm, &oldvalue))) goto error; + } /* write out new value */ if (prw.pm_flags & PMC_F_NEWVALUE) - error = (*pcd->pcd_write_pmc)(cpu, adjri, + error = (*pcd->pcd_write_pmc)(cpu, adjri, pm, prw.pm_value); error: critical_exit(); @@ -5028,7 +5030,7 @@ pmc_process_samples(int cpu, ring_type_t ring) continue; pm->pm_pcpu_state[cpu].pps_stalled = 0; - (*pcd->pcd_start_pmc)(cpu, adjri); + (*pcd->pcd_start_pmc)(cpu, adjri, pm); } } @@ -5162,11 +5164,11 @@ pmc_process_exit(void *arg __unused, struct proc *p) if (pm->pm_pcpu_state[cpu].pps_cpustate) { pm->pm_pcpu_state[cpu].pps_cpustate = 0; if (!pm->pm_pcpu_state[cpu].pps_stalled) { - (void) pcd->pcd_stop_pmc(cpu, adjri); + (void) pcd->pcd_stop_pmc(cpu, adjri, pm); if (PMC_TO_MODE(pm) == PMC_MODE_TC) { pcd->pcd_read_pmc(cpu, adjri, - &newvalue); + pm, &newvalue); tmp = newvalue - PMC_PCPU_SAVED(cpu,ri); diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c index 4c2a9cf84ef4..e8f6f536e471 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -262,19 +262,17 @@ powerpc_release_pmc(int cpu, int ri, struct pmc *pmc) } int -powerpc_start_pmc(int cpu, int ri) +powerpc_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc *pm; PMCDBG2(MDP,STA,1,"powerpc-start cpu=%d ri=%d", cpu, ri); - pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc; powerpc_set_pmc(cpu, ri, pm->pm_md.pm_powerpc.pm_powerpc_evsel); return (0); } int -powerpc_stop_pmc(int cpu, int ri) +powerpc_stop_pmc(int cpu, int ri, struct pmc *pm __unused) { PMCDBG2(MDP,STO,1, "powerpc-stop cpu=%d ri=%d", cpu, ri); powerpc_set_pmc(cpu, ri, PMCN_NONE); @@ -377,9 +375,8 @@ powerpc_pmcn_write_default(unsigned int pmc, uint32_t val) } int -powerpc_read_pmc(int cpu, int ri, pmc_value_t *v) +powerpc_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v) { - struct pmc *pm; pmc_value_t p, r, tmp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -387,11 +384,6 @@ powerpc_read_pmc(int cpu, int ri, pmc_value_t *v) KASSERT(ri >= 0 && ri < ppc_max_pmcs, ("[powerpc,%d] illegal row index %d", __LINE__, ri)); - pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc; - KASSERT(pm, - ("[core,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, - ri)); - /* * After an interrupt occurs because of a PMC overflow, the PMC value * is not always MAX_PMC_VALUE + 1, but may be a little above it. @@ -430,9 +422,8 @@ powerpc_read_pmc(int cpu, int ri, pmc_value_t *v) } int -powerpc_write_pmc(int cpu, int ri, pmc_value_t v) +powerpc_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v) { - struct pmc *pm; pmc_value_t vlo; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -440,8 +431,6 @@ powerpc_write_pmc(int cpu, int ri, pmc_value_t v) KASSERT(ri >= 0 && ri < ppc_max_pmcs, ("[powerpc,%d] illegal row-index %d", __LINE__, ri)); - pm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc; - if (PMC_IS_COUNTING_MODE(PMC_TO_MODE(pm))) { PPC_OVERFLOWCNT(pm) = v / (POWERPC_MAX_PMC_VALUE + 1); vlo = v % (POWERPC_MAX_PMC_VALUE + 1); @@ -496,7 +485,7 @@ powerpc_pmc_intr(struct trapframe *tf) if ((pm = pc->pc_ppcpmcs[i].phw_pmc) != NULL && PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) { if (pm->pm_state != PMC_STATE_RUNNING) { - powerpc_write_pmc(cpu, i, + powerpc_write_pmc(cpu, i, pm, pm->pm_sc.pm_reloadcount); continue; } @@ -518,11 +507,11 @@ powerpc_pmc_intr(struct trapframe *tf) PMCDBG3(MDP,INT,3, "cpu=%d ri=%d: error %d processing interrupt", cpu, i, error); - powerpc_stop_pmc(cpu, i); + powerpc_stop_pmc(cpu, i, pm); } /* Reload sampling count */ - powerpc_write_pmc(cpu, i, pm->pm_sc.pm_reloadcount); + powerpc_write_pmc(cpu, i, pm, pm->pm_sc.pm_reloadcount); } if (retval) diff --git a/sys/dev/hwpmc/hwpmc_powerpc.h b/sys/dev/hwpmc/hwpmc_powerpc.h index 25b041327b84..efd7aca1b9ef 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.h +++ b/sys/dev/hwpmc/hwpmc_powerpc.h @@ -101,13 +101,13 @@ int powerpc_pcpu_fini(struct pmc_mdep *md, int cpu); int powerpc_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a); int powerpc_release_pmc(int cpu, int ri, struct pmc *pmc); -int powerpc_start_pmc(int cpu, int ri); -int powerpc_stop_pmc(int cpu, int ri); +int powerpc_start_pmc(int cpu, int ri, struct pmc *pm); +int powerpc_stop_pmc(int cpu, int ri, struct pmc *pm); int powerpc_config_pmc(int cpu, int ri, struct pmc *pm); pmc_value_t powerpc_pmcn_read_default(unsigned int pmc); void powerpc_pmcn_write_default(unsigned int pmc, uint32_t val); -int powerpc_read_pmc(int cpu, int ri, pmc_value_t *v); -int powerpc_write_pmc(int cpu, int ri, pmc_value_t v); +int powerpc_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v); +int powerpc_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v); int powerpc_pmc_intr(struct trapframe *tf); #endif /* _KERNEL */ diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c index f3a6ffc70677..30d8e5013972 100644 --- a/sys/dev/hwpmc/hwpmc_soft.c +++ b/sys/dev/hwpmc/hwpmc_soft.c @@ -257,22 +257,14 @@ soft_pcpu_init(struct pmc_mdep *md, int cpu) } static int -soft_read_pmc(int cpu, int ri, pmc_value_t *v) +soft_read_pmc(int cpu, int ri, struct pmc *pm __unused, pmc_value_t *v) { - struct pmc *pm __diagused; - const struct pmc_hw *phw; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[soft,%d] illegal CPU value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < SOFT_NPMCS, ("[soft,%d] illegal row-index %d", __LINE__, ri)); - phw = &soft_pcpu[cpu]->soft_hw[ri]; - pm = phw->phw_pmc; - - KASSERT(pm != NULL, - ("[soft,%d] no owner for PHW [cpu%d,pmc%d]", __LINE__, cpu, ri)); - PMCDBG1(MDP,REA,1,"soft-read id=%d", ri); *v = soft_pcpu[cpu]->soft_values[ri]; @@ -281,20 +273,13 @@ soft_read_pmc(int cpu, int ri, pmc_value_t *v) } static int -soft_write_pmc(int cpu, int ri, pmc_value_t v) +soft_write_pmc(int cpu, int ri, struct pmc *pm __unused, pmc_value_t v) { - struct pmc *pm __diagused; - KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[soft,%d] illegal cpu value %d", __LINE__, cpu)); KASSERT(ri >= 0 && ri < SOFT_NPMCS, ("[soft,%d] illegal row-index %d", __LINE__, ri)); - pm = soft_pcpu[cpu]->soft_hw[ri].phw_pmc; - - KASSERT(pm, - ("[soft,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri)); - PMCDBG3(MDP,WRI,1, "soft-write cpu=%d ri=%d v=%jx", cpu, ri, v); soft_pcpu[cpu]->soft_values[ri] = v; @@ -335,10 +320,8 @@ soft_release_pmc(int cpu, int ri, struct pmc *pmc) } static int -soft_start_pmc(int cpu, int ri) +soft_start_pmc(int cpu, int ri, struct pmc *pm) { - struct pmc *pm; - struct soft_cpu *pc; struct pmc_soft *ps; *** 318 LINES SKIPPED ***