/* Reserve the lowmem memblock reserved regions in bootmem. */ for_each_memblock(reserved, reg) { unsigned long start = memblock_region_reserved_base_pfn(reg); unsigned long end = memblock_region_reserved_end_pfn(reg); if (end >= end_pfn) end = end_pfn; if (start >= end) break; reserve_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT); }
/* Reserve the lowmem memblock reserved regions in bootmem. */ for_each_memblock(reserved, reg) { // for (reg = memblock.reserved.regions; reg < (memblock.reserved.regions + memblock.reserved.cnt), reg++) unsigned long start = memblock_region_reserved_base_pfn(reg); unsigned long end = memblock_region_reserved_end_pfn(reg); if (end >= end_pfn) end = end_pfn; if (start >= end) break; // start : 0x20000000, (end - start) << PAGE_SHIFT : 0x2F800000 reserve_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT); // start부터 end에 해당하는 bitmap 중 reserved 영역을 1로 설정 }
/* Reserve the lowmem memblock reserved regions in bootmem. */ for_each_memblock(reserved, reg) { // start: 0x40004 unsigned long start = memblock_region_reserved_base_pfn(reg); // end: 0x40008 unsigned long end = memblock_region_reserved_end_pfn(reg); // end: 0x40008, end_pfn: 0x4f800 if (end >= end_pfn) end = end_pfn; // start: 0x40004, end: 0x40008 if (start >= end) break; // __pfn_to_phys(0x40004): 0x40004000, (end - start) << PAGE_SHIFT: 0x4000 // BOOTMEM_DEFAULT: 0 reserve_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT); }
static void __init free_highpages(void) { unsigned long max_low = max_low_pfn; struct memblock_region *mem, *res; reset_all_zones_managed_pages(); /* set highmem page free */ for_each_memblock(memory, mem) { unsigned long start = memblock_region_memory_base_pfn(mem); unsigned long end = memblock_region_memory_end_pfn(mem); /* Ignore complete lowmem entries */ if (end <= max_low) continue; if (memblock_is_nomap(mem)) continue; /* Truncate partial highmem entries */ if (start < max_low) start = max_low; /* Find and exclude any reserved regions */ for_each_memblock(reserved, res) { unsigned long res_start, res_end; res_start = memblock_region_reserved_base_pfn(res); res_end = memblock_region_reserved_end_pfn(res); if (res_end < start) continue; if (res_start < start) res_start = start; if (res_start > end) res_start = end; if (res_end > end) res_end = end; if (res_start != start) free_area_high(start, res_start); start = res_end; if (start == end) break; }