Thread (16 messages) 16 messages, 6 authors, 2002-10-15

Re: [patch, feature] nonlinear mappings, prefaulting support, 2.5.42-F8

From: William Lee Irwin III <hidden>
Date: 2002-10-14 21:00:46
Also in: lkml

On Mon, Oct 14, 2002 at 06:02:30PM +0200, Ingo Molnar wrote:
quoted
if this is really an issue then we could force vma->vm_page_prot to
PROT_NONE within remap_file_pages(), so at least all subsequent faults
will be PROT_NONE and the user would have to explicitly re-mprotect()
the vma again to change this.
i've added this to the -G1 patch at:
        http://redhat.com/~mingo/remap-file-pages-patches/
    Ingo
Okay, if PROT_NONE is in there, my last remaining concern would be
solved by invalidating the pte's of failed nonblocking prefaults.

A nonblocking remapping done "over the top" of a preexisting mapping
(such as would occur with MAP_LOCKED) may fail at unpredictable times,
which is fine from the kernel point of view but leaves userspace with
no way of telling which pages that it requested to be prefaulted
actually made it in, and which pages are residue from the prior mapping.

Basically something like this would solve this API semantics issue
(totally untested). Against mpopulate-2.5.42-G1


diff -urpN mpop-2.5.42/include/linux/mm.h wlipop-2.5.42/include/linux/mm.h
--- mpop-2.5.42/include/linux/mm.h	2002-10-14 11:43:03.000000000 -0700
+++ wlipop-2.5.42/include/linux/mm.h	2002-10-14 12:26:27.000000000 -0700
@@ -424,6 +424,7 @@ static inline pmd_t *pmd_alloc(struct mm
 	return pmd_offset(pgd, address);
 }
 
+extern void zap_pte(struct mm_struct *, pte_t *);
 extern void free_area_init(unsigned long * zones_size);
 extern void free_area_init_node(int nid, pg_data_t *pgdat, struct page *pmap,
 	unsigned long * zones_size, unsigned long zone_start_pfn, 
diff -urpN mpop-2.5.42/mm/filemap.c wlipop-2.5.42/mm/filemap.c
--- mpop-2.5.42/mm/filemap.c	2002-10-14 11:43:03.000000000 -0700
+++ wlipop-2.5.42/mm/filemap.c	2002-10-14 12:12:08.000000000 -0700
@@ -1286,9 +1286,27 @@ repeat:
 		return -EINVAL;
 
 	page = filemap_getpage(file, pgoff, nonblock);
-	if (!page && !nonblock)
-		return -ENOMEM;
-	if (page) {
+
+	if (!page) {
+		pgd_t *pgd;
+
+		if (!nonblock)
+			return -ENOMEM;
+
+		spin_lock(&mm->page_table_lock);
+		pgd = pgd_offset(mm, addr);
+		if (!pgd_none(*pgd) && !pgd_bad(*pgd)) {
+			pmd_t *pmd = pmd_offset(pgd, addr);
+			if (!pmd_none(*pmd) && !pmd_bad(*pmd)) {
+				pte_t *pte = pte_offset_map(pmd, addr);
+				if (pte) {
+					zap_pte(mm, pte);
+					pte_unmap(pte);
+				}
+			}
+		}
+		spin_unlock(&mm->page_table_lock);
+	} else {
 		err = install_page(mm, vma, addr, page, prot);
 		if (err)
 			return err;
diff -urpN mpop-2.5.42/mm/fremap.c wlipop-2.5.42/mm/fremap.c
--- mpop-2.5.42/mm/fremap.c	2002-10-14 11:43:03.000000000 -0700
+++ wlipop-2.5.42/mm/fremap.c	2002-10-14 12:26:37.000000000 -0700
@@ -13,7 +13,7 @@
 #include <linux/swapops.h>
 #include <asm/mmu_context.h>
 
-static inline void zap_pte(struct mm_struct *mm, pte_t *ptep)
+void zap_pte(struct mm_struct *mm, pte_t *ptep)
 {
 	pte_t pte = *ptep;
 
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help