diff options
author | Richard Braun <rbraun@sceen.net> | 2019-05-22 21:59:19 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2019-05-22 21:59:19 +0200 |
commit | 5bc2263b54a89e28dd5092c807a86cd3c078e4d3 (patch) | |
tree | ad399e98a6d46bad25543a4f8680335f3abb1bf8 /vm/vm_page.c | |
parent | c45d94a590d778c26dc78386c41231fed9df1b14 (diff) |
Add a log print function type for information reporting
This type allows the use of either printf-based or log-based functions
when reporting information.
Diffstat (limited to 'vm/vm_page.c')
-rw-r--r-- | vm/vm_page.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/vm/vm_page.c b/vm/vm_page.c index beccfabd..b1df194b 100644 --- a/vm/vm_page.c +++ b/vm/vm_page.c @@ -643,37 +643,16 @@ vm_page_bootalloc(size_t size) panic("vm_page: no physical memory available"); } -static void -vm_page_info_common(int (*print_fn)(const char *format, ...)) -{ - struct vm_page_zone *zone; - unsigned long pages; - unsigned int i; - - for (i = 0; i < vm_page_zones_size; i++) { - zone = &vm_page_zones[i]; - pages = (unsigned long)(zone->pages_end - zone->pages); - print_fn("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)\n", - vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT), - zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT)); - } -} - #ifdef CONFIG_SHELL static void -vm_page_info(void) -{ - vm_page_info_common(printf); -} - -static void vm_page_shell_info(struct shell *shell, int argc, char **argv) { (void)shell; (void)argc; (void)argv; - vm_page_info(); + + vm_page_info(printf_ln); } static struct shell_cmd vm_page_shell_cmds[] = { @@ -854,7 +833,17 @@ vm_page_zone_name(unsigned int zone_index) } void -vm_page_log_info(void) +vm_page_info(log_print_fn_t print_fn) { - vm_page_info_common(log_info); + struct vm_page_zone *zone; + unsigned long pages; + unsigned int i; + + for (i = 0; i < vm_page_zones_size; i++) { + zone = &vm_page_zones[i]; + pages = (unsigned long)(zone->pages_end - zone->pages); + print_fn("vm_page: %s: pages: %lu (%luM), free: %lu (%luM)", + vm_page_zone_name(i), pages, pages >> (20 - PAGE_SHIFT), + zone->nr_free_pages, zone->nr_free_pages >> (20 - PAGE_SHIFT)); + } } |