linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch, feature] nonlinear mappings, prefaulting support, 2.5.42-F8
Date: Mon, 14 Oct 2002 14:02:34 -0700	[thread overview]
Message-ID: <20021014210234.GE4488@holomorphy.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0210141800160.9302-100000@localhost.localdomain>

On Mon, Oct 14, 2002 at 06:02:30PM +0200, Ingo Molnar wrote:
>> 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;
 

  reply	other threads:[~2002-10-14 21:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-14 12:38 [patch, feature] nonlinear mappings, prefaulting support, 2.5.42-F8 Ingo Molnar
2002-10-14 12:45 ` David S. Miller
2002-10-14 13:30   ` Ingo Molnar
2002-10-14 13:18     ` David S. Miller
2002-10-14 13:52 ` William Lee Irwin III
2002-10-14 15:02   ` Ingo Molnar
2002-10-14 15:15     ` Ingo Molnar
2002-10-14 15:20     ` William Lee Irwin III
2002-10-14 15:52       ` Ingo Molnar
2002-10-14 16:02         ` Ingo Molnar
2002-10-14 21:02           ` William Lee Irwin III [this message]
2002-10-14 21:20           ` William Lee Irwin III
2002-10-14 21:25             ` William Lee Irwin III
2002-10-14 20:27 ` Andrew Morton
2002-10-15  1:18 ` Jamie Lokier
2002-10-15  6:48   ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021014210234.GE4488@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).