linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Paul Davies <pauld@gelato.unsw.edu.au>
To: linux-mm@kvack.org
Cc: Paul Davies <pauld@gelato.unsw.edu.au>
Subject: [PATCH 10/29] Call simple PTI functions
Date: Sat, 13 Jan 2007 13:46:33 +1100	[thread overview]
Message-ID: <20070113024633.29682.34136.sendpatchset@weill.orchestra.cse.unsw.EDU.AU> (raw)
In-Reply-To: <20070113024540.29682.27024.sendpatchset@weill.orchestra.cse.unsw.EDU.AU>

PATCH 10 summary:
 * Remove implementation dependent page table lookup code from memory.c,
 rmap.c and filemap_xip.c and replace with interface defined lookup_page_table.
   * Leaves hugetlb undisturbed for the default page table implementation.
 * Adjust prototype in rmap.h to align with page table interface.

Signed-Off-By: Paul Davies <pauld@gelato.unsw.edu.au>

---

 include/linux/rmap.h |    3 +-
 mm/filemap_xip.c     |    7 +++--
 mm/memory.c          |   61 +++++++++++++++------------------------------------
 mm/rmap.c            |   52 ++++++++++++++++++-------------------------
 4 files changed, 47 insertions(+), 76 deletions(-)
Index: linux-2.6.20-rc3/mm/memory.c
===================================================================
--- linux-2.6.20-rc3.orig/mm/memory.c	2007-01-09 12:17:31.550257000 +1100
+++ linux-2.6.20-rc3/mm/memory.c	2007-01-09 12:18:09.418257000 +1100
@@ -844,11 +844,8 @@
 struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
 			unsigned int flags)
 {
-	pgd_t *pgd;
-	pud_t *pud;
-	pmd_t *pmd;
 	pte_t *ptep, pte;
-	spinlock_t *ptl;
+	pt_path_t pt_path;
 	struct page *page;
 	struct mm_struct *mm = vma->vm_mm;
 
@@ -859,25 +856,14 @@
 	}
 
 	page = NULL;
-	pgd = pgd_offset(mm, address);
-	if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
-		goto no_page_table;
-
-	pud = pud_offset(pgd, address);
-	if (pud_none(*pud) || unlikely(pud_bad(*pud)))
-		goto no_page_table;
-	
-	pmd = pmd_offset(pud, address);
-	if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
+	ptep = lookup_page_table(mm, address, &pt_path);
+	if (!ptep)
 		goto no_page_table;
 
-	if (pmd_huge(*pmd)) {
-		BUG_ON(flags & FOLL_GET);
-		page = follow_huge_pmd(mm, address, pmd, flags & FOLL_WRITE);
+	if(is_huge_page(mm, address, pt_path, flags, page))
 		goto out;
-	}
 
-	ptep = pte_offset_map_lock(mm, pmd, address, &ptl);
+	lock_pte(mm, pt_path);
 	if (!ptep)
 		goto out;
 
@@ -899,7 +885,8 @@
 		mark_page_accessed(page);
 	}
 unlock:
-	pte_unmap_unlock(ptep, ptl);
+	unlock_pte(mm, pt_path);
+	pte_unmap(ptep);
 out:
 	return page;
 
@@ -2426,29 +2413,19 @@
  */
 struct page * vmalloc_to_page(void * vmalloc_addr)
 {
-	unsigned long addr = (unsigned long) vmalloc_addr;
-	struct page *page = NULL;
-	pgd_t *pgd = pgd_offset_k(addr);
-	pud_t *pud;
-	pmd_t *pmd;
-	pte_t *ptep, pte;
-  
-	if (!pgd_none(*pgd)) {
-		pud = pud_offset(pgd, addr);
-		if (!pud_none(*pud)) {
-			pmd = pmd_offset(pud, addr);
-			if (!pmd_none(*pmd)) {
-				ptep = pte_offset_map(pmd, addr);
-				pte = *ptep;
-				if (pte_present(pte))
-					page = pte_page(pte);
-				pte_unmap(ptep);
-			}
-		}
-	}
-	return page;
+    unsigned long addr = (unsigned long) vmalloc_addr;
+    struct page *page = NULL;
+    pte_t *ptep, pte;
+
+    ptep = lookup_page_table(&init_mm, addr, NULL);
+    if(ptep) {
+        pte = *ptep;
+        if (pte_present(pte))
+            page = pte_page(pte);
+        pte_unmap(ptep);
+    }
+    return page;
 }
