| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library fuchsia.kernel; |
| |
| using zx; |
| |
| // The zx library does not include zx_info_kmem_stats_t, so this table is mirroring it. |
| // See zircon/system/public/zircon/syscalls/object.h for more details. |
| table MemoryStats { |
| 1: uint64 total_bytes; |
| 2: uint64 free_bytes; |
| 3: uint64 wired_bytes; |
| 4: uint64 total_heap_bytes; |
| 5: uint64 free_heap_bytes; |
| 6: uint64 vmo_bytes; |
| 7: uint64 mmu_overhead_bytes; |
| 8: uint64 ipc_bytes; |
| 9: uint64 other_bytes; |
| }; |
| |
| // Similarly, this table mirrors zx_info_kmem_stats_extended_t. |
| // See zircon/system/public/zircon/syscalls/object.h for more details. |
| table MemoryStatsExtended { |
| 1: uint64 total_bytes; |
| 2: uint64 free_bytes; |
| 3: uint64 wired_bytes; |
| 4: uint64 total_heap_bytes; |
| 5: uint64 free_heap_bytes; |
| 6: uint64 vmo_bytes; |
| 7: uint64 vmo_pager_total_bytes; |
| 8: uint64 vmo_pager_newest_bytes; |
| 9: uint64 vmo_pager_oldest_bytes; |
| 10: uint64 vmo_discardable_locked_bytes; |
| 11: uint64 vmo_discardable_unlocked_bytes; |
| 12: uint64 mmu_overhead_bytes; |
| 13: uint64 ipc_bytes; |
| 14: uint64 other_bytes; |
| }; |
| |
| // Similarly, this table mirrors zx_info_cpu_stats_t. |
| // See zircon/system/public/zircon/syscalls/object.h for more details. |
| table PerCpuStats { |
| 1: uint32 cpu_number; |
| 2: uint32 flags; |
| 3: zx.duration idle_time; |
| 4: uint64 reschedules; |
| 5: uint64 context_switches; |
| 6: uint64 irq_preempts; |
| 7: uint64 yields; |
| 8: uint64 ints; |
| 9: uint64 timer_ints; |
| 10: uint64 timers; |
| 11: uint64 page_faults; |
| 12: uint64 exceptions; |
| 13: uint64 syscalls; |
| 14: uint64 reschedule_ipis; |
| 15: uint64 generic_ipis; |
| }; |
| |
| struct CpuStats { |
| /// This is the total number of CPUs on the actual device. This may not be the same as the length |
| /// of the vector `per_cpu_stats` as it is possible the underlying syscall will not return stats |
| /// for all CPUs. |
| uint64 actual_num_cpus; |
| vector<PerCpuStats>:zx.MAX_CPUS? per_cpu_stats; |
| }; |
| |
| /// Protocol for providing kernel stats. This is roughly a wrapper around zx_object_get_info for |
| /// the ZX_INFO_KMEM_STATS, ZX_INFO_KMEM_STATS_EXTENDED and ZX_INFO_CPU_STATS topics, which today |
| /// require the very powerful 'Root Resource' capability to obtain. Instead of vending out that |
| /// capability, programs that just want stats should use this service instead. If for some reason |
| /// the protocol fails to retrieve stats, which will be an un-recoverable error, it will close the |
| /// channel. |
| [Discoverable] |
| protocol Stats { |
| GetMemoryStats() -> (MemoryStats stats); |
| |
| GetMemoryStatsExtended() -> (MemoryStatsExtended stats); |
| |
| GetCpuStats() -> (CpuStats stats); |
| }; |