impove memory accounting
. the total amount of memory in the system didn't include the memory used by the boot-time modules and some dynamic allocation by the kernel at boot time (to map in VM). especially apparent on our ARM board with 'only' 512MB of memory and a huge ramdisk. . also: *add* the VM loaded module to the freelist after it has been allocated for & mapped in instead of cutting it *out* of the freelist! so we get a few more MB free.. Change-Id: If37ac32b21c9d38610830e21421264da4f20bc4f
This commit is contained in:
@@ -97,6 +97,11 @@ phys_clicks alloc_mem(phys_clicks clicks, u32_t memflags)
|
||||
return mem;
|
||||
}
|
||||
|
||||
void mem_add_total_pages(int pages)
|
||||
{
|
||||
total_pages += pages;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* free_mem *
|
||||
*===========================================================================*/
|
||||
|
||||
@@ -306,6 +306,8 @@ void init_vm(void)
|
||||
static struct memory mem_chunks[NR_MEMS];
|
||||
static struct boot_image *ip;
|
||||
extern void __minix_init(void);
|
||||
multiboot_module_t *mod;
|
||||
vir_bytes kern_dyn, kern_static;
|
||||
|
||||
#if SANITYCHECKS
|
||||
incheck = nocheck = 0;
|
||||
@@ -344,6 +346,21 @@ void init_vm(void)
|
||||
init_proc(VM_PROC_NR);
|
||||
pt_init();
|
||||
|
||||
/* The kernel's freelist does not include boot-time modules; let
|
||||
* the allocator know that the total memory is bigger.
|
||||
*/
|
||||
for (mod = &kernel_boot_info.module_list[0];
|
||||
mod < &kernel_boot_info.module_list[kernel_boot_info.mods_with_kernel-1]; mod++) {
|
||||
phys_bytes len = mod->mod_end-mod->mod_start+1;
|
||||
len = roundup(len, VM_PAGE_SIZE);
|
||||
mem_add_total_pages(len/VM_PAGE_SIZE);
|
||||
}
|
||||
|
||||
kern_dyn = kernel_boot_info.kernel_allocated_bytes_dynamic;
|
||||
kern_static = kernel_boot_info.kernel_allocated_bytes;
|
||||
kern_static = roundup(kern_static, VM_PAGE_SIZE);
|
||||
mem_add_total_pages((kern_dyn + kern_static)/VM_PAGE_SIZE);
|
||||
|
||||
/* Give these processes their own page table. */
|
||||
for (ip = &kernel_boot_info.boot_procs[0];
|
||||
ip < &kernel_boot_info.boot_procs[NR_BOOT_PROCS]; ip++) {
|
||||
|
||||
@@ -26,6 +26,7 @@ void usedpages_reset(void);
|
||||
int usedpages_add_f(phys_bytes phys, phys_bytes len, char *file, int
|
||||
line);
|
||||
void free_mem(phys_clicks base, phys_clicks clicks);
|
||||
void mem_add_total_pages(int pages);
|
||||
#define usedpages_add(a, l) usedpages_add_f(a, l, __FILE__, __LINE__)
|
||||
|
||||
void mem_init(struct memory *chunks);
|
||||
|
||||
+2
-1
@@ -1462,7 +1462,8 @@ void get_stats_info(struct vm_stats_info *vsi)
|
||||
void get_usage_info_kernel(struct vm_usage_info *vui)
|
||||
{
|
||||
memset(vui, 0, sizeof(*vui));
|
||||
vui->vui_total = kernel_boot_info.kernel_allocated_bytes;
|
||||
vui->vui_total = kernel_boot_info.kernel_allocated_bytes +
|
||||
kernel_boot_info.kernel_allocated_bytes_dynamic;
|
||||
}
|
||||
|
||||
static void get_usage_info_vm(struct vm_usage_info *vui)
|
||||
|
||||
Reference in New Issue
Block a user