-
 EXPORT_SYMBOL(vmalloc_to_page);
 
 /*
Index: linux-2.6.20-rc3/mm/rmap.c
===================================================================
--- linux-2.6.20-rc3.orig/mm/rmap.c	2007-01-09 12:15:41.563902000 +1100
+++ linux-2.6.20-rc3/mm/rmap.c	2007-01-09 12:17:44.614257000 +1100
@@ -48,6 +48,7 @@
 #include <linux/rcupdate.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
+#include <linux/pt.h>
 
 #include <asm/tlbflush.h>
 
@@ -243,43 +244,30 @@
  * On success returns with pte mapped and locked.
  */
 pte_t *page_check_address(struct page *page, struct mm_struct *mm,
-			  unsigned long address, spinlock_t **ptlp)
+			  unsigned long address, pt_path_t *ppt_path)
 {
-	pgd_t *pgd;
-	pud_t *pud;
-	pmd_t *pmd;
 	pte_t *pte;
-	spinlock_t *ptl;
-
-	pgd = pgd_offset(mm, address);
-	if (!pgd_present(*pgd))
-		return NULL;
+	pt_path_t pt_path;
 
-	pud = pud_offset(pgd, address);
-	if (!pud_present(*pud))
+	pte = lookup_page_table(mm, address, &pt_path);
+	if(!pte)
 		return NULL;
 
-	pmd = pmd_offset(pud, address);
-	if (!pmd_present(*pmd))
-		return NULL;
-
-	pte = pte_offset_map(pmd, address);
 	/* Make a quick check before getting the lock */
 	if (!pte_present(*pte)) {
 		pte_unmap(pte);
 		return NULL;
 	}
 
-	ptl = pte_lockptr(mm, pmd);
-	spin_lock(ptl);
+	lock_pte(mm, pt_path);
 	if (pte_present(*pte) && page_to_pfn(page) == pte_pfn(*pte)) {
-		*ptlp = ptl;
+		set_pt_path(pt_path, ppt_path);
 		return pte;
 	}
-	pte_unmap_unlock(pte, ptl);
+	unlock_pte(mm, pt_path);
+	pte_unmap(pte);
 	return NULL;
 }
