Developer tool to limit RAM used (eg to restrict to only node0 memory etc).
Signed-off-by: Kanoj Sarcar <[email protected]> --- kern/arch/x86/page_alloc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kern/arch/x86/page_alloc.c b/kern/arch/x86/page_alloc.c index da3d8b0..ad0aaa4 100644 --- a/kern/arch/x86/page_alloc.c +++ b/kern/arch/x86/page_alloc.c @@ -48,6 +48,10 @@ static bool pa64_is_in_kernel(uint64_t paddr) return (EXTPHYSMEM <= paddr) && (paddr < PADDR(end)); } +#define MAX_LIMIT_RAM 0xFFFFFFFFFFFFFFFFULL +static uint64_t max_usable_paddr = MAX_LIMIT_RAM; /* cmdline option? */ +#define USABLE_RAM(_pa_) ((_pa_) < max_usable_paddr) + /* Helper. For every page in the entry, this will determine whether or not the * page is free, and handle accordingly. All pages are marked as busy by * default, and we're just determining which of them could be free. */ @@ -89,6 +93,11 @@ static void parse_mboot_region(struct multiboot_mmap_entry *entry, void *data) * bootzone. If it was in the bootzone, we already skipped it. */ if (pa64_is_in_kernel(i)) continue; + + /* If beyond what we want to allocate, give up */ + if (!USABLE_RAM(i)) + return; + track_free_page(pa64_to_page(i)); } } @@ -98,6 +107,10 @@ static void check_range(uint64_t start, uint64_t end, int expect) int ref; if (PGOFF(start)) printk("Warning: check_range given unaligned addr 0x%016llx\n", start); + + if ((expect == 0) && (!USABLE_RAM(end))) + end = max_usable_paddr; + for (uint64_t i = start; i < end; i += PGSIZE) { ref = kref_refcnt(&pa64_to_page(i)->pg_kref); if (ref != expect) { -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
