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
This commit is contained in:
Mitchell Horne 2023-05-05 19:00:02 -03:00
parent a35453b9c7
commit 39f92a76a9
14 changed files with 94 additions and 334 deletions

View File

@ -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));

View File

@ -211,10 +211,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;
@ -223,8 +222,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.
*/
@ -260,17 +257,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);
@ -306,14 +300,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;
/*
@ -334,7 +324,7 @@ 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)
{
/*
* Disable the PMCs.
@ -404,10 +394,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);

View File

@ -160,10 +160,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;
@ -172,8 +171,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);
@ -212,17 +209,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);
@ -261,14 +255,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;
/*
@ -290,14 +280,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;
@ -372,10 +358,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);

View File

@ -141,11 +141,10 @@ cmn600_pmu_writecntr(void *arg, u_int nodeid, u_int xpcntr, u_int dtccntr,
* read a pmc register
*/
static int
cmn600_read_pmc(int cpu, int ri, pmc_value_t *v)
cmn600_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v)
{
int counter, local_counter, nodeid;
struct cmn600_descr *desc;
struct pmc *pm;
void *arg;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -155,15 +154,10 @@ cmn600_read_pmc(int cpu, int ri, pmc_value_t *v)
counter = ri % CMN600_COUNTERS_N;
desc = cmn600desc(ri);
pm = desc->pd_phw->phw_pmc;
arg = desc->pd_rw_arg;
nodeid = pm->pm_md.pm_cmn600.pm_cmn600_nodeid;
local_counter = pm->pm_md.pm_cmn600.pm_cmn600_local_counter;
KASSERT(pm != NULL,
("[cmn600,%d] No owner for HWPMC [cpu%d,pmc%d]", __LINE__,
cpu, ri));
*v = cmn600_pmu_readcntr(arg, nodeid, local_counter, counter, 4);
PMCDBG3(MDP, REA, 2, "%s id=%d -> %jd", __func__, ri, *v);
@ -174,11 +168,10 @@ cmn600_read_pmc(int cpu, int ri, pmc_value_t *v)
* Write a pmc register.
*/
static int
cmn600_write_pmc(int cpu, int ri, pmc_value_t v)
cmn600_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v)
{
int counter, local_counter, nodeid;
struct cmn600_descr *desc;
struct pmc *pm;
void *arg;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -188,7 +181,6 @@ cmn600_write_pmc(int cpu, int ri, pmc_value_t v)
counter = ri % CMN600_COUNTERS_N;
desc = cmn600desc(ri);
pm = desc->pd_phw->phw_pmc;
arg = desc->pd_rw_arg;
nodeid = pm->pm_md.pm_cmn600.pm_cmn600_nodeid;
local_counter = pm->pm_md.pm_cmn600.pm_cmn600_local_counter;
@ -424,13 +416,11 @@ cmn600_encode_source(int node_type, int counter, int port, int sub)
*/
static int
cmn600_start_pmc(int cpu, int ri)
cmn600_start_pmc(int cpu, int ri, struct pmc *pm)
{
int counter, local_counter, node_type, shift;
uint64_t config, occupancy, source, xp_pmucfg;
struct cmn600_descr *desc;
struct pmc_hw *phw;
struct pmc *pm;
uint8_t event, port, sub;
uint16_t nodeid;
void *arg;
@ -442,14 +432,8 @@ cmn600_start_pmc(int cpu, int ri)
counter = ri % CMN600_COUNTERS_N;
desc = cmn600desc(ri);
phw = desc->pd_phw;
pm = phw->phw_pmc;
arg = desc->pd_rw_arg;
KASSERT(pm != NULL,
("[cmn600,%d] starting cpu%d,pmc%d with null pmc record", __LINE__,
cpu, ri));
PMCDBG3(MDP, STA, 1, "%s cpu=%d ri=%d", __func__, cpu, ri);
config = pm->pm_md.pm_cmn600.pm_cmn600_config;
@ -541,11 +525,9 @@ cmn600_start_pmc(int cpu, int ri)
*/
static int
cmn600_stop_pmc(int cpu, int ri)
cmn600_stop_pmc(int cpu, int ri, struct pmc *pm)
{
struct cmn600_descr *desc;
struct pmc_hw *phw;
struct pmc *pm;
int local_counter;
uint64_t val;
@ -555,12 +537,6 @@ cmn600_stop_pmc(int cpu, int ri)
ri));
desc = cmn600desc(ri);
phw = desc->pd_phw;
pm = phw->phw_pmc;
KASSERT(pm != NULL,
("[cmn600,%d] cpu%d,pmc%d no PMC to stop", __LINE__,
cpu, ri));
PMCDBG2(MDP, STO, 1, "%s ri=%d", __func__, ri);
@ -696,10 +672,10 @@ cmn600_pmu_intr(struct trapframe *tf, int unit, int i)
error = pmc_process_interrupt(PMC_HR, pm, tf);
if (error)
cmn600_stop_pmc(cpu, ri);
cmn600_stop_pmc(cpu, ri, pm);
/* Reload sampling count */
cmn600_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount);
cmn600_write_pmc(cpu, ri, pm, pm->pm_sc.pm_reloadcount);
return (0);
}

