linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jack Steiner <steiner@sgi.com>
To: Christoph Hellwig <hch@infradead.org>,
	cl@linux-foundation.org, hugh@veritas.com
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, mingo@elte.hu,
	tglx@linutronix.de, holt@sgi.com, andrea@qumranet.com,
	linux-mm@kvack.org
Subject: Re: [patch 12/13] GRU Driver V3 -  export is_uv_system(), zap_page_range() & follow_page()
Date: Mon, 7 Jul 2008 12:58:58 -0500	[thread overview]
Message-ID: <20080707175858.GA1927@sgi.com> (raw)
In-Reply-To: <20080704073926.GA1449@infradead.org>

On Fri, Jul 04, 2008 at 03:39:26AM -0400, Christoph Hellwig wrote:
> On Thu, Jul 03, 2008 at 04:34:00PM -0500, steiner@sgi.com wrote:
> > +EXPORT_SYMBOL_GPL(zap_page_range);
> >  
> 
> NACK.
> 

I agree that zap_pages_range() is more general than what is needed.

How about the following. This should prevent abuse of the API &
provide what (I think) drivers need.

Verified with GRU & XPMEM.


--- jack

--------------------------------------------------------------------------------------------
Add function to unmap driver ptes.

zap_vma_ptes() is intended to be used by drivers to unmap
ptes assigned to the driver private vmas. This interface is
similar to zap_page_range() but is less general & less likely to
be abused.


Signed-off-by: Jack Steiner <steiner@sgi.com>

---
 include/linux/mm.h |    2 ++
 mm/memory.c        |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

Index: linux/include/linux/mm.h
===================================================================
--- linux.orig/include/linux/mm.h	2008-07-07 12:22:17.809892803 -0500
+++ linux/include/linux/mm.h	2008-07-07 12:22:56.126695482 -0500
@@ -742,6 +742,8 @@ struct zap_details {
 struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 		pte_t pte);
 
+int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
+		unsigned long size);
 unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
 		unsigned long size, struct zap_details *);
 unsigned long unmap_vmas(struct mmu_gather **tlb,
Index: linux/mm/memory.c
===================================================================
--- linux.orig/mm/memory.c	2008-07-07 12:22:18.357961503 -0500
+++ linux/mm/memory.c	2008-07-07 12:31:51.097688882 -0500
@@ -978,6 +978,29 @@ unsigned long zap_page_range(struct vm_a
 }
 EXPORT_SYMBOL_GPL(zap_page_range);
 
+/**
+ * zap_vma_ptes - remove ptes mapping the vma
+ * @vma: vm_area_struct holding ptes to be zapped
+ * @address: starting address of pages to zap
+ * @size: number of bytes to zap
+ *
+ * This function only unmaps ptes assigned to VM_PFNMAP vmas.
+ *
+ * The entire address range must be fully contained within the vma.
+ *
+ * Returns 0 if successful.
+ */
+int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
+		unsigned long size)
+{
+	if (address < vma->vm_start || address + size > vma->vm_end ||
+	    		!(vma->vm_flags & VM_PFNMAP))
+		return -1;
+	zap_page_range(vma, address, size, NULL);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zap_vma_ptes);
+
 /*
  * Do a quick page-table lookup for a single page.
  */

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      parent reply	other threads:[~2008-07-07 17:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080703213348.489120321@attica.americas.sgi.com>
     [not found] ` <20080703213633.890647632@attica.americas.sgi.com>
     [not found]   ` <20080704073926.GA1449@infradead.org>
2008-07-07 14:39     ` Jack Steiner
2008-07-07 14:54       ` Andrea Arcangeli
2008-07-07 16:29       ` Hugh Dickins
2008-07-07 16:53         ` Jack Steiner
2008-07-08  2:16           ` Nick Piggin
2008-07-09 19:11             ` Jack Steiner
2008-07-10  7:31               ` Nick Piggin
2008-07-10 13:29                 ` Jack Steiner
2008-07-10 14:21                   ` Nick Piggin
2008-07-10 16:33                     ` Jack Steiner
2008-07-10 16:52                       ` Nick Piggin
2008-07-10 17:20                         ` Jack Steiner
2008-07-11  3:30                           ` Nick Piggin
2008-07-07 18:58         ` Arjan van de Ven
2008-07-07 19:29           ` Jack Steiner
2008-07-07 21:03             ` Andrea Arcangeli
2008-07-07 17:58     ` Jack Steiner [this message]

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=20080707175858.GA1927@sgi.com \
    --to=steiner@sgi.com \
    --cc=akpm@osdl.org \
    --cc=andrea@qumranet.com \
    --cc=cl@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=holt@sgi.com \
    --cc=hugh@veritas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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