FreeBSD/sys/dev/hwpmc/hwpmc_mod.c
/*
 * Check if a given PMC at row index 'ri' can be currently used in
 * mode 'mode'.
 */
Check if a given PMC at row index 'ri' can be currently used in
mode 'mode'.
Check if a given PMC at row index ' ri ' can be currently used in mode ' mode ' .
static int
pmc_can_allocate_row(int ri, enum pmc_mode mode)
{
	enum pmc_disp	disp;
	sx_assert(&pmc_sx, SX_XLOCKED);
	PMCDBG2(PMC,ALR,1, "can-allocate-row ri=%d mode=%d", ri, mode);
	if (PMC_IS_SYSTEM_MODE(mode))
		disp = PMC_DISP_STANDALONE;
	else
		disp = PMC_DISP_THREAD;
	if (!PMC_ROW_DISP_IS_FREE(ri) &&
	    !(disp == PMC_DISP_THREAD && PMC_ROW_DISP_IS_THREAD(ri)) &&
	    !(disp == PMC_DISP_STANDALONE && PMC_ROW_DISP_IS_STANDALONE(ri)))
		return EBUSY;
	PMCDBG2(PMC,ALR,2, "can-allocate-row ri=%d mode=%d ok", ri, mode);
	return 0;
}
static int pmc_can_allocate_row ( int ri , enum pmc_mode mode ) { enum pmc_disp disp ; sx_assert ( & pmc_sx , SX_XLOCKED ) ; PMCDBG2 ( PMC , ALR , 1 , " " , ri , mode ) ; if ( PMC_IS_SYSTEM_MODE ( mode ) ) disp = PMC_DISP_STANDALONE ; else disp = PMC_DISP_THREAD ; if ( ! PMC_ROW_DISP_IS_FREE ( ri ) && ! ( disp == PMC_DISP_THREAD && PMC_ROW_DISP_IS_THREAD ( ri ) ) && ! ( disp == PMC_DISP_STANDALONE && PMC_ROW_DISP_IS_STANDALONE ( ri ) ) ) return EBUSY ; PMCDBG2 ( PMC , ALR , 2 , " " , ri , mode ) ; return 0 ; }
Check if a given PMC at row index 'ri' can be currently used in
 mode 'mode'.
Check if a given PMC at row index ' ri ' can be currently used in mode ' mode ' .
/*
	 * check disposition for PMC row 'ri':
	 *
	 * Expected disposition		Row-disposition		Result
	 *
	 * STANDALONE			STANDALONE or FREE	proceed
	 * STANDALONE			THREAD			fail
	 * THREAD			THREAD or FREE		proceed
	 * THREAD			STANDALONE		fail
	 */ /*
	 * All OK
	 */