[PATCH v4 7/7] Prevent activation of page in madvise_dontneed

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Minchan Kim
Date: Sunday, December 5, 2010 - 10:29 am

Now zap_pte_range alwayas activates pages which are pte_young &&
!VM_SequentialReadHint(vma). But in case of calling MADV_DONTNEED,
it's unnecessary since the page wouldn't use any more.

Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Acked-by: Rik van Riel <riel@redhat.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Hugh Dickins <hughd@google.com>

Changelog since v3:
 - Change variable name - suggested by Johannes
 - Union ignore_references with zap_details - suggested by Hugh

Changelog since v2:
 - remove unnecessary description

Changelog since v1:
 - change word from promote to activate
 - add activate argument to zap_pte_range and family function
---
 include/linux/mm.h |    4 +++-
 mm/madvise.c       |    6 +++---
 mm/memory.c        |    5 ++++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6522ae4..e57190f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -771,12 +771,14 @@ struct zap_details {
 	pgoff_t last_index;			/* Highest page->index to unmap */
 	spinlock_t *i_mmap_lock;		/* For unmap_mapping_range: */
 	unsigned long truncate_count;		/* Compare vm_truncate_count */
+	bool ignore_references;			/* For page activation */
 };
 
 #define __ZAP_DETAILS_INITIALIZER(name) \
                 { .nonlinear_vma = NULL \
 		, .check_mapping = NULL \
-		, .i_mmap_lock = NULL }
+		, .i_mmap_lock = NULL	\
+		, .ignore_references = false }
 
 #define DEFINE_ZAP_DETAILS(name)		\
 	struct zap_details name = __ZAP_DETAILS_INITIALIZER(name)
diff --git a/mm/madvise.c b/mm/madvise.c
index bfa17aa..8e7aba3 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -163,6 +163,7 @@ static long madvise_dontneed(struct vm_area_struct * vma,
 			     unsigned long start, unsigned long end)
 {
 	DEFINE_ZAP_DETAILS(details);
+	details.ignore_references = true;
 
 	*prev = vma;
 	if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
@@ -173,10 +174,9 @@ static long madvise_dontneed(struct vm_area_struct * vma,
 		details.last_index = ULONG_MAX;
 
 		zap_page_range(vma, start, end - start, &details);
-	} else {
-
+	} else
 		zap_page_range(vma, start, end - start, &details);
-	}
+
 	return 0;
 }
 
diff --git a/mm/memory.c b/mm/memory.c
index c0879bb..44d87e1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -897,6 +897,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 	pte_t *pte;
 	spinlock_t *ptl;
 	int rss[NR_MM_COUNTERS];
+	bool ignore_references = details->ignore_references;
 
 	init_rss_vec(rss);
 
@@ -952,7 +953,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 				if (pte_dirty(ptent))
 					set_page_dirty(page);
 				if (pte_young(ptent) &&
-				    likely(!VM_SequentialReadHint(vma)))
+				    likely(!VM_SequentialReadHint(vma)) &&
+					!ignore_references)
 					mark_page_accessed(page);
 				rss[MM_FILEPAGES]--;
 			}
@@ -1218,6 +1220,7 @@ int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
 		unsigned long size)
 {
 	DEFINE_ZAP_DETAILS(details);
+	details.ignore_references = true;
 	if (address < vma->vm_start || address + size > vma->vm_end ||
 	    		!(vma->vm_flags & VM_PFNMAP))
 		return -1;
-- 
1.7.0.4

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v4 0/7] f/madivse(DONTNEED) support, Minchan Kim, (Sun Dec 5, 10:29 am)
[PATCH v4 1/7] Fix checkpatch's report in swap.c, Minchan Kim, (Sun Dec 5, 10:29 am)
[PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Sun Dec 5, 10:29 am)
[PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Sun Dec 5, 10:29 am)
[PATCH v4 6/7] Remove zap_details NULL dependency, Minchan Kim, (Sun Dec 5, 10:29 am)
[PATCH v4 7/7] Prevent activation of page in madvise_dontneed, Minchan Kim, (Sun Dec 5, 10:29 am)
Re: [PATCH v4 1/7] Fix checkpatch's report in swap.c, Rik van Riel, (Sun Dec 5, 6:47 pm)
Re: [PATCH v4 6/7] Remove zap_details NULL dependency, Rik van Riel, (Sun Dec 5, 8:25 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, Mel Gorman, (Mon Dec 6, 7:53 am)
Re: [PATCH v4 6/7] Remove zap_details NULL dependency, Hugh Dickins, (Mon Dec 6, 9:26 pm)
Re: [PATCH v4 6/7] Remove zap_details NULL dependency, Minchan Kim, (Mon Dec 6, 10:30 pm)
Re: [PATCH v4 1/7] Fix checkpatch's report in swap.c, Johannes Weiner, (Tue Dec 7, 7:37 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Johannes Weiner, (Tue Dec 7, 7:49 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Johannes Weiner, (Tue Dec 7, 8:05 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Tue Dec 7, 8:07 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Johannes Weiner, (Tue Dec 7, 8:19 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Tue Dec 7, 8:21 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Tue Dec 7, 8:26 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Johannes Weiner, (Tue Dec 7, 8:56 am)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Tue Dec 7, 3:51 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, KAMEZAWA Hiroyuki, (Tue Dec 7, 5:56 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Tue Dec 7, 6:43 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, KAMEZAWA Hiroyuki, (Tue Dec 7, 6:56 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Tue Dec 7, 7:15 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, Balbir Singh, (Tue Dec 7, 11:56 pm)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, KOSAKI Motohiro, (Wed Dec 8, 1:04 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Wed Dec 8, 1:16 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Ben Gamari, (Wed Dec 8, 6:01 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Wed Dec 8, 4:10 pm)
Re: [PATCH v4 2/7] deactivate invalidated pages, Minchan Kim, (Wed Dec 8, 5:19 pm)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Mon Dec 13, 8:31 am)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Ben Gamari, (Mon Dec 13, 1:06 pm)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, KAMEZAWA Hiroyuki, (Mon Dec 13, 7:07 pm)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Mon Dec 13, 7:34 pm)
Re: [PATCH v4 4/7] Reclaim invalidated page ASAP, Minchan Kim, (Mon Dec 13, 7:36 pm)