1 // Copyright 2017 The Fuchsia Authors 2 // 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file or at 5 // https://opensource.org/licenses/MIT 6 #pragma once 7 8 #include <sys/types.h> 9 #include <zircon/compiler.h> 10 #include <zircon/types.h> 11 12 __BEGIN_CDECLS 13 14 // per cpu kernel level statistics 15 struct cpu_stats { 16 zx_duration_t idle_time; 17 ulong reschedules; 18 ulong context_switches; 19 ulong irq_preempts; 20 ulong preempts; 21 ulong yields; 22 23 // cpu level interrupts and exceptions 24 ulong interrupts; // hardware interrupts, minus timer interrupts or inter-processor interrupts 25 ulong timer_ints; // timer interrupts 26 ulong timers; // timer callbacks 27 ulong perf_ints; // performance monitor interrupts 28 ulong syscalls; 29 ulong page_faults; 30 31 // inter-processor interrupts 32 ulong reschedule_ipis; 33 ulong generic_ipis; 34 }; 35 36 __END_CDECLS 37 38 // include after the cpu_stats definition above, since it is part of the percpu structure 39 #include <kernel/percpu.h> 40 41 #define CPU_STATS_INC(name) \ 42 do { \ 43 __atomic_fetch_add(&get_local_percpu()->stats.name, 1u, __ATOMIC_RELAXED); \ 44 } while (0) 45