All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mmotm-2009-12-10-17-19] Prevent churning of zero page in LRU list.
@ 2009-12-28  2:53 ` Minchan Kim
  0 siblings, 0 replies; 22+ messages in thread
From: Minchan Kim @ 2009-12-28  2:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml, linux-mm, Hugh Dickins, Rik van Riel, KOSAKI Motohiro


VM doesn't add zero page to LRU list. 
It means zero page's churning in LRU list is pointless. 

As a matter of fact, zero page can't be promoted by mark_page_accessed
since it doesn't have PG_lru. 

This patch prevent unecessary mark_page_accessed call of zero page 
alghouth caller want FOLL_TOUCH. 

Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
---
 mm/memory.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 09e4b1b..485f727 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1152,6 +1152,7 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
 	spinlock_t *ptl;
 	struct page *page;
 	struct mm_struct *mm = vma->vm_mm;
+	int zero_pfn = 0;
 
 	page = follow_huge_addr(mm, address, flags & FOLL_WRITE);
 	if (!IS_ERR(page)) {
@@ -1196,15 +1197,15 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
 
 	page = vm_normal_page(vma, address, pte);
 	if (unlikely(!page)) {
-		if ((flags & FOLL_DUMP) ||
-		    !is_zero_pfn(pte_pfn(pte)))
+		zero_pfn = is_zero_pfn(pte_pfn(pte));
+		if ((flags & FOLL_DUMP) || !zero_pfn )
 			goto bad_page;
 		page = pte_page(pte);
 	}
 
 	if (flags & FOLL_GET)
 		get_page(page);
-	if (flags & FOLL_TOUCH) {
+	if (flags & FOLL_TOUCH && !zero_pfn) {
 		if ((flags & FOLL_WRITE) &&
 		    !pte_dirty(pte) && !PageDirty(page))
 			set_page_dirty(page);
-- 
1.5.6.3


-- 
Kind regards,
Minchan Kim

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-12-31  2:26 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-28  2:53 [PATCH -mmotm-2009-12-10-17-19] Prevent churning of zero page in LRU list Minchan Kim
2009-12-28  2:53 ` Minchan Kim
2009-12-28  2:57 ` KAMEZAWA Hiroyuki
2009-12-28  2:57   ` KAMEZAWA Hiroyuki
2009-12-28  3:18 ` KOSAKI Motohiro
2009-12-28  3:18   ` KOSAKI Motohiro
2009-12-28  3:22 ` Rik van Riel
2009-12-28  3:22   ` Rik van Riel
2009-12-28  3:56   ` Balbir Singh
2009-12-28  3:56     ` Balbir Singh
2009-12-28  3:57     ` Balbir Singh
2009-12-28  3:57       ` Balbir Singh
2009-12-28  4:12       ` Rik van Riel
2009-12-28  4:12         ` Rik van Riel
2009-12-28  4:17         ` Balbir Singh
2009-12-28  4:17           ` Balbir Singh
2009-12-28  4:09   ` Minchan Kim
2009-12-28  4:09     ` Minchan Kim
2009-12-30 17:03     ` Hugh Dickins
2009-12-30 17:03       ` Hugh Dickins
2009-12-31  2:26       ` Minchan Kim
2009-12-31  2:26         ` Minchan Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.