diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-08-21 00:15:00 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-08-21 00:22:26 +0200 |
commit | ec06b6d64b99bf39dd7728787efc352db3c7cabc (patch) | |
tree | d15fef7a6a49f51e39eae6c6d3a555c461833fc5 /vm | |
parent | 4a704a0ad95973249544f3f95e30e328e701a871 (diff) | |
download | gnumach-ec06b6d64b99bf39dd7728787efc352db3c7cabc.tar.gz gnumach-ec06b6d64b99bf39dd7728787efc352db3c7cabc.tar.bz2 gnumach-ec06b6d64b99bf39dd7728787efc352db3c7cabc.zip |
db: Add show vmstat command
with an output similar to the userland vmstat command
* vm/vm_page.c (db_show_vmstat): New function.
* vm/vm_page.h (db_show_vmstat): New prototype.
* ddb/db_command.c (db_show_cmds): Add vmstat command.
Diffstat (limited to 'vm')
-rw-r--r-- | vm/vm_page.c | 43 | ||||
-rw-r--r-- | vm/vm_page.h | 5 |
2 files changed, 48 insertions, 0 deletions
diff --git a/vm/vm_page.c b/vm/vm_page.c index 9a7fa275..fa61af85 100644 --- a/vm/vm_page.c +++ b/vm/vm_page.c @@ -2086,3 +2086,46 @@ vm_page_wait(void (*continuation)(void)) thread_block((void (*)(void)) 0); } } + +#if MACH_KDB +#include <ddb/db_output.h> +#define PAGES_PER_MB ((1<<20) / PAGE_SIZE) +void db_show_vmstat(void) +{ + integer_t free_count = vm_page_mem_free(); + + db_printf("%-20s %10uM\n", "size:", + (free_count + vm_page_active_count + + vm_page_inactive_count + vm_page_wire_count) + / PAGES_PER_MB); + + db_printf("%-20s %10uM\n", "free:", + free_count / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "active:", + vm_page_active_count / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "inactive:", + vm_page_inactive_count / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "wired:", + vm_page_wire_count / PAGES_PER_MB); + + db_printf("%-20s %10uM\n", "zero filled:", + vm_stat.zero_fill_count / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "reactivated:", + vm_stat.reactivations / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "pageins:", + vm_stat.pageins / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "pageouts:", + vm_stat.pageouts / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "page faults:", + vm_stat.faults / PAGES_PER_MB); + db_printf("%-20s %10uM\n", "cow faults:", + vm_stat.cow_faults / PAGES_PER_MB); + db_printf("%-20s %10u%\n", "memobj hit ratio:", + (vm_stat.hits * 100) / vm_stat.lookups); + + db_printf("%-20s %10u%\n", "cached_memobjs", + vm_object_external_count); + db_printf("%-20s %10uM\n", "cache", + vm_object_external_pages / PAGES_PER_MB); +} +#endif /* MACH_KDB */ diff --git a/vm/vm_page.h b/vm/vm_page.h index 2a0ad2c2..d9af188c 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -532,4 +532,9 @@ boolean_t vm_page_evict(boolean_t *should_wait); */ void vm_page_refill_inactive(void); +/* + * Print vmstat information + */ +void db_show_vmstat(void); + #endif /* _VM_VM_PAGE_H_ */ |