These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / tools / lib / api / cpu.c
diff --git a/kernel/tools/lib/api/cpu.c b/kernel/tools/lib/api/cpu.c
new file mode 100644 (file)
index 0000000..8c64893
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+#include "cpu.h"
+#include "fs/fs.h"
+
+int cpu__get_max_freq(unsigned long long *freq)
+{
+       char entry[PATH_MAX];
+       int cpu;
+
+       if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
+               return -1;
+
+       snprintf(entry, sizeof(entry),
+                "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
+
+       return sysfs__read_ull(entry, freq);
+}