[v1.05] Add support for frequency measurement in ARM (had to move bind_to_cpu to common dir)

This commit is contained in:
Dr-Noob
2024-02-16 23:37:37 +01:00
parent 72eee0e08e
commit d71a461d83
10 changed files with 114 additions and 54 deletions

View File

@@ -2,11 +2,6 @@
#define _GNU_SOURCE
// TODO: This should be under common/
#include "../x86/apic.h"
#include "../x86/freq/freq.h"
#include "global.h"
#include <time.h>
#include <stdio.h>
#include <stdint.h>
@@ -17,6 +12,14 @@
#include <sys/ioctl.h>
#include <linux/perf_event.h>
#ifdef ARCH_X86
#include "../x86/freq/freq.h"
#elif ARCH_ARM
#include "../arm/freq.h"
#endif
#include "global.h"
static long
perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
int cpu, int group_fd, unsigned long flags) {
@@ -36,10 +39,7 @@ perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
// - measure_frequency uses actual computation while measuring the frequency
// whereas measure_max_frequency uses nop instructions. This makes the former
// x86 dependant whereas the latter is architecture independant.
int64_t measure_max_frequency(void) {
// TODO: Support binding on all cores inside a SoC (x86
// hybrid topologies and ARM SoCs)
int core = 0;
int64_t measure_max_frequency(uint32_t core) {
if (!bind_to_cpu(core)) {
printErr("Failed binding the process to CPU %d", core);
return -1;