Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25588f85 authored by Minchan Kim's avatar Minchan Kim Committed by Vinayak Menon
Browse files

mm: Enhance per process reclaim to consider shared pages



Some pages could be shared by several processes. (ex, libc)
In case of that, it's too bad to reclaim them from the beginnig.

This patch causes VM to keep them on memory until last task
try to reclaim them so shared pages will be reclaimed only if
all of task has gone swapping out.

This feature doesn't handle non-linear mapping on ramfs because
it's very time-consuming and doesn't make sure of reclaiming and
not common.

Change-Id: I7e5f34f2e947f5db6d405867fe2ad34863ca40f7
Signed-off-by: default avatarSangseok Lee <sangseok.lee@lge.com>
Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
Patch-mainline: linux-mm @ 9 May 2013 16:21:27
[vinmenon@codeaurora.org: trivial merge conflict fixes + changes
to make the patch work with 3.18 kernel]
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 080d5d3a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1421,7 +1421,7 @@ cont:
			break;
	}
	pte_unmap_unlock(pte - 1, ptl);
	reclaim_pages_from_list(&page_list);
	reclaim_pages_from_list(&page_list, vma);
	if (addr != end)
		goto cont;

+6 −3
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@

extern int isolate_lru_page(struct page *page);
extern void putback_lru_page(struct page *page);
extern unsigned long reclaim_pages_from_list(struct list_head *page_list);
extern unsigned long reclaim_pages_from_list(struct list_head *page_list,
					     struct vm_area_struct *vma);

/*
 * The anon_vma heads a list of private "related" vmas, to scan if
@@ -199,7 +200,8 @@ int page_referenced(struct page *, int is_locked,

#define TTU_ACTION(x) ((x) & TTU_ACTION_MASK)

int try_to_unmap(struct page *, enum ttu_flags flags);
int try_to_unmap(struct page *, enum ttu_flags flags,
			struct vm_area_struct *vma);

/*
 * Called from mm/filemap_xip.c to unmap empty zero page
@@ -256,6 +258,7 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma);
 */
struct rmap_walk_control {
	void *arg;
	struct vm_area_struct *target_vma;
	int (*rmap_one)(struct page *page, struct vm_area_struct *vma,
					unsigned long addr, void *arg);
	int (*done)(struct page *page);
@@ -280,7 +283,7 @@ static inline int page_referenced(struct page *page, int is_locked,
	return 0;
}

#define try_to_unmap(page, refs) SWAP_FAIL
#define try_to_unmap(page, refs, vma) SWAP_FAIL

static inline int page_mkclean(struct page *page)
{
+0 −2
Original line number Diff line number Diff line
@@ -267,10 +267,8 @@ static inline void mlock_migrate_page(struct page *newpage, struct page *page)

extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
extern unsigned long vma_address(struct page *page,
				 struct vm_area_struct *vma);
#endif
#else /* !CONFIG_MMU */
static inline void clear_page_mlock(struct page *page) { }
static inline void mlock_vma_page(struct page *page) { }
+6 −0
Original line number Diff line number Diff line
@@ -1965,6 +1965,12 @@ int rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc)
	stable_node = page_stable_node(page);
	if (!stable_node)
		return ret;

	if (rwc->target_vma) {
               unsigned long address = vma_address(page, rwc->target_vma);
               ret = rwc->rmap_one(page, rwc->target_vma, address, rwc->arg);
               goto out;
	}
again:
	hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) {
		struct anon_vma *anon_vma = rmap_item->anon_vma;
+1 −1
Original line number Diff line number Diff line
@@ -1006,7 +1006,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
	if (kill)
		collect_procs(ppage, &tokill, flags & MF_ACTION_REQUIRED);

	ret = try_to_unmap(ppage, ttu);
	ret = try_to_unmap(ppage, ttu, NULL);
	if (ret != SWAP_SUCCESS)
		printk(KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n",
				pfn, page_mapcount(ppage));
Loading