+ read-write-migration-entries-make-mprotect-convert-write-migration.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     Read/Write migration entries: Make mprotect() convert write migration entries to read

has been added to the -mm tree.  Its filename is

     read-write-migration-entries-make-mprotect-convert-write-migration.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Christoph Lameter <clameter@xxxxxxx>

1. Introduce a new function make_migration_entry() to
   isolate common code between copy_pte_range and change_pte_range.

2. Modify change_pte_range() to check for a migration entry.
   If a write migration entry is found and there is a request for
   a READ permissions then change the migration entry.

I am a bit concerned about the check of newprot. Are there other
values than PAGE_READONLY that indicate read only access?

Signed-off-by: Christoph Lameter <clameter@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/swapops.h |    6 ++++++
 mm/memory.c             |    7 ++-----
 mm/mprotect.c           |   21 ++++++++++++++++++---
 3 files changed, 26 insertions(+), 8 deletions(-)

diff -puN include/linux/swapops.h~read-write-migration-entries-make-mprotect-convert-write-migration include/linux/swapops.h
--- devel/include/linux/swapops.h~read-write-migration-entries-make-mprotect-convert-write-migration	2006-04-20 22:56:38.000000000 -0700
+++ devel-akpm/include/linux/swapops.h	2006-04-20 22:56:38.000000000 -0700
@@ -98,6 +98,11 @@ static inline struct page *migration_ent
 	return p;
 }
 
+static inline void make_migration_entry_read(swp_entry_t *entry)
+{
+	*entry = swp_entry(SWP_MIGRATION_READ, swp_offset(*entry));
+}
+
 extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
 					unsigned long address);
 #else
@@ -105,6 +110,7 @@ extern void migration_entry_wait(struct 
 #define make_migration_entry(page, write) swp_entry(0, 0)
 #define is_migration_entry(swp) 0
 #define migration_entry_to_page(swp) NULL
+static inline void make_migration_entry_read(entryp) { }
 static inline void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
 					 unsigned long address) { }
 
diff -puN mm/memory.c~read-write-migration-entries-make-mprotect-convert-write-migration mm/memory.c
--- devel/mm/memory.c~read-write-migration-entries-make-mprotect-convert-write-migration	2006-04-20 22:56:38.000000000 -0700
+++ devel-akpm/mm/memory.c	2006-04-20 22:56:55.000000000 -0700
@@ -447,14 +447,11 @@ copy_one_pte(struct mm_struct *dst_mm, s
 			}
 			if (is_migration_entry(entry) &&
 					is_cow_mapping(vm_flags)) {
-				page = migration_entry_to_page(entry);
-
 				/*
 				 * COW mappings require pages in both parent
-				*  and child to be set to read.
+				 * and child to be set to read.
 				 */
-				entry = make_migration_entry(page,
-							SWP_MIGRATION_READ);
+				make_migration_entry_read(&entry);
 				pte = swp_entry_to_pte(entry);
 				set_pte_at(src_mm, addr, src_pte, pte);
 			}
diff -puN mm/mprotect.c~read-write-migration-entries-make-mprotect-convert-write-migration mm/mprotect.c
--- devel/mm/mprotect.c~read-write-migration-entries-make-mprotect-convert-write-migration	2006-04-20 22:56:38.000000000 -0700
+++ devel-akpm/mm/mprotect.c	2006-04-20 22:56:38.000000000 -0700
@@ -19,6 +19,8 @@
 #include <linux/mempolicy.h>
 #include <linux/personality.h>
 #include <linux/syscalls.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -28,22 +30,35 @@
 static void change_pte_range(struct mm_struct *mm, pmd_t *pmd,
 		unsigned long addr, unsigned long end, pgprot_t newprot)
 {
-	pte_t *pte;
+	pte_t *pte, oldpte;
 	spinlock_t *ptl;
 
 	pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
 	do {
-		if (pte_present(*pte)) {
+		oldpte = *pte;
+		if (pte_present(oldpte)) {
 			pte_t ptent;
 
 			/* Avoid an SMP race with hardware updated dirty/clean
 			 * bits by wiping the pte and then setting the new pte
 			 * into place.
 			 */
-			ptent = pte_modify(ptep_get_and_clear(mm, addr, pte), newprot);
+			ptent = pte_modify(ptep_get_and_clear(mm, addr, pte),
+								newprot);
 			set_pte_at(mm, addr, pte, ptent);
 			lazy_mmu_prot_update(ptent);
+		} else
+		if (!pte_file(oldpte) && pgprot_val(newprot) ==
+						 pgprot_val(PAGE_READONLY)) {
+			swp_entry_t entry = pte_to_swp_entry(oldpte);
+
+			if (is_write_migration_entry(entry)) {
+				make_migration_entry_read(&entry);
+				set_pte_at(mm, addr, pte,
+					swp_entry_to_pte(entry));
+			}
 		}
+
 	} while (pte++, addr += PAGE_SIZE, addr != end);
 	pte_unmap_unlock(pte - 1, ptl);
 }
_

Patches currently in -mm which might be from clameter@xxxxxxx are

origin.patch
add-migratepage-address-space-op-to-shmem.patch
page-migration-make-do_swap_page-redo-the-fault.patch
slab-extract-cache_free_alien-from-__cache_free.patch
migration-remove-unnecessary-pageswapcache-checks.patch
migration-remove-unnecessary-pageswapcache-checks-fix.patch
swapless-v2-try_to_unmap-rename-ignrefs-to-migration.patch
swapless-v2-add-migration-swap-entries.patch
swapless-v2-make-try_to_unmap-create-migration-entries.patch
swapless-v2-rip-out-swap-portion-of-old-migration-code.patch
swapless-v2-revise-main-migration-logic.patch
wait-for-migrating-page-after-incr-of-page-count-under-anon_vma-lock.patch
preserve-write-permissions-in-migration-entries.patch
preserve-write-permissions-in-migration-entries-fix.patch
migration_entry_wait-use-the-pte-lock-instead-of-the-anon_vma-lock.patch
read-write-migration-entries-implement-correct-behavior-in-copy_one_pte.patch
read-write-migration-entries-make-mprotect-convert-write-migration.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux