重读页面的回收处理笔记2
来源:互联网 发布:linux ping timeout 编辑:程序博客网 时间:2024/06/05 23:52
在跟踪代码的过程中,我们可以看到alloc-page就是分配一个page。
我们在接着看代码:
函数:__alloc_pages_internal,我们可以看到注释:
/*
* This is the 'heart' of the zoned buddy allocator.
*/
从上面知道这个函数的地位了。首先会去唤醒kswapd的内核线成。
wakeup_kswapd。
接着:
unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
gfp_t gfp_mask)
{
struct scan_control sc = {
.gfp_mask = gfp_mask,
.may_writepage = !laptop_mode,
.swap_cluster_max = SWAP_CLUSTER_MAX,
.may_swap = 1,
.swappiness = vm_swappiness,
.order = order,
.mem_cgroup = NULL,
.isolate_pages = isolate_pages_global,
};
return do_try_to_free_pages(zonelist, &sc);
}
上面只是一种想当于人为的去释放pages。kswapd是内存回收的守护内核线程。
下面是kswapd的动作:
static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
{
int all_zones_ok;
int priority;
int i;
unsigned long total_scanned;
unsigned long nr_reclaimed;
struct reclaim_state *reclaim_state = current->reclaim_state;
struct scan_control sc = {
.gfp_mask = GFP_KERNEL,
.may_swap = 1,
.swap_cluster_max = SWAP_CLUSTER_MAX,
.swappiness = vm_swappiness,
.order = order,
.mem_cgroup = NULL,
.isolate_pages = isolate_pages_global,
};
shrink_zone
shrink_active_list
shrink_inactive_list
shrink_slab
我们在前一篇文章说了slab页面没有放在page cache中,所以有一个独立的 shrink_slab函数来处理
对于page cache的处理。
shrink_active_list,我们也同样看看该函数的说明:
/*
* This moves pages from the active list to the inactive list.
*
* We move them the other way if the page is referenced by one or more
* processes, from rmap.
*
* If the pages are mostly unmapped, the processing is fast and it is
* appropriate to hold zone->lru_lock across the whole operation. But if
* the pages are mapped, the processing is slow (page_referenced()) so we
* should drop zone->lru_lock around each page. It's impossible to balance
* this, so instead we remove the pages from the LRU while processing them.
* It is safe to rely on PG_active against the non-LRU pages in here because
* nobody will play with that bit on a non-LRU page.
*
* The downside is that we have to touch page->_count against each page.
* But we had to alter page->flags anyway.
*/
而函数:shrink_inactive_list的说明:
/*
* shrink_inactive_list() is a helper for shrink_zone(). It returns the number
* of reclaimed pages
*/
- 重读页面的回收处理笔记2
- 重读页面的回收处理笔记1
- Android开发精要 重读 + xmind笔记(2)
- linux 页面的回收
- linux 页面的回收
- 重读uclinux-2008r1-rc8(bf561)内核的中断处理(2):中断配置
- 笔记四:重读javascript权威指南,对prototype的理解
- Android笔记-2:重读单例模式有感
- H5页面打开android本地照册,当webview页面被系统回收的情况下,如何处理图片
- 重读保尔的意义
- 重读:《微软的秘密》
- 重读GFS的设计
- 重读uclinux-2008r1-rc8(bf561)内核的中断处理(3):中断处理流程
- 重读uclinux-2008r1-rc8(bf561)内核的中断处理(4):特定处理函数
- 重读spring2.5手册笔记
- 《Effective STL》重读笔记整理
- 重读C/C++笔记(一)
- 重读C/C++笔记(二)
- PS 研究:圆形笔刷与渐变曲率
- Linux的应用--Video Streaming探讨 六
- C#编程命名规范
- 基于嵌入式linux和s32410平台的视频采集
- oracle中合并insert、update语句
- 重读页面的回收处理笔记2
- H.264之指数哥伦布编解码分析
- 查找历史纪录的代码
- [转]web.xml文件详解
- 表格边框/单元格之间分隔线的隐藏实现方法
- 数据分析(摘自百度)
- vs2005 写的web servcies 在.net 2003下调用时报xml 604异常原因是因为实体类,声明类型两个环境不一样
- 面向对象设计的设计原则
- fckeditor集成到php zend framework框架中