免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3828 | 回复: 4
打印 上一主题 下一主题

每CPU页高速缓存 [复制链接]

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-07 09:25 |只看该作者 |倒序浏览
30可用积分
今天看了一下《Understanding the Linux Virtual Memory Manager》关于per_cpu_pages的部分,几个设计上的问题不明白。

1. it says"If the low watermark(per_cpu_pageset->low) has not been reached, the pages will be allocated from the pageset with no requirement for a spinlock to be hold"。
那么是否引入per_cpu_pages的目的就是可以省去使用spin_lock_irqsave,spin_unlock_irqsave这对自旋锁?这对自旋锁是干什么用的?省去了会带来什么好处?

2. it says"With 0 order allocations, splits will be delayed until the low watermark is reached in the per-cpu set, and coalescing will be delayed until the high watermark is reached"
为什么使用per_cpu_pages分配会产生延迟还是不明白?

3. it says"The first issue is that high-order allocations may fail if the pagesets hold order-0 pages that would normally be merged into higher order contigous blocks"
也就是说per_cpu_pages占用了一些page,使page都是order 0,无法合并成大的order,这样请求大order的block就会失败,这个问题是怎么解决的?

4. it says"The last potential problem is that buddies of newly freed pages could exist in other pagesets, leading to possible fragmentation problems"
不了解这种potential problem什么情况下会产生,为什么还会导致fragmentation problems?

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
2 [报告]
发表于 2011-11-07 15:00 |只看该作者
请教了kouu和某位VM大神,总结如下:

1. it says"If the low watermark(per_cpu_pageset->low) has not been reached, the pages will be allocated from the pageset with no requirement for a spinlock to be hold"。
那么是否引入per_cpu_pages的目的就是可以省去使用spin_lock_irqsave,spin_unlock_irqsave这对自旋锁?这对自旋锁是干什么用的?省去了会带来什么好处?

1)由于buddy system各个CPU都需要使用,会产生竞争,所以加锁,而per_cpu_pages是 per CPU的,不需要加锁
2)提高本地cache命中率,per_cpu_pages使得内存在倾向于在同一个CPU上使用


2. it says"With 0 order allocations, splits will be delayed until the low watermark is reached in the per-cpu set, and coalescing will be delayed until the high watermark is reached"
为什么使用per_cpu_pages分配会产生延迟还是不明白?

由于分配order为1的页是比较容易的,如果早早就split,造成碎片的可能性就大一些!


3. it says"The first issue is that high-order allocations may fail if the pagesets hold order-0 pages that would normally be merged into higher order contigous blocks"
也就是说per_cpu_pages占用了一些page,使page都是order 0,无法合并成大的order,这样请求大order的block就会失败,这个问题是怎么解决的?


当页面不足的时候,per_cpu_pages的页会被回收回来,如drain_pages之类的函数


4. it says"The last potential problem is that buddies of newly freed pages could exist in other pagesets, leading to possible fragmentation problems"
不了解这种potential problem什么情况下会产生,为什么还会导致fragmentation problems?

也就是说可能组成兄弟的两个page块一个在buddy里,一个在per_cpu_pages里,这样就不能组成一个大的order了

论坛徽章:
4
酉鸡
日期:2014-03-21 23:19:50狮子座
日期:2014-08-01 22:11:40酉鸡
日期:2015-01-10 21:31:442015年辞旧岁徽章
日期:2015-03-03 16:54:15
3 [报告]
发表于 2011-11-12 20:08 |只看该作者
第二个问题是啥意思?

论坛徽章:
1
拜羊年徽章
日期:2015-03-03 16:15:43
4 [报告]
发表于 2011-11-14 10:48 |只看该作者
第二个问题是说: 如果系统感到memory紧张, daomon就会扫描内存,回收一些不太可能再使用的页面;只有这些方法都用了,而剩下的内存已经到了最低允许的界限,这时才考虑split大的页面

论坛徽章:
0
5 [报告]
发表于 2011-11-14 16:26 |只看该作者
本帖最后由 jiabo2011 于 2011-11-14 16:51 编辑

第二个问题好像是说:per-CPU pageset 为每一个zone建造了一个有很多单个页组成的缓存。只有当这个缓存的页的数量大于一个阀值或小于一个阀值时,内核才考虑回收n个单页到buddy系统中或者从buddy中分离n个单页。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP