sandbox: extra page stats output
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -41,6 +42,37 @@ static struct mem_map_region mem_map[] = {
|
|||||||
/* virtual address of where system memory is mapped */
|
/* virtual address of where system memory is mapped */
|
||||||
static void *system_memory = NULL;
|
static void *system_memory = NULL;
|
||||||
|
|
||||||
|
static void print_zone_pages(vm_zone_t *z)
|
||||||
|
{
|
||||||
|
for (int i = VM_PAGE_MIN_ORDER; i <= VM_PAGE_MAX_ORDER; i++) {
|
||||||
|
queue_foreach (vm_page_t, pg, &z->z_free_pages[i], p_free_list) {
|
||||||
|
printf(" * %08zx (%s, order %u, 0x%zx bytes)\n",
|
||||||
|
vm_page_get_paddr(pg),
|
||||||
|
z->z_info.zd_name,
|
||||||
|
pg->p_order,
|
||||||
|
vm_page_order_to_bytes(pg->p_order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_all_pages(void)
|
||||||
|
{
|
||||||
|
for (phys_addr_t i = 0; i < UINTPTR_MAX; ) {
|
||||||
|
vm_page_t *pg = vm_page_get(i);
|
||||||
|
if (!pg) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" * %08" PRIxPTR ": %s order-%u (%zu bytes) %s\n",
|
||||||
|
i,
|
||||||
|
pg->p_zone ? pg->p_zone->z_info.zd_name : "[none]",
|
||||||
|
pg->p_order,
|
||||||
|
vm_page_order_to_bytes(pg->p_order),
|
||||||
|
pg->p_flags & VM_PAGE_RESERVED ? "reserved" : "free");
|
||||||
|
i += vm_page_order_to_bytes(pg->p_order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int memory_test(void)
|
int memory_test(void)
|
||||||
{
|
{
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
@@ -127,6 +159,15 @@ int memory_test(void)
|
|||||||
it.it_limit);
|
it.it_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_pg_data_t *pg_data = vm_pg_data_get(0);
|
||||||
|
printf("free pages:\n");
|
||||||
|
for (int i = VM_ZONE_MIN; i <= VM_ZONE_MAX; i++) {
|
||||||
|
print_zone_pages(&pg_data->pg_zones[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("all pages:\n");
|
||||||
|
print_all_pages();
|
||||||
|
|
||||||
munmap(system_memory, MB_TO_BYTES(MEMORY_SIZE_MB));
|
munmap(system_memory, MB_TO_BYTES(MEMORY_SIZE_MB));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user