03-03学习笔记 内存管理初始化

文章探讨了不同体系结构下虚拟空间的管理,如32位和64位系统中virtualspace的大小和分配策略。强调了内核与用户空间的上下文切换效率,以及在初始化过程中,如早期参数处理、bootmem和pageinit的计算,以及fixmap在内存映射中的重要作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当指针位数为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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值