-
 /*
  * Subfunctions of page_referenced: page_referenced_one called
  * repeatedly from either page_referenced_anon or page_referenced_file.
@@ -290,14 +278,14 @@
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long address;
 	pte_t *pte;
-	spinlock_t *ptl;
 	int referenced = 0;
+	pt_path_t pt_path;
 
 	address = vma_address(page, vma);
 	if (address == -EFAULT)
 		goto out;
 
-	pte = page_check_address(page, mm, address, &ptl);
+	pte = page_check_address(page, mm, address, &pt_path);
 	if (!pte)
 		goto out;
 
@@ -311,7 +299,8 @@
 		referenced++;
 
 	(*mapcount)--;
-	pte_unmap_unlock(pte, ptl);
+	unlock_pte(mm, pt_path);
+	pte_unmap(pte);
 out:
 	return referenced;
 }
@@ -434,14 +423,14 @@
 	struct mm_struct *mm = vma->vm_mm;
 	unsigned long address;
 	pte_t *pte;
-	spinlock_t *ptl;
+	pt_path_t pt_path;
 	int ret = 0;
 
 	address = vma_address(page, vma);
 	if (address == -EFAULT)
 		goto out;
 
-	pte = page_check_address(page, mm, address, &ptl);
+	pte = page_check_address(page, mm, address, &pt_path);
 	if (!pte)
 		goto out;
 
@@ -457,7 +446,9 @@
 		ret = 1;
 	}
 
-	pte_unmap_unlock(pte, ptl);
+	unlock_pte(mm, pt_path);
+	pte_unmap(pte);
+
 out:
 	return ret;
 }
@@ -615,14 +606,14 @@
 	unsigned long address;
 	pte_t *pte;
 	pte_t pteval;
-	spinlock_t *ptl;
+	pt_path_t pt_path;
 	int ret = SWAP_AGAIN;
 
 	address = vma_address(page, vma);
 	if (address == -EFAULT)
 		goto out;
 
-	pte = page_check_address(page, mm, address, &ptl);
+	pte = page_check_address(page, mm, address, &pt_path);
 	if (!pte)
 		goto out;
 
@@ -693,7 +684,8 @@
 	page_cache_release(page);
 
 out_unmap:
-	pte_unmap_unlock(pte, ptl);
+	unlock_pte(mm, pt_path);
+	pte_unmap(pte);
 out:
 	return ret;
 }
Index: linux-2.6.20-rc3/include/linux/rmap.h
===================================================================
--- linux-2.6.20-rc3.orig/include/linux/rmap.h	2007-01-09 12:15:41.563902000 +1100
+++ linux-2.6.20-rc3/include/linux/rmap.h	2007-01-09 12:17:44.618257000 +1100
@@ -8,6 +8,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/spinlock.h>
+#include <linux/pt.h>
 
 /*
  * The anon_vma heads a list of private "related" vmas, to scan if
@@ -96,7 +97,7 @@
  * Called from mm/filemap_xip.c to unmap empty zero page
  */
 pte_t *page_check_address(struct page *, struct mm_struct *,
-				unsigned long, spinlock_t **);
+				unsigned long, pt_path_t *);
 
 /*
  * Used by swapoff to help locate where page is expected in vma.
Index: linux-2.6.20-rc3/mm/filemap_xip.c
===================================================================
--- linux-2.6.20-rc3.orig/mm/filemap_xip.c	2007-01-09 12:15:41.563902000 +1100
+++ linux-2.6.20-rc3/mm/filemap_xip.c	2007-01-09 12:17:44.618257000 +1100
@@ -174,7 +174,7 @@
 	unsigned long address;
 	pte_t *pte;
 	pte_t pteval;
-	spinlock_t *ptl;
+	pt_path_t pt_path;
 	struct page *page;
 
 	spin_lock(&mapping->i_mmap_lock);
@@ -184,7 +184,7 @@
 			((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
 		BUG_ON(address < vma->vm_start || address >= vma->vm_end);
 		page = ZERO_PAGE(address);
-		pte = page_check_address(page, mm, address, &ptl);
+		pte = page_check_address(page, mm, address, &pt_path);
 		if (pte) {
 			/* Nuke the page table entry. */
 			flush_cache_page(vma, address, pte_pfn(*pte));
@@ -192,7 +192,8 @@
 			page_remove_rmap(page, vma);
 			dec_mm_counter(mm, file_rss);
 			BUG_ON(pte_dirty(pteval));
