linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jack Steiner <steiner@sgi.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Subject: [PATCH] - GRU virtual -> physical translation
Date: Wed, 9 Jul 2008 14:14:39 -0500	[thread overview]
Message-ID: <20080709191439.GA7307@sgi.com> (raw)

Open code the equivalent to follow_page(). This eliminates the
requirement for an EXPORT of follow_page(). In addition, the code
is optimized for the specific case that is needed by the GRU and only
supports architectures supported by the GRU (ia64 & x86_64).

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

---

Andrew - do you want incremental patches or should I repost a V4 of
the original GRU driver.

After the GRU code is stabilized, I'll look into moving the open codes
PT lookup code into the kernel.


 drivers/misc/sgi-gru/grufault.c |   54 +++++++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 9 deletions(-)

Index: linux/drivers/misc/sgi-gru/grufault.c
===================================================================
--- linux.orig/drivers/misc/sgi-gru/grufault.c	2008-07-09 13:54:16.786142769 -0500
+++ linux/drivers/misc/sgi-gru/grufault.c	2008-07-09 13:56:58.762219264 -0500
@@ -213,20 +213,56 @@ static int non_atomic_pte_lookup(struct 
 	return 0;
 }
 
+/*
+ *
+ * atomic_pte_lookup
+ *
+ * Convert a user virtual address to a physical address
+ * Only supports Intel large pages (2MB only) on x86_64.
+ *	ZZZ - hugepage support is incomplete
+ */
 static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
-			     int write, unsigned long *paddr, int *pageshift)
+	int write, unsigned long *paddr, int *pageshift)
 {
-	struct page *page;
+	pgd_t *pgdp;
+	pmd_t *pmdp;
+	pud_t *pudp;
+	pte_t pte;
+
+	WARN_ON(irqs_disabled());		/* ZZZ debug */
+
+	local_irq_disable();
+	pgdp = pgd_offset(vma->vm_mm, vaddr);
+	if (unlikely(pgd_none(*pgdp)))
+		goto err;
+
+	pudp = pud_offset(pgdp, vaddr);
+	if (unlikely(pud_none(*pudp)))
+		goto err;
+
+	pmdp = pmd_offset(pudp, vaddr);
+	if (unlikely(pmd_none(*pmdp)))
+		goto err;
+#ifdef CONFIG_X86_64
+	if (unlikely(pmd_large(*pmdp)))
+		pte = *(pte_t *) pmdp;
+	else
+#endif
+		pte = *pte_offset_kernel(pmdp, vaddr);
 
-	/* ZZZ Need to handle HUGE pages */
-	if (is_vm_hugetlb_page(vma))
-		return -EFAULT;
-	*pageshift = PAGE_SHIFT;
-	page = follow_page(vma, vaddr, (write ? FOLL_WRITE : 0));
-	if (!page)
+	local_irq_enable();
+
+	if (unlikely(!pte_present(pte) ||
+		     (write && (!pte_write(pte) || !pte_dirty(pte)))))
 		return 1;
-	*paddr = page_to_phys(page);
+
+	*paddr = pte_pfn(pte) << PAGE_SHIFT;
+	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
 	return 0;
+
+err:
+	local_irq_enable();
+	return 1;
 }
 
 /*

--
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>

             reply	other threads:[~2008-07-09 19:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 19:14 Jack Steiner [this message]
2008-07-11 19:17 ` Andrew Morton
2008-07-14 14:52   ` Jack Steiner
2008-07-14 16:24     ` Andrew Morton
2008-07-14 16:31       ` Jack Steiner
2008-07-14 19:50         ` Robin Holt
2008-07-14 20:01           ` Jack Steiner
2008-07-14 20:37           ` Hugh Dickins
2008-07-14 21:52             ` Jack Steiner

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=20080709191439.GA7307@sgi.com \
    --to=steiner@sgi.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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