FreeBSD/sys/dev/hwpmc/hwpmc_mod.c
/*
 * Register an owner and a pmc.
 */
Register an owner and a pmc.
Register an owner and a pmc .
static int
pmc_register_owner(struct proc *p, struct pmc *pmc)
{
	struct pmc_owner *po;
	sx_assert(&pmc_sx, SX_XLOCKED);
	if ((po = pmc_find_owner_descriptor(p)) == NULL)
		if ((po = pmc_allocate_owner_descriptor(p)) == NULL)
			return ENOMEM;
	KASSERT(pmc->pm_owner == NULL,
	    ("[pmc,%d] attempting to own an initialized PMC", __LINE__));
	pmc->pm_owner  = po;
	LIST_INSERT_HEAD(&po->po_pmcs, pmc, pm_next);
	PROC_LOCK(p);
	p->p_flag |= P_HWPMC;
	PROC_UNLOCK(p);
	if (po->po_flags & PMC_PO_OWNS_LOGFILE)
		pmclog_process_pmcallocate(pmc);
	PMCDBG2(PMC,REG,1, "register-owner pmc-owner=%p pmc=%p",
	    po, pmc);
	return 0;
}
static int pmc_register_owner ( struct proc * p , struct pmc * pmc ) { struct pmc_owner * po ; sx_assert ( & pmc_sx , SX_XLOCKED ) ; if ( ( po = pmc_find_owner_descriptor ( p ) ) == NULL ) if ( ( po = pmc_allocate_owner_descriptor ( p ) ) == NULL ) return ENOMEM ; KASSERT ( pmc -> pm_owner == NULL , ( " " , __LINE__ ) ) ; pmc -> pm_owner = po ; LIST_INSERT_HEAD ( & po -> po_pmcs , pmc , pm_next ) ; PROC_LOCK ( p ) ; p -> p_flag |= P_HWPMC ; PROC_UNLOCK ( p ) ; if ( po -> po_flags & PMC_PO_OWNS_LOGFILE ) pmclog_process_pmcallocate ( pmc ) ; PMCDBG2 ( PMC , REG , 1 , " " , po , pmc ) ; return 0 ; }
Register an owner and a pmc.
Register an owner and a pmc .