-			pte_unmap_unlock(pte, ptl);
+			unlock_pte(mm, pt_path);
+			pte_unmap(pte);
 			page_cache_release(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:[~2007-01-13  2:46 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-13  2:45 [PATCH 0/29] Page Table Interface Explanation Paul Davies
2007-01-13  2:45 ` [PATCH 1/29] Abstract current page table implementation Paul Davies
2007-01-13  2:45 ` [PATCH 2/29] " Paul Davies
2007-01-13  2:45 ` [PATCH 3/29] " Paul Davies
2007-01-16 18:55   ` Christoph Lameter
2007-01-13  2:46 ` [PATCH 4/29] Introduce Page Table Interface (PTI) Paul Davies
2007-01-16 19:02   ` Christoph Lameter
2007-01-13  2:46 ` [PATCH 5/29] Start calling simple PTI functions Paul Davies
2007-01-16 19:04   ` Christoph Lameter
2007-01-18  6:43     ` Paul Cameron Davies
2007-01-13  2:46 ` [PATCH 6/29] Tweak IA64 arch dependent files to work with PTI Paul Davies
2007-01-16 19:05   ` Christoph Lameter
2007-01-13  2:46 ` [PATCH 7/29] Continue calling simple PTI functions Paul Davies
2007-01-16 19:08   ` Christoph Lameter
2007-01-13  2:46 ` [PATCH 8/29] Clean up page fault handers Paul Davies
2007-01-13  2:46 ` [PATCH 9/29] Clean up page fault handlers Paul Davies
2007-01-13  2:46 ` Paul Davies [this message]
2007-01-13  2:46 ` [PATCH 11/29] Call simple PTI functions cont Paul Davies
2007-01-13  2:46 ` [PATCH 12/29] Abstract page table tear down Paul Davies
2007-01-13  2:46 ` [PATCH 13/29] Finish abstracting " Paul Davies
2007-01-13  2:46 ` [PATCH 14/29] Abstract copy page range iterator Paul Davies
2007-01-13  2:46 ` [PATCH 15/29] Finish abstracting copy page range Paul Davies
2007-01-13  2:47 ` [PATCH 16/29] Abstract unmap page range iterator Paul Davies
2007-01-13  2:47 ` [PATCH 17/29] Finish abstracting unmap page range Paul Davies
2007-01-13  2:47 ` [PATCH 18/29] Abstract zeromap " Paul Davies
2007-01-13  2:47 ` [PATCH 19/29] Abstract remap pfn range Paul Davies
2007-01-13  2:47 ` [PATCH 20/29] Abstract change protection iterator Paul Davies
2007-01-13  2:47 ` [PATCH 21/29] Abstract unmap vm area Paul Davies
2007-01-13  2:47 ` [PATCH 22/29] Abstract map " Paul Davies
2007-01-13  2:47 ` [PATCH 23/29] Abstract unuse_vma Paul Davies
2007-01-13  2:47 ` [PATCH 24/29] Abstract smaps iterator Paul Davies
2007-01-13  2:47 ` [PATCH 25/29] Abstact mempolicy iterator Paul Davies
2007-01-13  2:47 ` [PATCH 26/29] Abstract mempolicy iterator cont Paul Davies
2007-01-13  2:48 ` [PATCH 27/29] Abstract implementation dependent code for mremap Paul Davies
2007-01-13  2:48 ` [PATCH 28/29] Abstract ioremap iterator Paul Davies
2007-01-13  2:48 ` [PATCH 29/29] Tweak i386 arch dependent files to work with PTI Paul Davies
2007-01-13  2:48 ` [PATCH 1/5] Introduce IA64 page table interface Paul Davies
2007-01-13  2:48 ` [PATCH 2/5] Abstract pgtable Paul Davies
2007-01-13  2:48 ` [PATCH 3/5] Abstact pgtable continued Paul Davies
2007-01-13  2:48 ` [PATCH 4/5] Abstract assembler lookup Paul Davies
2007-01-13  2:48 ` [PATCH 5/5] Abstract pgalloc Paul Davies
2007-01-13  2:48 ` [PATCH 1/12] Alternate page table implementation (GPT) Paul Davies
2007-01-13  2:48 ` [PATCH 2/12] Alternate page table implementation cont Paul Davies
2007-01-13  2:48 ` [PATCH 3/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 4/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 5/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 6/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 7/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 8/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 9/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 10/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 11/12] " Paul Davies
2007-01-13  2:49 ` [PATCH 12/12] " Paul Davies
2007-01-13 19:29 ` [PATCH 0/29] Page Table Interface Explanation Peter Zijlstra
2007-01-14 10:06   ` Paul Cameron Davies
2007-01-16 18:49 ` Christoph Lameter
2007-01-18  6:22   ` Paul Cameron Davies
2007-01-16 18:51 ` Christoph Lameter
2007-01-18  6:53   ` Paul Cameron Davies
2007-01-16 19:14 ` Christoph Lameter

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=20070113024633.29682.34136.sendpatchset@weill.orchestra.cse.unsw.EDU.AU \
    --to=pauld@gelato.unsw.edu.au \
    --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