慢慢欣赏linux 页面回收

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.html

Linux内存管理之页面回收
https://blog.csdn.net/wh8_2011/article/details/52275231

【内核】Linux 2.6 内存反向映射机制 Reverse Mapping
https://www.cnblogs.com/visayafan/archive/2011/12/24/2300758.html

linux 逆向映射机制浅析
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.html

猜你喜欢

转载自blog.csdn.net/shipinsky/article/details/89787656