View File

@ -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);

View File

@ -192,10 +192,10 @@ class_ri2unit(int class, int ri)
* read a pmc register
*/
CLASSDEP_FN3(dmc620_read_pmc, int, cpu, int, ri, pmc_value_t *, v)
CLASSDEP_FN4(dmc620_read_pmc, int, cpu, int, ri, struct pmc *, pm,
pmc_value_t *, v)
{
struct dmc620_descr *desc;
struct pmc *pm;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[dmc620,%d] illegal CPU value %d", __LINE__, cpu));
@ -203,11 +203,6 @@ CLASSDEP_FN3(dmc620_read_pmc, int, cpu, int, ri, pmc_value_t *, v)
ri));
desc = dmc620desc(class, cpu, ri);
pm = desc->pd_phw->phw_pmc;
KASSERT(pm != NULL,
("[dmc620,%d] No owner for HWPMC [cpu%d,pmc%d]", __LINE__,
cpu, ri));
PMCDBG3(MDP,REA,1,"%s id=%d class=%d", __func__, ri, class);
@ -229,10 +224,10 @@ CLASSDEP_FN3(dmc620_read_pmc, int, cpu, int, ri, pmc_value_t *, v)
* Write a pmc register.
*/
CLASSDEP_FN3(dmc620_write_pmc, int, cpu, int, ri, pmc_value_t, v)
CLASSDEP_FN4(dmc620_write_pmc, int, cpu, int, ri, struct pmc *, pm,
pmc_value_t, v)
{
struct dmc620_descr *desc;
struct pmc *pm __diagused;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[dmc620,%d] illegal CPU value %d", __LINE__, cpu));
@ -240,11 +235,6 @@ CLASSDEP_FN3(dmc620_write_pmc, int, cpu, int, ri, pmc_value_t, v)
ri));
desc = dmc620desc(class, cpu, ri);
pm = desc->pd_phw->phw_pmc;
KASSERT(pm != NULL,
("[dmc620,%d] PMC not owned (cpu%d,pmc%d)", __LINE__,
cpu, ri));
PMCDBG4(MDP, WRI, 1, "%s cpu=%d ri=%d v=%jx", __func__, cpu, ri, v);
@ -374,12 +364,10 @@ CLASSDEP_FN3(dmc620_release_pmc, int, cpu, int, ri, struct pmc *, pmc)
* start a PMC.
*/
CLASSDEP_FN2(dmc620_start_pmc, int, cpu, int, ri)
CLASSDEP_FN3(dmc620_start_pmc, int, cpu, int, ri, struct pmc *, pm)
{
struct dmc620_descr *desc;
struct pmc_hw *phw;
uint64_t control;
struct pmc *pm;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[dmc620,%d] illegal CPU value %d", __LINE__, cpu));
@ -387,12 +375,6 @@ CLASSDEP_FN2(dmc620_start_pmc, int, cpu, int, ri)
ri));
desc = dmc620desc(class, cpu, ri);
phw = desc->pd_phw;
pm = phw->phw_pmc;
KASSERT(pm != NULL,
("[dmc620,%d] starting cpu%d,pmc%d with null pmc record", __LINE__,
cpu, ri));
PMCDBG3(MDP, STA, 1, "%s cpu=%d ri=%d", __func__, cpu, ri);
@ -418,11 +400,9 @@ CLASSDEP_FN2(dmc620_start_pmc, int, cpu, int, ri)
* Stop a PMC.
*/
CLASSDEP_FN2(dmc620_stop_pmc, int, cpu, int, ri)
CLASSDEP_FN3(dmc620_stop_pmc, int, cpu, int, ri, struct pmc *, pm)
{
struct dmc620_descr *desc;
struct pmc_hw *phw;
struct pmc *pm;
uint64_t control;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -431,12 +411,6 @@ CLASSDEP_FN2(dmc620_stop_pmc, int, cpu, int, ri)
ri));
desc = dmc620desc(class, cpu, ri);
phw = desc->pd_phw;
pm = phw->phw_pmc;
KASSERT(pm != NULL,
("[dmc620,%d] cpu%d,pmc%d no PMC to stop", __LINE__,
cpu, ri));
PMCDBG2(MDP, STO, 1, "%s ri=%d", __func__, ri);
@ -564,10 +538,10 @@ dmc620_intr(struct trapframe *tf, int class, int unit, int i)
error = pmc_process_interrupt(PMC_HR, pm, tf);
if (error)
dmc620_stop_pmc(class, cpu, ri);
dmc620_stop_pmc(class, cpu, ri, pm);
/* Reload sampling count */
dmc620_write_pmc(class, cpu, ri, pm->pm_sc.pm_reloadcount);
dmc620_write_pmc(class, cpu, ri, pm, pm->pm_sc.pm_reloadcount);
return (0);
}

