[RFC] discard task stack pages instead of pageout into swap partition

From: Wang, Yalin
Date: Thu Dec 11 2014 - 22:31:14 EST


Hi,

I am think of discard stack pages if the old
Page is under the stack pointer(Assume stack grow down)
of the task, This page don't need pageout, we can free it directly,
When the task need it again, we just use a zero page to
Map, it is safe for stack .

But I don't know how to implement it,
And is there some issue if do like this ?

The following is pseudo code to explain my ideas.
Any comments are appreciated !
Thanks
---
diff --git a/mm/vmscan.c b/mm/vmscan.c
index dcb4707..52e8314 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -962,6 +962,12 @@ static unsigned long shrink_page_list(struct list_head *page_list,
; /* try to reclaim the page below */
}

+ if (page_vm_flags(page) & (VM_GROWSUP | VM_GROWSDOWN) &&
+ PageAnon(page) && !PageSwapCache(page)) {
+ if (page_task_is_sleep(page) && task_sp > page->index) {
+ zap_page_range(vma, page->index, PAGE_SIZE);
+ }
+ }
/*
* Anonymous process memory has backing store?
* Try to allocate it some swap space here.
N‹§²æ¸›yú²X¬¶ÇvØ–)Þ{.nlj·¥Š{±‘êX§¶›¡Ü}©ž²ÆzÚj:+v‰¨¾«‘êZ+€Êzf£¢·hšˆ§~†­†Ûÿû®w¥¢¸?™¨è&¢)ßf”ùy§m…á«a¶Úÿ 0¶ìå