ARM: fix performance counters allocation

Change-Id: Ie6c8beacf268462064f59b063d9c7b635c906dc4
This commit is contained in:
Balazs Gerofi
2019-06-05 14:00:12 +09:00
parent 99fba2df1c
commit bc4629dfb0
7 changed files with 49 additions and 22 deletions

View File

@ -8,6 +8,7 @@
#define SYSCALL_HANDLED(number, name) DECLARATOR(number, name)
#define SYSCALL_DELEGATED(number, name) DECLARATOR(number, name)
#include <config.h>
#include <syscall_list.h>
#undef DECLARATOR

View File

@ -111,7 +111,7 @@ SYSCALL_HANDLED(236, get_mempolicy)
SYSCALL_HANDLED(237, set_mempolicy)
SYSCALL_HANDLED(238, migrate_pages)
SYSCALL_HANDLED(239, move_pages)
#ifdef PERF_ENABLE
#ifdef ENABLE_PERF
SYSCALL_HANDLED(241, perf_event_open)
#else // PERF_ENABLE
SYSCALL_DELEGATED(241, perf_event_open)

View File

@ -8,6 +8,7 @@
#include <string.h>
#include <ihk/mm.h>
#include <irq.h>
#include <process.h>
/*
* @ref.impl arch/arm64/kernel/perf_event.c
@ -198,6 +199,27 @@ int ihk_mc_perfctr_read_mask(unsigned long counter_mask, unsigned long *value)
return 0;
}
int ihk_mc_perfctr_alloc(struct thread *thread, int cpu_cycles)
{
int ret = -EINVAL;
int i = 1;
const int counters = ihk_mc_perf_get_num_counters();
// Counter 0 is only used for CPU cycles on ARM
if (cpu_cycles) {
i = 0;
}
for (; i < counters; i++) {
if (!(thread->pmc_alloc_map & (1 << i))) {
ret = i;
break;
}
}
return ret;
}
unsigned long ihk_mc_perfctr_read(int counter)
{
unsigned long count;

View File

@ -17,6 +17,7 @@
#include <mc_perf_event.h>
#include <config.h>
#include <ihk/debug.h>
#include <process.h>
extern unsigned int *x86_march_perfmap;
extern int running_on_kvm(void);
@ -411,6 +412,23 @@ int ihk_mc_perfctr_read_mask(unsigned long counter_mask, unsigned long *value)
return 0;
}
int ihk_mc_perfctr_alloc(struct thread *thread, int cpu_cycles)
{
int ret = -EINVAL;
int i = 0;
const int counters = ihk_mc_perf_get_num_counters();
// find avail generic counter
for (i = 0; i < counters; i++) {
if (!(thread->pmc_alloc_map & (1 << i))) {
ret = i;
break;
}
}
return ret;
}
unsigned long ihk_mc_perfctr_read(int counter)
{
unsigned long retval = 0;