View File

@ -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);

View File

@ -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);

View File

@ -248,19 +248,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);
@ -363,9 +361,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(),
@ -373,11 +370,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.
@ -416,9 +408,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(),
@ -426,8 +417,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);
@ -482,7 +471,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;
}
@ -504,11 +493,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)

View File

@ -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 */

View File

@ -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;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -346,12 +329,6 @@ soft_start_pmc(int cpu, int ri)
KASSERT(ri >= 0 && ri < SOFT_NPMCS,
("[soft,%d] illegal row-index %d", __LINE__, ri));
pc = soft_pcpu[cpu];
pm = pc->soft_hw[ri].phw_pmc;
KASSERT(pm,
("[soft,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri));
ps = pmc_soft_ev_acquire(pm->pm_event);
if (ps == NULL)
return (EINVAL);
@ -362,10 +339,8 @@ soft_start_pmc(int cpu, int ri)
}
static int
soft_stop_pmc(int cpu, int ri)
soft_stop_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc *pm;
struct soft_cpu *pc;
struct pmc_soft *ps;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -373,12 +348,6 @@ soft_stop_pmc(int cpu, int ri)
KASSERT(ri >= 0 && ri < SOFT_NPMCS,
("[soft,%d] illegal row-index %d", __LINE__, ri));
pc = soft_pcpu[cpu];
pm = pc->soft_hw[ri].phw_pmc;
KASSERT(pm,
("[soft,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri));
ps = pmc_soft_ev_acquire(pm->pm_event);
/* event unregistered ? */
if (ps != NULL) {
@ -420,7 +389,7 @@ pmc_soft_intr(struct pmckern_soft *ks)
user_mode = TRAPF_USERMODE(ks->pm_tf);
error = pmc_process_interrupt(PMC_SR, pm, ks->pm_tf);
if (error) {
soft_stop_pmc(ks->pm_cpu, ri);
soft_stop_pmc(ks->pm_cpu, ri, pm);
continue;
}

View File

@ -220,22 +220,14 @@ tsc_pcpu_init(struct pmc_mdep *md, int cpu)
}
static int
tsc_read_pmc(int cpu, int ri, pmc_value_t *v)
tsc_read_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t *v)
{
struct pmc *pm;
enum pmc_mode mode __diagused;
const struct pmc_hw *phw;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[tsc,%d] illegal CPU value %d", __LINE__, cpu));
KASSERT(ri == 0, ("[tsc,%d] illegal ri %d", __LINE__, ri));
phw = &tsc_pcpu[cpu]->tc_hw;
pm = phw->phw_pmc;
KASSERT(pm != NULL,
("[tsc,%d] no owner for PHW [cpu%d,pmc%d]", __LINE__, cpu, ri));
mode = PMC_TO_MODE(pm);
KASSERT(mode == PMC_MODE_SC,
@ -270,7 +262,7 @@ tsc_release_pmc(int cpu, int ri __diagused, struct pmc *pmc __unused)
}
static int
tsc_start_pmc(int cpu __diagused, int ri __diagused)
tsc_start_pmc(int cpu __diagused, int ri __diagused, struct pmc *pm __unused)
{
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -281,7 +273,7 @@ tsc_start_pmc(int cpu __diagused, int ri __diagused)
}
static int
tsc_stop_pmc(int cpu __diagused, int ri __diagused)
tsc_stop_pmc(int cpu __diagused, int ri __diagused, struct pmc *pm __unused)
{
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -292,7 +284,8 @@ tsc_stop_pmc(int cpu __diagused, int ri __diagused)
}
static int
tsc_write_pmc(int cpu __diagused, int ri __diagused, pmc_value_t v __unused)
tsc_write_pmc(int cpu __diagused, int ri __diagused, struct pmc *pm __unused,
pmc_value_t v __unused)
{
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),

View File

@ -260,9 +260,8 @@ ucf_get_config(int cpu, int ri, struct pmc **ppm)
}
static int
ucf_read_pmc(int cpu, int ri, pmc_value_t *v)
ucf_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(),
@ -270,12 +269,6 @@ ucf_read_pmc(int cpu, int ri, pmc_value_t *v)
KASSERT(ri >= 0 && ri < uncore_ucf_npmc,
("[uncore,%d] illegal row-index %d", __LINE__, ri));
pm = uncore_pcpu[cpu]->pc_uncorepmcs[ri + uncore_ucf_ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] cpu %d ri %d(%d) pmc not configured", __LINE__, cpu,
ri, ri + uncore_ucf_ri));
tmp = rdmsr(UCF_CTR0 + ri);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
@ -305,9 +298,8 @@ ucf_release_pmc(int cpu, int ri, struct pmc *pmc)
}
static int
ucf_start_pmc(int cpu, int ri)
ucf_start_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc *pm;
struct uncore_cpu *ucfc;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@ -318,8 +310,6 @@ ucf_start_pmc(int cpu, int ri)
PMCDBG2(MDP,STA,1,"ucf-start cpu=%d ri=%d", cpu, ri);
ucfc = uncore_pcpu[cpu];
pm = ucfc->pc_uncorepmcs[ri + uncore_ucf_ri].phw_pmc;
ucfc->pc_ucfctrl |= pm->pm_md.pm_ucf.pm_ucf_ctrl;
wrmsr(UCF_CTRL, ucfc->pc_ucfctrl);
@ -335,7 +325,7 @@ ucf_start_pmc(int cpu, int ri)
}
static int
ucf_stop_pmc(int cpu, int ri)
ucf_stop_pmc(int cpu, int ri, struct pmc *pm __unused)
{
uint32_t fc;
struct uncore_cpu *ucfc;
@ -366,10 +356,9 @@ ucf_stop_pmc(int cpu, int ri)
}
static int
ucf_write_pmc(int cpu, int ri, pmc_value_t v)
ucf_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v)
{
struct uncore_cpu *cc;
struct pmc *pm;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] illegal cpu value %d", __LINE__, cpu));
@ -377,10 +366,6 @@ ucf_write_pmc(int cpu, int ri, pmc_value_t v)
("[uncore,%d] illegal row-index %d", __LINE__, ri));
cc = uncore_pcpu[cpu];
pm = cc->pc_uncorepmcs[ri + uncore_ucf_ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri));
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = ucf_reload_count_to_perfctr_value(v);
@ -581,9 +566,8 @@ ucp_get_config(int cpu, int ri, struct pmc **ppm)
}
static int
ucp_read_pmc(int cpu, int ri, pmc_value_t *v)
ucp_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(),
@ -591,12 +575,6 @@ ucp_read_pmc(int cpu, int ri, pmc_value_t *v)
KASSERT(ri >= 0 && ri < uncore_ucp_npmc,
("[uncore,%d] illegal row-index %d", __LINE__, ri));
pm = uncore_pcpu[cpu]->pc_uncorepmcs[ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] cpu %d ri %d pmc not configured", __LINE__, cpu,
ri));
tmp = rdmsr(UCP_PMC0 + ri);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = ucp_perfctr_value_to_reload_count(tmp);
@ -629,9 +607,8 @@ ucp_release_pmc(int cpu, int ri, struct pmc *pm)
}
static int
ucp_start_pmc(int cpu, int ri)
ucp_start_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc *pm;
uint64_t evsel;
struct uncore_cpu *cc;
@ -641,11 +618,6 @@ ucp_start_pmc(int cpu, int ri)
("[uncore,%d] illegal row-index %d", __LINE__, ri));
cc = uncore_pcpu[cpu];
pm = cc->pc_uncorepmcs[ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] starting cpu%d,ri%d with no pmc configured",
__LINE__, cpu, ri));
PMCDBG2(MDP,STA,1, "ucp-start cpu=%d ri=%d", cpu, ri);
@ -664,23 +636,14 @@ ucp_start_pmc(int cpu, int ri)
}
static int
ucp_stop_pmc(int cpu, int ri)
ucp_stop_pmc(int cpu, int ri, struct pmc *pm __unused)
{
struct pmc *pm __diagused;
struct uncore_cpu *cc;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] illegal cpu value %d", __LINE__, cpu));
KASSERT(ri >= 0 && ri < uncore_ucp_npmc,
("[uncore,%d] illegal row index %d", __LINE__, ri));
cc = uncore_pcpu[cpu];
pm = cc->pc_uncorepmcs[ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
PMCDBG2(MDP,STO,1, "ucp-stop cpu=%d ri=%d", cpu, ri);
/* stop hw. */
@ -692,23 +655,14 @@ ucp_stop_pmc(int cpu, int ri)
}
static int
ucp_write_pmc(int cpu, int ri, pmc_value_t v)
ucp_write_pmc(int cpu, int ri, struct pmc *pm, pmc_value_t v)
{
struct pmc *pm;
struct uncore_cpu *cc;
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] illegal cpu value %d", __LINE__, cpu));
KASSERT(ri >= 0 && ri < uncore_ucp_npmc,
("[uncore,%d] illegal row index %d", __LINE__, ri));
cc = uncore_pcpu[cpu];
pm = cc->pc_uncorepmcs[ri].phw_pmc;
KASSERT(pm,
("[uncore,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
PMCDBG4(MDP,WRI,1, "ucp-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
UCP_PMC0 + ri, v);

View File

@ -62,7 +62,7 @@
* The patch version is incremented for every bug fix.
*/
#define PMC_VERSION_MAJOR 0x09
#define PMC_VERSION_MINOR 0x03
#define PMC_VERSION_MINOR 0x04
#define PMC_VERSION_PATCH 0x0000
#define PMC_VERSION (PMC_VERSION_MAJOR << 24 | \
@ -1004,8 +1004,10 @@ struct pmc_classdep {
/* configuring/reading/writing the hardware PMCs */
int (*pcd_config_pmc)(int _cpu, int _ri, struct pmc *_pm);
int (*pcd_get_config)(int _cpu, int _ri, struct pmc **_ppm);
int (*pcd_read_pmc)(int _cpu, int _ri, pmc_value_t *_value);
int (*pcd_write_pmc)(int _cpu, int _ri, pmc_value_t _value);
int (*pcd_read_pmc)(int _cpu, int _ri, struct pmc *_pm,
pmc_value_t *_value);
int (*pcd_write_pmc)(int _cpu, int _ri, struct pmc *_pm,
pmc_value_t _value);
/* pmc allocation/release */
int (*pcd_allocate_pmc)(int _cpu, int _ri, struct pmc *_t,
@ -1013,8 +1015,8 @@ struct pmc_classdep {
int (*pcd_release_pmc)(int _cpu, int _ri, struct pmc *_pm);
/* starting and stopping PMCs */
int (*pcd_start_pmc)(int _cpu, int _ri);
int (*pcd_stop_pmc)(int _cpu, int _ri);
int (*pcd_start_pmc)(int _cpu, int _ri, struct pmc *_pm);
int (*pcd_stop_pmc)(int _cpu, int _ri, struct pmc *_pm);
/* description */
int (*pcd_describe)(int _cpu, int _ri, struct pmc_info *_pi,