Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/3_memory/linux_mem2 中的1/8 和7/8 有问题 #247

Open
geesun opened this issue May 15, 2024 · 0 comments
Open

os/3_memory/linux_mem2 中的1/8 和7/8 有问题 #247

geesun opened this issue May 15, 2024 · 0 comments

Comments

@geesun
Copy link

geesun commented May 15, 2024

页面:
https://www.xiaolincoding.com/os/3_memory/linux_mem2.html#_5-4-min-free-kbytes-的计算逻辑
里面的

比如:当前 NUMA 节点中有两个 zone :ZONE_DMA 和 ZONE_NORMAL,内存容量大小分别是:100 M 和 800 M。那么 ZONE_DMA 与 ZONE_NORMAL 之间的比例就是 1 :8。

根据这个比例,ZONE_DMA 区域里的 WMARK_MIN 水位线就是:min_free_kbytes * 1 / 8 。ZONE_NORMAL 区域里的 WMARK_MIN 水位线就是:min_free_kbytes * 7 / 8。

这里的1/8应该是 1/9 , 而7/8应该是8/9

根据函数 __setup_per_zone_wmarks,lowmem_pages 算的是ZONE_DMA 和 ZONE_NORMAL 的总page,对应上面是900M内存,而
tmp = (u64)pages_min * zone_managed_pages(zone);
do_div(tmp, lowmem_pages);

zone_managed_pages(zone) 算的是当前的zone的page,对应的是100M或800M

所以对应的比例应该是 1/9 或者 8/9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant