當指針位數為32位時,virtual space 的大小就是 2^32,只有當指針位數是64位時,virtual space 才會增大。
通常virtual space 的劃分方式為 3:1, 依靠 PAGE_OFFSET 常數控制,影響著內核空間和用戶空間的上下文切換效率。 像路由器這種設備就希望虛擬空間全部都歸kernel,不給user。
昨天建立了數據結構,描述node的pgdat,描述zone的zone,還有nodelist 等初始化
今天是特定于體系結構的設置 architecture-specific ,以IA32,AMD64為例子
PHYSICAL_START , PHYSICAL_ALIGN
the kernel should always be loaded into a contiguous memory range, IA-32 kernels use s0x100000 as the start address, this corresponds to the start of the first megabyte in RAM memory, named _text.
Each time the kernel is compiled, a file named System.map is generated and stored in the source base directory. Besides the address of all other variables, procedures, and functions defined in the kernel, this file also includes the values of the constants ablout _text…
For AMD64 systems, the kernel starts 2MiB after the fisrt page frame, and physical memory is mapped into the virtual address space from 0xffffffff80000000 onward.
These are not the same regions as in the NUMA concept but are areas occupied by ACPI functions
https://zhuanlan.zhihu.com/p/88202063
1.獲取當前可用memory
2. parse_early_param 計算highmem, fixmap,
3. bootmem 初始化
4. pageinit
5. bootmem allocator
6. 劃分 pageinit新,page table,線性映射,fixmap;清空所有boot期間的mem包括TLB,因為這個TLB是硬件建立的
7. zone 完全實例化, 冷熱頁的初始化,為watermark準備, buddy
pageinit
896M for system directly map
128M NOT directly :vmalloc, persitent, fixmap
highmemory -> max_low_phn 這里沒透,就先按趙是通過find 函數秋出來的。
fixmap 固定映射的內存,TLB高速緩存
the advantage of fixmap addresses is that at compilation time, the address acts like a constant whose physical address is assigned when the kernel is booted.
pagetable_init
–>kernel_physical_mapping
–> fixmap and persitent map
load cr2(swapper_pg_dir)PGD
__flush_all_tlb
kmap_init
->> 得到kmap_pte, kmem_vstart用來映射highmem
內核的zimage 還是保存到 實際物理內存的。
完善pg_data_t 的冷熱頁元素。
找到所有的活動區域,去除掉孔洞的那些。
開始buddy。