Beispiel #1
0
void mv_proc_start_cntrs(int cc0, int cc1, int cc2, int cc3) {

    printk("configure CPU counters %d %d %d %d \n",cc0, cc1, cc2, cc3);
    if( mvCpuCntrsProgram(0, cc0, "cc0", 0) != MV_OK)
	goto error;
    if( mvCpuCntrsProgram(1, cc1, "cc1", 0) != MV_OK)
	goto error;
    if( mvCpuCntrsProgram(2, cc2, "cc2", 0) != MV_OK)
	goto error;
    if( mvCpuCntrsProgram(3, cc3, "cc3", 0) != MV_OK)
	goto error;

    if(proc_event == NULL) {
	proc_event = mvCpuCntrsEventCreate("PROC_CPU_CNTRS", 1);
	if(proc_event == NULL)
		goto error;
    }

    mvCpuCntrsEventClear(proc_event);

    mvCpuCntrsReset();
    MV_CPU_CNTRS_START(proc_event);
    return;

error:
    printk("ERROR configuring counter\n");
    return;
}
void mvCpuCntrsShow(MV_CPU_CNTRS_EVENT *pEvent)
{
	int			i;
	MV_U64		counters_avg;
	static int	title = 0;

	if ((title % 64) == 0) {

		mvOsPrintf("\n%16s  ", " ");
		for (i = 0; i < MV_CPU_CNTRS_NUM; i++) {
			if (mvCpuCntrsTbl[i].operation == MV_CPU_CNTRS_INVALID)
				continue;

			mvOsPrintf(" %8s, ", mvCpuCntrsTbl[i].name);
		}
		mvOsPrintf("\n");
	}

	mvOsPrintf("%16s: ", pEvent->name);
	for (i = 0; i < MV_CPU_CNTRS_NUM; i++) {
		if (mvCpuCntrsTbl[i].operation == MV_CPU_CNTRS_INVALID)
			continue;


		counters_avg = mvOsDivMod64(pEvent->counters_sum[i], pEvent->num_of_measurements, NULL);
/*		counters_avg = pEvent->counters_sum[i] / pEvent->num_of_measurements;*/
		if (counters_avg >= mvCpuCntrsTbl[i].overhead)
			counters_avg -= mvCpuCntrsTbl[i].overhead;
		else
			counters_avg = 0;
		mvOsPrintf(" %8llu, ", counters_avg);

/*
		mvOsPrintf("%s = %5llu / %u, ",
				mvCpuCntrsTbl[i].name, pEvent->counters_sum[i], pEvent->num_of_measurements);
*/
	}
	mvOsPrintf("\n");
	mvCpuCntrsEventClear(pEvent);
	mvCpuCntrsReset();

	title++;
}