diff options
Diffstat (limited to 'vm')
-rw-r--r-- | vm/vm_map.c | 25 | ||||
-rw-r--r-- | vm/vm_map.h | 5 | ||||
-rw-r--r-- | vm/vm_page.c | 39 | ||||
-rw-r--r-- | vm/vm_page.h | 3 |
4 files changed, 32 insertions, 40 deletions
diff --git a/vm/vm_map.c b/vm/vm_map.c index 03bc7165..42725d9c 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -29,6 +29,7 @@ #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/macros.h> #include <kern/mutex.h> #include <kern/panic.h> @@ -713,13 +714,13 @@ vm_map_shell_info(struct shell *shell, int argc, char **argv) goto error; } - vm_map_info(task_get_vm_map(task)); + vm_map_info(task_get_vm_map(task), printf_ln); } return; error: - printf("vm_map: info: invalid arguments\n"); + printf_ln("vm_map: info: invalid arguments"); } static struct shell_cmd vm_map_shell_cmds[] = { @@ -803,7 +804,7 @@ error_map: } void -vm_map_info(struct vm_map *map) +vm_map_info(struct vm_map *map, log_print_fn_t print_fn) { struct vm_map_entry *entry; const char *type, *name; @@ -816,10 +817,10 @@ vm_map_info(struct vm_map *map) mutex_lock(&map->lock); - printf("vm_map: %s: %016lx-%016lx\n" - "vm_map: start end " - "size offset flags type\n", name, - (unsigned long)map->start, (unsigned long)map->end); + print_fn("vm_map: %s: %016lx-%016lx" + "vm_map: start end " + "size offset flags type\n", name, + (unsigned long)map->start, (unsigned long)map->end); list_for_each_entry(&map->entry_list, entry, list_node) { if (entry->object == NULL) { @@ -828,13 +829,13 @@ vm_map_info(struct vm_map *map) type = "object"; } - printf("vm_map: %016lx %016lx %8luk %08llx %08x %s\n", - (unsigned long)entry->start, (unsigned long)entry->end, - (unsigned long)(entry->end - entry->start) >> 10, - (unsigned long long)entry->offset, entry->flags, type); + print_fn("vm_map: %016lx %016lx %8luk %08llx %08x %s", + (unsigned long)entry->start, (unsigned long)entry->end, + (unsigned long)(entry->end - entry->start) >> 10, + (unsigned long long)entry->offset, entry->flags, type); } - printf("vm_map: total: %zuk\n", map->size >> 10); + print_fn("vm_map: total: %zuk", map->size >> 10); mutex_unlock(&map->lock); } diff --git a/vm/vm_map.h b/vm/vm_map.h index dc6514bd..4e925722 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Richard Braun. + * Copyright (c) 2011-2019 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include <kern/init.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/mutex.h> #include <kern/rbtree.h> #include <machine/pmap.h> @@ -120,7 +121,7 @@ int vm_map_create(struct vm_map **mapp); /* * Display information about a memory map. */ -void vm_map_info(struct vm_map *map); +void vm_map_info(struct vm_map *map, log_print_fn_t print_fn); /* * This init operation provides : 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)); + } } diff --git a/vm/vm_page.h b/vm/vm_page.h index 4f2aaf93..7865d16a 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -33,6 +33,7 @@ #include <kern/atomic.h> #include <kern/init.h> #include <kern/list.h> +#include <kern/log.h> #include <kern/log2.h> #include <kern/macros.h> #include <machine/page.h> @@ -230,7 +231,7 @@ const char * vm_page_zone_name(unsigned int zone_index); /* * Log information about physical pages. */ -void vm_page_log_info(void); +void vm_page_info(log_print_fn_t print_fn); static inline bool vm_page_referenced(const struct vm_page *page) |