本文共 3688 字,大约阅读时间需要 12 分钟。
int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, unsigned long address, enum ttu_flags flags) struct mm_struct *mm = vma->vm_mm; pte_t *pte = page_check_address(page, mm, address, &ptl, 0); flush_cache_page(vma, address, page_to_pfn(page)); pteval = ptep_clear_flush_notify(vma, address, pte);//tlb if (pte_dirty(pteval)) set_page_dirty(page); page_remove_rmap(page); page_cache_release(page);//释放页框
unsigned long try_to_free_pages(struct zonelist *zonelist, int order, gfp_t gfp_mask, nodemask_t *nodemask) struct scan_control sc = { .gfp_mask = gfp_mask, .may_writepage = !laptop_mode, .nr_to_reclaim = SWAP_CLUSTER_MAX, .may_unmap = 1, .may_swap = 1, .swappiness = vm_swappiness, .order = order, .mem_cgroup = NULL, .isolate_pages = isolate_pages_global, .nodemask = nodemask, }; return do_try_to_free_pages(zonelist, &sc); =>unsigned long do_try_to_free_pages(struct zonelist *zonelist, struct scan_control *sc) for (priority = DEF_PRIORITY; priority >= 0; priority--) shrink_zones(priority, zonelist, sc); =>void shrink_zones(int priority, struct zonelist *zonelist, struct scan_control *sc) for_each_zone_zonelist_nodemask(zone, z, zonelist, high_zoneidx, sc->nodemask) shrink_zone(priority, zone, sc); =>void shrink_zone(int priority, struct zone *zone, struct scan_control *sc) while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || nr[LRU_INACTIVE_FILE]) for_each_evictable_lru(l) if (nr[l]) nr_to_scan = min_t(unsigned long, nr[l], SWAP_CLUSTER_MAX); nr[l] -= nr_to_scan; nr_reclaimed += shrink_list(l, nr_to_scan, zone, sc, priority); =>unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, struct zone *zone, struct scan_control *sc, int priority) int file = is_file_lru(lru); if (is_active_lru(lru)) if (inactive_list_is_low(zone, sc, file)) shrink_active_list(nr_to_scan, zone, sc, priority, file); return 0; return shrink_inactive_list(nr_to_scan, zone, sc, priority, file); =>unsigned long shrink_inactive_list(unsigned long max_scan, struct zone *zone, struct scan_control *sc, int priority, int file) nr_freed = shrink_page_list(&page_list, sc, PAGEOUT_IO_ASYNC);
Linux页面回收与反向映射机制
http://www.233.com/linux/fudao/20110324/153235403-4.htmlLinux内存管理之页面回收
https://blog.csdn.net/wh8_2011/article/details/52275231【内核】Linux 2.6 内存反向映射机制 Reverse Mapping
https://www.cnblogs.com/visayafan/archive/2011/12/24/2300758.htmllinux 逆向映射机制浅析
https://www.cnblogs.com/ck1020/p/6883061.html郭健:Linux内存管理系统参数配置之overcommit
https://blog.csdn.net/jus3ve/article/details/80681655页面回收---LRU链表
https://blog.csdn.net/zouxiaoting/article/details/8824896直接内存回收中的等待队列 好文章
http://www.cnblogs.com/tolimit/p/5481419.htmlLinux内核设计与实现(16)--页高速缓存和页回写
http://blog.chinaunix.net/uid-24708340-id-4060950.htmlLinux Kernel文件系统写I/O流程代码分析(二)bdi_writeback
https://www.cnblogs.com/jimbo17/p/10491223.htmlread()/write()的生命旅程之四——第四章:writeback
http://blog.sina.com.cn/s/blog_a558c25a0102vhv3.htmlblock_prepare_write
https://blog.csdn.net/kidd_3/article/details/7032785基数树(radix tree)
https://www.cnblogs.com/wuchanming/p/3824990.htmllinux内核之把块放在页高速缓存中
http://blog.chinaunix.net/uid-28977986-id-3778156.html内存脏数据下刷(linux2.6.18/linux.2.6.32)剖析
https://blog.csdn.net/u011013137/article/details/9110967Linux内核进程详解之二:bdi-default
http://www.lenky.info/archives/2012/02/1125Linux内存管理 —— 文件系统缓存和匿名页的交换
https://blog.csdn.net/jasonchen_gbd/article/details/79462014内存管理---匿名页面管理
https://blog.csdn.net/jasonlee_lijiaqi/article/details/83068446Linux 匿名页的反向映射
https://www.cnblogs.com/linhaostudy/p/10350326.html