rpms/kernel/F-10 linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch, NONE, 1.1 kernel.spec, 1.1359, 1.1360 linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch, 1.1, 1.2

Chuck Ebbert cebbert at fedoraproject.org
Sat May 9 07:12:36 UTC 2009


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv9378

Modified Files:
	kernel.spec 
	linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch 
Added Files:
	linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch 
Log Message:
Add less-intrusive version of the mm patch to prevent executable
  pages from being deactivated.

linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch:

--- NEW FILE linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch ---
vmscan: report vm_flags in page_referenced()

This enables more informed reclaim heuristics, eg. to protect executable
file pages more aggressively.

Signed-off-by: Wu Fengguang <fengguang.wu at intel.com>
---

--- linux.orig/include/linux/rmap.h
+++ linux/include/linux/rmap.h
@@ -83,7 +83,8 @@  static inline void page_dup_rmap(struct 
 /*
  * Called from mm/vmscan.c to handle paging out
  */
-int page_referenced(struct page *, int is_locked, struct mem_cgroup *cnt);
+int page_referenced(struct page *, int is_locked,
+			struct mem_cgroup *cnt, unsigned long *vm_flags);
 int try_to_unmap(struct page *, int ignore_refs);
 
 /*
@@ -128,7 +129,7 @@  int page_wrprotect(struct page *page, in
 #define anon_vma_prepare(vma)	(0)
 #define anon_vma_link(vma)	do {} while (0)
 
-#define page_referenced(page,l,cnt) TestClearPageReferenced(page)
+#define page_referenced(page, locked, cnt, flags) TestClearPageReferenced(page)
 #define try_to_unmap(page, refs) SWAP_FAIL
 
 static inline int page_mkclean(struct page *page)
--- linux.orig/mm/rmap.c
+++ linux/mm/rmap.c
@@ -333,7 +333,8 @@  static int page_mapped_in_vma(struct pag
  * repeatedly from either page_referenced_anon or page_referenced_file.
  */
 static int page_referenced_one(struct page *page,
-	struct vm_area_struct *vma, unsigned int *mapcount)
+			       struct vm_area_struct *vma,
+			       unsigned int *mapcount)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long address;
@@ -385,7 +386,8 @@  out:
 }
 
 static int page_referenced_anon(struct page *page,
-				struct mem_cgroup *mem_cont)
+				struct mem_cgroup *mem_cont,
+				unsigned long *vm_flags)
 {
 	unsigned int mapcount;
 	struct anon_vma *anon_vma;
@@ -406,6 +408,7 @@  static int page_referenced_anon(struct p
 		if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
 			continue;
 		referenced += page_referenced_one(page, vma, &mapcount);
+		*vm_flags |= vma->vm_flags;
 		if (!mapcount)
 			break;
 	}
@@ -418,6 +421,7 @@  static int page_referenced_anon(struct p
  * page_referenced_file - referenced check for object-based rmap
  * @page: the page we're checking references on.
  * @mem_cont: target memory controller
+ * @vm_flags: collect the encountered vma->vm_flags
  *
  * For an object-based mapped page, find all the places it is mapped and
  * check/clear the referenced flag.  This is done by following the page->mapping
@@ -427,7 +431,8 @@  static int page_referenced_anon(struct p
  * This function is only called from page_referenced for object-based pages.
  */
 static int page_referenced_file(struct page *page,
-				struct mem_cgroup *mem_cont)
+				struct mem_cgroup *mem_cont,
+				unsigned long *vm_flags)
 {
 	unsigned int mapcount;
 	struct address_space *mapping = page->mapping;
@@ -468,6 +473,7 @@  static int page_referenced_file(struct p
 		if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
 			continue;
 		referenced += page_referenced_one(page, vma, &mapcount);
+		*vm_flags |= vma->vm_flags;
 		if (!mapcount)
 			break;
 	}
@@ -481,29 +487,35 @@  static int page_referenced_file(struct p
  * @page: the page to test
  * @is_locked: caller holds lock on the page
  * @mem_cont: target memory controller
+ * @vm_flags: collect the encountered vma->vm_flags
  *
  * Quick test_and_clear_referenced for all mappings to a page,
  * returns the number of ptes which referenced the page.
  */
-int page_referenced(struct page *page, int is_locked,
-			struct mem_cgroup *mem_cont)
+int page_referenced(struct page *page,
+		    int is_locked,
+		    struct mem_cgroup *mem_cont,
+		    unsigned long *vm_flags)
 {
 	int referenced = 0;
 
 	if (TestClearPageReferenced(page))
 		referenced++;
 
+	*vm_flags = 0;
 	if (page_mapped(page) && page->mapping) {
 		if (PageAnon(page))
-			referenced += page_referenced_anon(page, mem_cont);
+			referenced += page_referenced_anon(page, mem_cont,
+								vm_flags);
 		else if (is_locked)
-			referenced += page_referenced_file(page, mem_cont);
+			referenced += page_referenced_file(page, mem_cont,
+								vm_flags);
 		else if (!trylock_page(page))
 			referenced++;
 		else {
 			if (page->mapping)
-				referenced +=
-					page_referenced_file(page, mem_cont);
+				referenced += page_referenced_file(page,
+							mem_cont, vm_flags);
 			unlock_page(page);
 		}
 	}
--- linux.orig/mm/vmscan.c
+++ linux/mm/vmscan.c
@@ -598,6 +598,7 @@  static unsigned long shrink_page_list(st
 	struct pagevec freed_pvec;
 	int pgactivate = 0;
 	unsigned long nr_reclaimed = 0;
+	unsigned long vm_flags;
 
 	cond_resched();
 
@@ -648,7 +649,8 @@  static unsigned long shrink_page_list(st
 				goto keep_locked;
 		}
 
-		referenced = page_referenced(page, 1, sc->mem_cgroup);
+		referenced = page_referenced(page, 1,
+						sc->mem_cgroup, &vm_flags);
 		/* In active use or really unfreeable?  Activate it. */
 		if (sc->order <= PAGE_ALLOC_COSTLY_ORDER &&
 					referenced && page_mapping_inuse(page))
@@ -1229,6 +1231,7 @@  static void shrink_active_list(unsigned 
 	unsigned long pgmoved;
 	int pgdeactivate = 0;
 	unsigned long pgscanned;
+	unsigned long vm_flags;
 	LIST_HEAD(l_hold);	/* The pages which were snipped off */
 	LIST_HEAD(l_inactive);
 	struct page *page;
@@ -1269,7 +1272,7 @@  static void shrink_active_list(unsigned 
 
 		/* page_referenced clears PageReferenced */
 		if (page_mapping_inuse(page) &&
-		    page_referenced(page, 0, sc->mem_cgroup))
+		    page_referenced(page, 0, sc->mem_cgroup, &vm_flags))
 			pgmoved++;
 
 		list_add(&page->lru, &l_inactive);



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/kernel.spec,v
retrieving revision 1.1359
retrieving revision 1.1360
diff -u -p -r1.1359 -r1.1360
--- kernel.spec	9 May 2009 03:37:40 -0000	1.1359
+++ kernel.spec	9 May 2009 07:12:05 -0000	1.1360
@@ -597,7 +597,8 @@ Patch41: linux-2.6-sysrq-c.patch
 
 Patch81: linux-2.6-defaults-saner-vm-settings.patch
 Patch90: linux-2.6-mm-lru-evict-streaming-io-pages-first.patch
-Patch91: linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch
+Patch91: linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch
+Patch92: linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch
 
 Patch140: linux-2.6-ps3-ehci-iso.patch
 Patch141: linux-2.6-ps3-storage-alias.patch
@@ -1143,6 +1144,7 @@ ApplyPatch linux-2.6-sysrq-c.patch
 
 ApplyPatch linux-2.6-defaults-saner-vm-settings.patch
 ApplyPatch linux-2.6-mm-lru-evict-streaming-io-pages-first.patch
+ApplyPatch linux-2.6-mm-lru-report-vm-flags-in-page-referenced.patch
 ApplyPatch linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch
 
 # Architecture patches
@@ -1924,6 +1926,10 @@ fi
 %kernel_variant_files -k vmlinux %{with_kdump} kdump
 
 %changelog
+* Sat May 09 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.29.3-60
+- Add less-intrusive version of the mm patch to prevent executable
+  pages from being deactivated.
+
 * Fri May 08 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.29.3-59
 - Linux 2.6.29.3
 - Dropped patches, merged upstream:

linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch:

Index: linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch	8 May 2009 00:04:08 -0000	1.1
+++ linux-2.6-mm-lru-dont-evict-mapped-executable-pages.patch	9 May 2009 07:12:05 -0000	1.2
@@ -1,107 +1,65 @@
-Subject: [PATCH -mm] vmscan: make mapped executable pages the first class citizen
+vmscan: make mapped executable pages the first class citizen
 
-Date: Thu, 7 May 2009 20:11:01 +0800
-From: Wu Fengguang <fengguang wu intel com>
-To: Andrew Morton <akpm linux-foundation org>
+Protect referenced PROT_EXEC mapped pages from being deactivated.
 
-CC: Peter Zijlstra <peterz infradead org>, Rik van Riel <riel redhat com>, "linux-kernel vger kernel org" <linux-kernel vger kernel org>, "tytso mit edu" <tytso mit edu>, "linux-mm kvack org" <linux-mm kvack org>, Elladan <elladan eskimo com>, Nick Piggin <npiggin suse de>, Johannes Weiner <hannes cmpxchg org>, Christoph Lameter <cl linux-foundation org>, KOSAKI Motohiro <kosaki motohiro jp fujitsu com> References: <20090430072057 GA4663 eskimo com> <20090430174536 d0f438dd akpm linux-foundation org> <20090430205936 0f8b29fc riellaptop surriel com> <20090430181340 6f07421d akpm linux-foundation org> <20090430215034 4748e615 riellaptop surriel com> <20090430195439 e02edc26 akpm linux-foundation org> <49FB01C1 6050204 redhat com> <20090501123541 7983a8ae akpm linux-foundation org> <20090503031539 GC5702 localhost> <1241432635 7620 4732 camel twins>
-
-Introduce AS_EXEC to mark executables and their linked libraries, and to
-protect their referenced active pages from being deactivated.
-
-CC: Elladan <elladan eskimo com>
-CC: Nick Piggin <npiggin suse de>
-CC: Johannes Weiner <hannes cmpxchg org>
-CC: Christoph Lameter <cl linux-foundation org>
-CC: KOSAKI Motohiro <kosaki motohiro jp fujitsu com>
-Acked-by: Peter Zijlstra <peterz infradead org>
-Acked-by: Rik van Riel <riel redhat com>
-Signed-off-by: Wu Fengguang <fengguang wu intel com>
+PROT_EXEC(or its internal presentation VM_EXEC) pages normally belong to some
+currently running executables and their linked libraries, they shall really be
+cached aggressively to provide good user experiences.
+
+CC: Elladan <elladan at eskimo.com>
+CC: Nick Piggin <npiggin at suse.de>
+CC: Johannes Weiner <hannes at cmpxchg.org>
+CC: Christoph Lameter <cl at linux-foundation.org>
+CC: KOSAKI Motohiro <kosaki.motohiro at jp.fujitsu.com>
+Acked-by: Peter Zijlstra <peterz at infradead.org>
+Acked-by: Rik van Riel <riel at redhat.com>
+Signed-off-by: Wu Fengguang <fengguang.wu at intel.com>
 ---
- include/linux/pagemap.h |    1 +
- mm/mmap.c               |    2 ++
- mm/nommu.c              |    2 ++
- mm/vmscan.c             |   35 +++++++++++++++++++++++++++++++++--
- 4 files changed, 38 insertions(+), 2 deletions(-)
-
---- linux.orig/include/linux/pagemap.h
-+++ linux/include/linux/pagemap.h
-@@ -25,6 +25,7 @@ enum mapping_flags {
- #ifdef CONFIG_UNEVICTABLE_LRU
- 	AS_UNEVICTABLE	= __GFP_BITS_SHIFT + 3,	/* e.g., ramdisk, SHM_LOCK */
- #endif
-+	AS_EXEC		= __GFP_BITS_SHIFT + 4,	/* mapped PROT_EXEC somewhere */
- };
-
-
-static inline void mapping_set_error(struct address_space *mapping, int error)
-
---- linux.orig/mm/mmap.c
-+++ linux/mm/mmap.c
-@@ -1194,6 +1194,8 @@ munmap_back:
- 			goto unmap_and_free_vma;
- 		if (vm_flags & VM_EXECUTABLE)
- 			added_exe_file_vma(mm);
-+		if (vm_flags & VM_EXEC)
-+			set_bit(AS_EXEC, &file->f_mapping->flags);
- 	} else if (vm_flags & VM_SHARED) {
- 		error = shmem_zero_setup(vma);
- 		if (error)
---- linux.orig/mm/nommu.c
-+++ linux/mm/nommu.c
-@@ -1224,6 +1224,8 @@ unsigned long do_mmap_pgoff(struct file
- 			added_exe_file_vma(current->mm);
- 			vma->vm_mm = current->mm;
- 		}
-+		if (vm_flags & VM_EXEC)
-+			set_bit(AS_EXEC, &file->f_mapping->flags);
- 	}
+ mm/vmscan.c |   33 +++++++++++++++++++++++++++++++--
+ 1 file changed, 31 insertions(+), 2 deletions(-)
 
- 	down_write(&nommu_region_sem);
 --- linux.orig/mm/vmscan.c
 +++ linux/mm/vmscan.c
-@@ -1230,6 +1230,7 @@ static void shrink_active_list(unsigned
- 	unsigned long pgmoved;
+@@ -1233,6 +1233,7 @@ static void shrink_active_list(unsigned 
  	unsigned long pgscanned;
+ 	unsigned long vm_flags;
  	LIST_HEAD(l_hold);	/* The pages which were snipped off */
 +	LIST_HEAD(l_active);
  	LIST_HEAD(l_inactive);
  	struct page *page;
  	struct pagevec pvec;
-@@ -1269,8 +1270,15 @@ static void shrink_active_list(unsigned
-
+@@ -1272,8 +1273,13 @@ static void shrink_active_list(unsigned 
+ 
  		/* page_referenced clears PageReferenced */
  		if (page_mapping_inuse(page) &&
--		    page_referenced(page, 0, sc->mem_cgroup))
-+		    page_referenced(page, 0, sc->mem_cgroup)) {
-+			struct address_space *mapping = page_mapping(page);
-+
+-		    page_referenced(page, 0, sc->mem_cgroup, &vm_flags))
++		    page_referenced(page, 0, sc->mem_cgroup, &vm_flags)) {
  			pgmoved++;
-+			if (mapping && test_bit(AS_EXEC, &mapping->flags)) {
++			if ((vm_flags & VM_EXEC) && !PageAnon(page)) {
 +				list_add(&page->lru, &l_active);
 +				continue;
 +			}
 +		}
-
+ 
  		list_add(&page->lru, &l_inactive);
  	}
-@@ -1279,7 +1287,6 @@ static void shrink_active_list(unsigned
+@@ -1282,7 +1288,6 @@ static void shrink_active_list(unsigned 
  	 * Move the pages to the [file or anon] inactive list.
  	 */
  	pagevec_init(&pvec, 1);
 -	lru = LRU_BASE + file * LRU_FILE;
-
+ 
  	spin_lock_irq(&zone->lru_lock);
  	/*
-@@ -1291,6 +1298,7 @@ static void shrink_active_list(unsigned
+@@ -1294,6 +1299,7 @@ static void shrink_active_list(unsigned 
  	reclaim_stat->recent_rotated[!!file] += pgmoved;
-
+ 
  	pgmoved = 0;
 +	lru = LRU_BASE + file * LRU_FILE;
  	while (!list_empty(&l_inactive)) {
  		page = lru_to_page(&l_inactive);
  		prefetchw_prev_lru_page(page, &l_inactive, flags);
-@@ -1313,6 +1321,29 @@ static void shrink_active_list(unsigned
+@@ -1316,6 +1322,29 @@ static void shrink_active_list(unsigned 
  	}
  	__count_zone_vm_events(PGREFILL, zone, pgscanned);
  	__count_vm_events(PGDEACTIVATE, pgdeactivate);
@@ -131,3 +89,4 @@ static inline void mapping_set_error(str
  	spin_unlock_irq(&zone->lru_lock);
  	if (vm_swap_full())
  		pagevec_swap_free(&pvec);
+




More information about the fedora-extras-commits mailing list