git: 47699fc265b9 - main - hwpmc: Make powerpc memory allocation alike to x86.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 01 Jun 2022 18:53:14 UTC
The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=47699fc265b9d966b4eba6bc0c41739ac793f52b commit 47699fc265b9d966b4eba6bc0c41739ac793f52b Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2022-06-01 18:50:27 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2022-06-01 18:53:04 +0000 hwpmc: Make powerpc memory allocation alike to x86. It should remove some unneeded pointer dereferences. MFC after: 1 month --- sys/dev/hwpmc/hwpmc_powerpc.c | 8 +++----- sys/dev/hwpmc/hwpmc_powerpc.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_powerpc.c b/sys/dev/hwpmc/hwpmc_powerpc.c index 8302cfd84992..86ec71f14e80 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.c +++ b/sys/dev/hwpmc/hwpmc_powerpc.c @@ -167,10 +167,8 @@ powerpc_pcpu_init(struct pmc_mdep *md, int cpu) ("[powerpc,%d] wrong cpu number %d", __LINE__, cpu)); PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu); - powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC, - M_WAITOK|M_ZERO); - pac->pc_ppcpmcs = malloc(sizeof(struct pmc_hw) * ppc_max_pmcs, - M_PMC, M_WAITOK|M_ZERO); + powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu) + + ppc_max_pmcs * sizeof(struct pmc_hw), M_PMC, M_WAITOK | M_ZERO); pac->pc_class = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_POWERPC].pcd_class; @@ -193,8 +191,8 @@ powerpc_pcpu_fini(struct pmc_mdep *md, int cpu) { PMCDBG1(MDP,INI,1,"powerpc-fini cpu=%d", cpu); - free(powerpc_pcpu[cpu]->pc_ppcpmcs, M_PMC); free(powerpc_pcpu[cpu], M_PMC); + powerpc_pcpu[cpu] = NULL; return (0); } diff --git a/sys/dev/hwpmc/hwpmc_powerpc.h b/sys/dev/hwpmc/hwpmc_powerpc.h index 10aa0ad75b14..25b041327b84 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.h +++ b/sys/dev/hwpmc/hwpmc_powerpc.h @@ -58,8 +58,8 @@ #define PPC_OVERFLOWCNT_MAX 0x200000000UL struct powerpc_cpu { - struct pmc_hw *pc_ppcpmcs; - enum pmc_class pc_class; + enum pmc_class pc_class; + struct pmc_hw pc_ppcpmcs[]; }; struct pmc_ppc_event {