summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2005-12-26 16:10:00 +0000
committerjkoshy <jkoshy@FreeBSD.org>2005-12-26 16:10:00 +0000
commit9bad87d165e389f150bd970c5b1b26617c537e27 (patch)
treead165faebde479f21341b77abff158b8fe077251 /sys
parent758de8f2efcb402b1ed9c06b1b55fcd56ee71339 (diff)
downloadFreeBSD-src-9bad87d165e389f150bd970c5b1b26617c537e27.zip
FreeBSD-src-9bad87d165e389f150bd970c5b1b26617c537e27.tar.gz
- Plug a memory leak: free up per-cpu sample buffers at module unload time.
- Correct a few style nits.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 85b5fa0..97af35d 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -3954,7 +3954,8 @@ pmc_initialize(void)
}
if (pmc_nsamples <= 0 || pmc_nsamples > 65535) {
- (void) printf("hwpmc: tunable nsamples=%d out of range.\n", pmc_nsamples);
+ (void) printf("hwpmc: tunable nsamples=%d out of range.\n",
+ pmc_nsamples);
pmc_nsamples = PMC_NSAMPLES;
}
@@ -3995,8 +3996,7 @@ pmc_initialize(void)
M_WAITOK|M_ZERO);
sb->ps_read = sb->ps_write = sb->ps_samples;
- sb->ps_fence = sb->ps_samples + pmc_nsamples
-;
+ sb->ps_fence = sb->ps_samples + pmc_nsamples;
KASSERT(pmc_pcpu[cpu] != NULL,
("[pmc,%d] cpu=%d Null per-cpu data", __LINE__, cpu));
@@ -4147,6 +4147,17 @@ pmc_cleanup(void)
KASSERT(pmc_ss_count == 0,
("[pmc,%d] Global SS count not empty", __LINE__));
+ /* free the per-cpu sample buffers */
+ for (cpu = 0; cpu < mp_ncpus; cpu++) {
+ if (pmc_cpu_is_disabled(cpu))
+ continue;
+ KASSERT(pmc_pcpu[cpu]->pc_sb != NULL,
+ ("[pmc,%d] Null cpu sample buffer cpu=%d", __LINE__,
+ cpu));
+ FREE(pmc_pcpu[cpu]->pc_sb, M_PMC);
+ pmc_pcpu[cpu]->pc_sb = NULL;
+ }
+
/* do processor dependent cleanup */
PMCDBG(MOD,INI,3, "%s", "md cleanup");
if (md) {
OpenPOWER on IntegriCloud