Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hwpmc/hwpmc_mod.c
Show First 20 Lines • Show All 5,594 Lines • ▼ Show 20 Lines | #endif | ||||
md = pmc_md_initialize(); | md = pmc_md_initialize(); | ||||
if (md == NULL) { | if (md == NULL) { | ||||
/* Default to generic CPU. */ | /* Default to generic CPU. */ | ||||
md = pmc_generic_cpu_initialize(); | md = pmc_generic_cpu_initialize(); | ||||
if (md == NULL) | if (md == NULL) | ||||
return (ENOSYS); | return (ENOSYS); | ||||
} | } | ||||
/* | |||||
* Refresh classes base ri. Optional classes may come in different | |||||
* order. | |||||
*/ | |||||
for (ri = c = 0; c < md->pmd_nclass; c++) { | |||||
pcd = &md->pmd_classdep[c]; | |||||
pcd->pcd_ri = ri; | |||||
ri += pcd->pcd_num; | |||||
} | |||||
KASSERT(md->pmd_nclass >= 1 && md->pmd_npmc >= 1, | KASSERT(md->pmd_nclass >= 1 && md->pmd_npmc >= 1, | ||||
("[pmc,%d] no classes or pmcs", __LINE__)); | ("[pmc,%d] no classes or pmcs", __LINE__)); | ||||
/* Compute the map from row-indices to classdep pointers. */ | /* Compute the map from row-indices to classdep pointers. */ | ||||
pmc_rowindex_to_classdep = malloc(sizeof(struct pmc_classdep *) * | pmc_rowindex_to_classdep = malloc(sizeof(struct pmc_classdep *) * | ||||
md->pmd_npmc, M_PMC, M_WAITOK|M_ZERO); | md->pmd_npmc, M_PMC, M_WAITOK|M_ZERO); | ||||
for (n = 0; n < md->pmd_npmc; n++) | for (n = 0; n < md->pmd_npmc; n++) | ||||
Show All 26 Lines | if (!pmc_cpu_is_active(cpu)) | ||||
continue; | continue; | ||||
pmc_select_cpu(cpu); | pmc_select_cpu(cpu); | ||||
pmc_pcpu[cpu] = malloc(sizeof(struct pmc_cpu) + | pmc_pcpu[cpu] = malloc(sizeof(struct pmc_cpu) + | ||||
md->pmd_npmc * sizeof(struct pmc_hw *), M_PMC, | md->pmd_npmc * sizeof(struct pmc_hw *), M_PMC, | ||||
M_WAITOK|M_ZERO); | M_WAITOK|M_ZERO); | ||||
if (md->pmd_pcpu_init) | if (md->pmd_pcpu_init) | ||||
error = md->pmd_pcpu_init(md, cpu); | error = md->pmd_pcpu_init(md, cpu); | ||||
for (n = 0; error == 0 && n < md->pmd_nclass; n++) | for (n = 0; error == 0 && n < md->pmd_nclass; n++) | ||||
error = md->pmd_classdep[n].pcd_pcpu_init(md, cpu); | if (md->pmd_classdep[n].pcd_num > 0) | ||||
error = md->pmd_classdep[n].pcd_pcpu_init(md, | |||||
cpu); | |||||
} | } | ||||
pmc_restore_cpu_binding(&pb); | pmc_restore_cpu_binding(&pb); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
/* allocate space for the sample array */ | /* allocate space for the sample array */ | ||||
for (cpu = 0; cpu < maxcpu; cpu++) { | for (cpu = 0; cpu < maxcpu; cpu++) { | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | #endif | ||||
/* set hook functions */ | /* set hook functions */ | ||||
pmc_intr = md->pmd_intr; | pmc_intr = md->pmd_intr; | ||||
wmb(); | wmb(); | ||||
pmc_hook = pmc_hook_handler; | pmc_hook = pmc_hook_handler; | ||||
if (error == 0) { | if (error == 0) { | ||||
printf(PMC_MODULE_NAME ":"); | printf(PMC_MODULE_NAME ":"); | ||||
for (n = 0; n < (int) md->pmd_nclass; n++) { | for (n = 0; n < (int) md->pmd_nclass; n++) { | ||||
if (md->pmd_classdep[n].pcd_num == 0) | |||||
continue; | |||||
mhorne: How can such an optional class appear in this list? It seems like it shouldn't happen, because… | |||||
Done Inline ActionsFor example, one of classes fail to initialize. It have to be present in a list, otherwise class number and array position will not match. But to not process that class we can check number of counters it add (0 here). ray: For example, one of classes fail to initialize. It have to be present in a list, otherwise… | |||||
pcd = &md->pmd_classdep[n]; | pcd = &md->pmd_classdep[n]; | ||||
printf(" %s/%d/%d/0x%b", | printf(" %s/%d/%d/0x%b", | ||||
pmc_name_of_pmcclass(pcd->pcd_class), | pmc_name_of_pmcclass(pcd->pcd_class), | ||||
pcd->pcd_num, | pcd->pcd_num, | ||||
pcd->pcd_width, | pcd->pcd_width, | ||||
pcd->pcd_caps, | pcd->pcd_caps, | ||||
"\20" | "\20" | ||||
"\1INT\2USR\3SYS\4EDG\5THR" | "\1INT\2USR\3SYS\4EDG\5THR" | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if (md) { | ||||
pmc_save_cpu_binding(&pb); | pmc_save_cpu_binding(&pb); | ||||
for (cpu = 0; cpu < maxcpu; cpu++) { | for (cpu = 0; cpu < maxcpu; cpu++) { | ||||
PMCDBG2(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p", | PMCDBG2(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p", | ||||
cpu, pmc_pcpu[cpu]); | cpu, pmc_pcpu[cpu]); | ||||
if (!pmc_cpu_is_active(cpu) || pmc_pcpu[cpu] == NULL) | if (!pmc_cpu_is_active(cpu) || pmc_pcpu[cpu] == NULL) | ||||
continue; | continue; | ||||
pmc_select_cpu(cpu); | pmc_select_cpu(cpu); | ||||
for (c = 0; c < md->pmd_nclass; c++) | for (c = 0; c < md->pmd_nclass; c++) | ||||
md->pmd_classdep[c].pcd_pcpu_fini(md, cpu); | if (md->pmd_classdep[c].pcd_num > 0) | ||||
md->pmd_classdep[c].pcd_pcpu_fini(md, | |||||
cpu); | |||||
if (md->pmd_pcpu_fini) | if (md->pmd_pcpu_fini) | ||||
md->pmd_pcpu_fini(md, cpu); | md->pmd_pcpu_fini(md, cpu); | ||||
} | } | ||||
if (md->pmd_cputype == PMC_CPU_GENERIC) | if (md->pmd_cputype == PMC_CPU_GENERIC) | ||||
pmc_generic_cpu_finalize(md); | pmc_generic_cpu_finalize(md); | ||||
else | else | ||||
pmc_md_finalize(md); | pmc_md_finalize(md); | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |
How can such an optional class appear in this list? It seems like it shouldn't happen, because you take care to call pmc_mdep_alloc() with the correct nclasses value.