2#ifndef PEDIGREE_KERNEL_METRICS_H
3#define PEDIGREE_KERNEL_METRICS_H
5#include "pedigree/kernel/compiler.h"
11#if PEDIGREE_METRICS && !defined(PEDIGREE_BUILDUTILS)
12#include "pedigree/kernel/process/CpuAffinity.h"
13#include "pedigree/kernel/processor/Processor.h"
17enum Counter :
size_t {
46 PhysicalPageAllocFailure,
49 MemoryPressurePassSuccess,
60 CacheWritebackFailures,
85 uint64_t values[Count] = {};
88#if PEDIGREE_METRICS && !defined(PEDIGREE_BUILDUTILS)
89struct alignas(64) CpuCounters {
90 uint64_t values[Count];
92extern EXPORTED_PUBLIC CpuCounters counters[CpuAffinityMask::MaximumCpus];
96ALWAYS_INLINE inline void add(Counter counter, uint64_t amount) {
101 if (cpu < CpuAffinityMask::MaximumCpus) {
102 __atomic_fetch_add(&counters[cpu].values[counter], amount, __ATOMIC_RELAXED);
108EXPORTED_PUBLIC
bool snapshot(
size_t cpu, Snapshot& result);
110inline void add(Counter, uint64_t) {}
111inline void increment(Counter) {}
112inline bool snapshot(
size_t, Snapshot& result) {