public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
       [not found] <1109145729.5412.213.camel@gaston>
@ 2005-02-24  0:11 ` David S. Miller
  2005-02-25  9:32   ` Martin Schwidefsky
  2005-02-25 13:29   ` Paul Mundt
  0 siblings, 2 replies; 10+ messages in thread
From: David S. Miller @ 2005-02-24  0:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-arch

[-- Attachment #1: Type: text/plain, Size: 2046 bytes --]

On Wed, 23 Feb 2005 19:02:09 +1100
Benjamin Herrenschmidt <benh@au1.ibm.com> wrote:

> (I hope by early 2.6.12, we'll have David's patch that removes the need for
> those hacks though, and just pass us the vaddr (and mm or vma) to all the
> PTE accessors...)

Ok ok ok, I've started working on this again :-)

I'm taking a slightly different approach this time around so things
are easier to integrate.  Here is the first patch which builds the
infrastructure.  Basically:

1) Add set_pte_at() which is set_pte() with "mm" and "addr" arguments
   added.  All generic code uses set_pte_at().

   Most platforms simply get this define:
	#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)

   I chose this method over simply changing all set_pte() call sites
   because many platforms implement this in assembler and it would
   take forever to preserve the build and stabilize things if modifying
   that was necessary.

   Soon, with platform maintainer's help, we can kill of set_pte() entirely.
   To be honest, there are only a handful of set_pte() call sites in the
   arch specific code.

   Actually, in this patch ppc64 is completely set_pte() free and does not
   define it.

2) pte_clear() gets "mm" and "addr" arguments now.
   This had a cascading effect on many ptep_test_and_*() routines.  Specifically:
   a) ptep_test_and_clear_{young,dirty}() now take "vma" and "address" args.
   b) ptep_get_and_clear now take "mm" and "address" args.
   c) ptep_mkdirty was deleted, unused by any code.
   d) ptep_set_wrprotect now takes "mm" and "address" args.

I've tested this patch as follows:

1) compile and run tested on sparc64/SMP
2) compile tested on:
   a) ppc64/SMP
   b) i386 both with and without PAE enabled

I've been over this a few times this afternoon and the patch looks
correct.  Please test the build and boot of your platform, any build
failures should be trivial typos and nothing major.

Next I'll work on the sparc64 taking advantage of set_pte_at() and then
I'll merge in Ben's patch I have doing the same.

[-- Attachment #2: diff --]
[-- Type: application/octet-stream, Size: 63296 bytes --]

===== arch/arm/mm/consistent.c 1.28 vs edited =====
--- 1.28/arch/arm/mm/consistent.c	2005-02-18 14:19:54 -08:00
+++ edited/arch/arm/mm/consistent.c	2005-02-23 13:00:34 -08:00
@@ -322,7 +322,7 @@
 void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t handle)
 {
 	struct vm_region *c;
-	unsigned long flags;
+	unsigned long flags, addr;
 	pte_t *ptep;
 
 	size = PAGE_ALIGN(size);
@@ -341,11 +341,13 @@
 	}
 
 	ptep = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
+	addr = c->vm_start;
 	do {
-		pte_t pte = ptep_get_and_clear(ptep);
+		pte_t pte = ptep_get_and_clear(&init_mm, addr, ptep);
 		unsigned long pfn;
 
 		ptep++;
+		addr += PAGE_SIZE;
 
 		if (!pte_none(pte) && pte_present(pte)) {
 			pfn = pte_pfn(pte);
===== arch/i386/mm/highmem.c 1.6 vs edited =====
--- 1.6/arch/i386/mm/highmem.c	2005-01-03 15:49:15 -08:00
+++ edited/arch/i386/mm/highmem.c	2005-02-23 12:43:31 -08:00
@@ -66,7 +66,7 @@
 	 * force other mappings to Oops if they'll try to access
 	 * this pte without first remap it
 	 */
-	pte_clear(kmap_pte-idx);
+	pte_clear(&init_mm, vaddr, kmap_pte-idx);
 	__flush_tlb_one(vaddr);
 #endif
 
===== arch/i386/mm/hugetlbpage.c 1.58 vs edited =====
--- 1.58/arch/i386/mm/hugetlbpage.c	2004-12-22 01:31:49 -08:00
+++ edited/arch/i386/mm/hugetlbpage.c	2005-02-23 13:01:18 -08:00
@@ -216,7 +216,7 @@
 	BUG_ON(end & (HPAGE_SIZE - 1));
 
 	for (address = start; address < end; address += HPAGE_SIZE) {
-		pte = ptep_get_and_clear(huge_pte_offset(mm, address));
+		pte = ptep_get_and_clear(mm, address, huge_pte_offset(mm, address));
 		if (pte_none(pte))
 			continue;
 		page = pte_page(pte);
===== arch/ia64/mm/hugetlbpage.c 1.31 vs edited =====
--- 1.31/arch/ia64/mm/hugetlbpage.c	2004-12-22 01:32:06 -08:00
+++ edited/arch/ia64/mm/hugetlbpage.c	2005-02-23 12:46:23 -08:00
@@ -244,7 +244,7 @@
 			continue;
 		page = pte_page(*pte);
 		put_page(page);
-		pte_clear(pte);
+		pte_clear(mm, address, pte);
 	}
 	mm->rss -= (end - start) >> PAGE_SHIFT;
 	flush_tlb_range(vma, start, end);
===== arch/mips/mm/highmem.c 1.5 vs edited =====
--- 1.5/arch/mips/mm/highmem.c	2005-01-03 15:49:15 -08:00
+++ edited/arch/mips/mm/highmem.c	2005-02-23 12:46:46 -08:00
@@ -75,7 +75,7 @@
 	 * force other mappings to Oops if they'll try to access
 	 * this pte without first remap it
 	 */
-	pte_clear(kmap_pte-idx);
+	pte_clear(&init_mm, vaddr, kmap_pte-idx);
 	local_flush_tlb_one(vaddr);
 #endif
 
===== arch/parisc/kernel/pci-dma.c 1.12 vs edited =====
--- 1.12/arch/parisc/kernel/pci-dma.c	2004-10-31 22:09:35 -08:00
+++ edited/arch/parisc/kernel/pci-dma.c	2005-02-23 12:47:07 -08:00
@@ -180,7 +180,7 @@
 		end = PMD_SIZE;
 	do {
 		pte_t page = *pte;
-		pte_clear(pte);
+		pte_clear(&init_mm, vaddr, pte);
 		purge_tlb_start();
 		pdtlb_kernel(orig_vaddr);
 		purge_tlb_end();
===== arch/parisc/mm/kmap.c 1.4 vs edited =====
--- 1.4/arch/parisc/mm/kmap.c	2004-02-03 21:42:01 -08:00
+++ edited/arch/parisc/mm/kmap.c	2005-02-23 12:48:04 -08:00
@@ -49,10 +49,10 @@
  * unmap_uncached_page() and save a little code space but I didn't
  * do that since I'm not certain whether this is the right path. -PB
  */
-static void unmap_cached_pte(pte_t * pte, unsigned long arg)
+static void unmap_cached_pte(pte_t * pte, unsigned long addr, unsigned long arg)
 {
 	pte_t page = *pte;
-	pte_clear(pte);
+	pte_clear(&init_mm, addr, pte);
 	if (!pte_none(page)) {
 		if (pte_present(page)) {
 			unsigned long map_nr = pte_pagenr(page);
===== arch/ppc/kernel/dma-mapping.c 1.5 vs edited =====
--- 1.5/arch/ppc/kernel/dma-mapping.c	2005-01-20 21:02:08 -08:00
+++ edited/arch/ppc/kernel/dma-mapping.c	2005-02-23 13:02:17 -08:00
@@ -262,7 +262,7 @@
 void __dma_free_coherent(size_t size, void *vaddr)
 {
 	struct vm_region *c;
-	unsigned long flags;
+	unsigned long flags, addr;
 	pte_t *ptep;
 
 	size = PAGE_ALIGN(size);
@@ -281,11 +281,13 @@
 	}
 
 	ptep = consistent_pte + CONSISTENT_OFFSET(c->vm_start);
+	addr = c->vm_start;
 	do {
-		pte_t pte = ptep_get_and_clear(ptep);
+		pte_t pte = ptep_get_and_clear(&init_mm, addr, ptep);
 		unsigned long pfn;
 
 		ptep++;
+		addr += PAGE_SIZE;
 
 		if (!pte_none(pte) && pte_present(pte)) {
 			pfn = pte_pfn(pte);
===== arch/ppc64/mm/hugetlbpage.c 1.38 vs edited =====
--- 1.38/arch/ppc64/mm/hugetlbpage.c	2005-02-22 01:32:19 -08:00
+++ edited/arch/ppc64/mm/hugetlbpage.c	2005-02-23 14:54:44 -08:00
@@ -149,7 +149,8 @@
 }
 
 static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
-			 struct page *page, pte_t *ptep, int write_access)
+			 unsigned long addr, struct page *page,
+			 pte_t *ptep, int write_access)
 {
 	pte_t entry;
 
@@ -163,7 +164,7 @@
 	entry = pte_mkyoung(entry);
 	entry = pte_mkhuge(entry);
 
-	set_pte(ptep, entry);
+	set_pte_at(mm, addr, ptep, entry);
 }
 
 /*
@@ -316,7 +317,7 @@
 		ptepage = pte_page(entry);
 		get_page(ptepage);
 		dst->rss += (HPAGE_SIZE / PAGE_SIZE);
-		set_pte(dst_pte, entry);
+		set_pte_at(dst, addr, dst_pte, entry);
 
 		addr += HPAGE_SIZE;
 	}
@@ -421,7 +422,7 @@
 
 		pte = *ptep;
 		page = pte_page(pte);
-		pte_clear(ptep);
+		pte_clear(mm, addr, ptep);
 
 		put_page(page);
 	}
@@ -486,7 +487,7 @@
 				goto out;
 			}
 		}
-		set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
+		set_huge_pte(mm, vma, addr, page, pte, vma->vm_flags & VM_WRITE);
 	}
 out:
 	spin_unlock(&mm->page_table_lock);
===== arch/ppc64/mm/init.c 1.94 vs edited =====
--- 1.94/arch/ppc64/mm/init.c	2005-01-20 21:02:10 -08:00
+++ edited/arch/ppc64/mm/init.c	2005-02-23 14:57:47 -08:00
@@ -153,7 +153,7 @@
 		ptep = pte_alloc_kernel(&ioremap_mm, pmdp, ea);
 
 		pa = abs_to_phys(pa);
-		set_pte(ptep, pfn_pte(pa >> PAGE_SHIFT, __pgprot(flags)));
+		set_pte_at(&ioremap_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, __pgprot(flags)));
 		spin_unlock(&ioremap_mm.page_table_lock);
 	} else {
 		unsigned long va, vpn, hash, hpteg;
@@ -305,7 +305,7 @@
 
 	do {
 		pte_t page;
-		page = ptep_get_and_clear(pte);
+		page = ptep_get_and_clear(&ioremap_mm, address, pte);
 		address += PAGE_SIZE;
 		pte++;
 		if (pte_none(page))
===== arch/s390/mm/init.c 1.24 vs edited =====
--- 1.24/arch/s390/mm/init.c	2005-01-03 15:49:38 -08:00
+++ edited/arch/s390/mm/init.c	2005-02-23 14:38:40 -08:00
@@ -145,7 +145,7 @@
                 for (tmp = 0 ; tmp < PTRS_PER_PTE ; tmp++,pg_table++) {
                         pte = pfn_pte(pfn, PAGE_KERNEL);
                         if (pfn >= max_low_pfn)
-                                pte_clear(&pte);
+                                pte_clear(&init_mm, 0, &pte);
                         set_pte(pg_table, pte);
                         pfn++;
                 }
@@ -229,7 +229,7 @@
                         for (k = 0 ; k < PTRS_PER_PTE ; k++,pt_dir++) {
                                 pte = pfn_pte(pfn, PAGE_KERNEL);
                                 if (pfn >= max_low_pfn) {
-                                        pte_clear(&pte); 
+                                        pte_clear(&init_mm, 0, &pte); 
                                         continue;
                                 }
                                 set_pte(pt_dir, pte);
===== arch/sh/mm/hugetlbpage.c 1.9 vs edited =====
--- 1.9/arch/sh/mm/hugetlbpage.c	2004-05-10 04:25:53 -07:00
+++ edited/arch/sh/mm/hugetlbpage.c	2005-02-23 13:13:21 -08:00
@@ -202,7 +202,7 @@
 		page = pte_page(*pte);
 		put_page(page);
 		for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
-			pte_clear(pte);
+			pte_clear(mm, address+(i*PAGE_SIZE), pte);
 			pte++;
 		}
 	}
===== arch/sh/mm/pg-sh4.c 1.2 vs edited =====
--- 1.2/arch/sh/mm/pg-sh4.c	2004-06-24 01:56:10 -07:00
+++ edited/arch/sh/mm/pg-sh4.c	2005-02-23 12:51:15 -08:00
@@ -56,7 +56,7 @@
 		local_irq_restore(flags);
 		update_mmu_cache(NULL, p3_addr, entry);
 		__clear_user_page((void *)p3_addr, to);
-		pte_clear(pte);
+		pte_clear(&init_mm, p3_addr, pte);
 		up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
 	}
 }
@@ -95,7 +95,7 @@
 		local_irq_restore(flags);
 		update_mmu_cache(NULL, p3_addr, entry);
 		__copy_user_page((void *)p3_addr, from, to);
-		pte_clear(pte);
+		pte_clear(&init_mm, p3_addr, pte);
 		up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
 	}
 }
@@ -103,11 +103,11 @@
 /*
  * For SH-4, we have our own implementation for ptep_get_and_clear
  */
-inline pte_t ptep_get_and_clear(pte_t *ptep)
+inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t pte = *ptep;
 
-	pte_clear(ptep);
+	pte_clear(mm, addr, ptep);
 	if (!pte_not_present(pte)) {
 		unsigned long pfn = pte_pfn(pte);
 		if (pfn_valid(pfn)) {
===== arch/sh/mm/pg-sh7705.c 1.1 vs edited =====
--- 1.1/arch/sh/mm/pg-sh7705.c	2004-10-18 22:26:41 -07:00
+++ edited/arch/sh/mm/pg-sh7705.c	2005-02-23 12:51:34 -08:00
@@ -117,11 +117,11 @@
  * For SH7705, we have our own implementation for ptep_get_and_clear
  * Copied from pg-sh4.c
  */
-inline pte_t ptep_get_and_clear(pte_t *ptep)
+inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t pte = *ptep;
 
-	pte_clear(ptep);
+	pte_clear(mm, addr, ptep);
 	if (!pte_not_present(pte)) {
 		unsigned long pfn = pte_pfn(pte);
 		if (pfn_valid(pfn)) {
===== arch/sh64/mm/hugetlbpage.c 1.1 vs edited =====
--- 1.1/arch/sh64/mm/hugetlbpage.c	2004-06-29 07:44:46 -07:00
+++ edited/arch/sh64/mm/hugetlbpage.c	2005-02-23 13:13:30 -08:00
@@ -202,7 +202,7 @@
 		page = pte_page(*pte);
 		put_page(page);
 		for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
-			pte_clear(pte);
+			pte_clear(mm, address+(i*PAGE_SIZE), pte);
 			pte++;
 		}
 	}
===== arch/sh64/mm/ioremap.c 1.1 vs edited =====
--- 1.1/arch/sh64/mm/ioremap.c	2004-06-29 07:44:46 -07:00
+++ edited/arch/sh64/mm/ioremap.c	2005-02-23 12:51:54 -08:00
@@ -400,7 +400,7 @@
 		return;
 
 	clear_page((void *)ptep);
-	pte_clear(ptep);
+	pte_clear(&init_mm, vaddr, ptep);
 }
 
 unsigned long onchip_remap(unsigned long phys, unsigned long size, const char *name)
===== arch/sparc/mm/generic.c 1.9 vs edited =====
--- 1.9/arch/sparc/mm/generic.c	2004-10-20 01:37:05 -07:00
+++ edited/arch/sparc/mm/generic.c	2005-02-23 14:40:24 -08:00
@@ -47,7 +47,7 @@
  * They use a pgprot that sets PAGE_IO and does not check the
  * mem_map table as this is independent of normal memory.
  */
-static inline void io_remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
+static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte, unsigned long address, unsigned long size,
 	unsigned long offset, pgprot_t prot, int space)
 {
 	unsigned long end;
@@ -58,7 +58,7 @@
 		end = PMD_SIZE;
 	do {
 		pte_t oldpage = *pte;
-		pte_clear(pte);
+		pte_clear(mm, address, pte);
 		set_pte(pte, mk_pte_io(offset, prot, space));
 		forget_pte(oldpage);
 		address += PAGE_SIZE;
@@ -67,7 +67,7 @@
 	} while (address < end);
 }
 
-static inline int io_remap_pmd_range(pmd_t * pmd, unsigned long address, unsigned long size,
+static inline int io_remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
 	unsigned long offset, pgprot_t prot, int space)
 {
 	unsigned long end;
@@ -78,10 +78,10 @@
 		end = PGDIR_SIZE;
 	offset -= address;
 	do {
-		pte_t * pte = pte_alloc_map(current->mm, pmd, address);
+		pte_t * pte = pte_alloc_map(mm, pmd, address);
 		if (!pte)
 			return -ENOMEM;
-		io_remap_pte_range(pte, address, end - address, address + offset, prot, space);
+		io_remap_pte_range(mm, pte, address, end - address, address + offset, prot, space);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
 	} while (address < end);
@@ -107,7 +107,7 @@
 		error = -ENOMEM;
 		if (!pmd)
 			break;
-		error = io_remap_pmd_range(pmd, from, end - from, offset + from, prot, space);
+		error = io_remap_pmd_range(mm, pmd, from, end - from, offset + from, prot, space);
 		if (error)
 			break;
 		from = (from + PGDIR_SIZE) & PGDIR_MASK;
===== arch/sparc/mm/highmem.c 1.5 vs edited =====
--- 1.5/arch/sparc/mm/highmem.c	2005-01-03 15:49:15 -08:00
+++ edited/arch/sparc/mm/highmem.c	2005-02-23 14:40:49 -08:00
@@ -88,7 +88,7 @@
 	 * force other mappings to Oops if they'll try to access
 	 * this pte without first remap it
 	 */
-	pte_clear(kmap_pte-idx);
+	pte_clear(&init_mm, vaddr, kmap_pte-idx);
 /* XXX Fix - Anton */
 #if 0
 	__flush_tlb_one(vaddr);
===== arch/sparc64/mm/hugetlbpage.c 1.20 vs edited =====
--- 1.20/arch/sparc64/mm/hugetlbpage.c	2005-01-25 20:34:29 -08:00
+++ edited/arch/sparc64/mm/hugetlbpage.c	2005-02-23 13:12:20 -08:00
@@ -207,7 +207,7 @@
 		page = pte_page(*pte);
 		put_page(page);
 		for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
-			pte_clear(pte);
+			pte_clear(mm, address+(i*PAGE_SIZE), pte);
 			pte++;
 		}
 	}
===== fs/exec.c 1.159 vs edited =====
--- 1.159/fs/exec.c	2005-01-20 21:02:13 -08:00
+++ edited/fs/exec.c	2005-02-23 11:59:05 -08:00
@@ -328,7 +328,7 @@
 	}
 	mm->rss++;
 	lru_cache_add_active(page);
-	set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(
+	set_pte_at(mm, address, pte, pte_mkdirty(pte_mkwrite(mk_pte(
 					page, vma->vm_page_prot))));
 	page_add_anon_rmap(page, vma, address);
 	pte_unmap(pte);
===== include/asm-alpha/pgtable.h 1.29 vs edited =====
--- 1.29/include/asm-alpha/pgtable.h	2005-02-02 01:49:27 -08:00
+++ edited/include/asm-alpha/pgtable.h	2005-02-23 12:24:25 -08:00
@@ -22,6 +22,7 @@
  * hook is made available.
  */
 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
 #define PMD_SHIFT	(PAGE_SHIFT + (PAGE_SHIFT-3))
@@ -235,7 +236,10 @@
 
 extern inline int pte_none(pte_t pte)		{ return !pte_val(pte); }
 extern inline int pte_present(pte_t pte)	{ return pte_val(pte) & _PAGE_VALID; }
-extern inline void pte_clear(pte_t *ptep)	{ pte_val(*ptep) = 0; }
+extern inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+	pte_val(*ptep) = 0;
+}
 
 extern inline int pmd_none(pmd_t pmd)		{ return !pmd_val(pmd); }
 extern inline int pmd_bad(pmd_t pmd)		{ return (pmd_val(pmd) & ~_PFN_MASK) != _PAGE_TABLE; }
===== include/asm-arm/pgtable.h 1.28 vs edited =====
--- 1.28/include/asm-arm/pgtable.h	2005-01-05 15:55:41 -08:00
+++ edited/include/asm-arm/pgtable.h	2005-02-23 12:24:47 -08:00
@@ -254,7 +254,7 @@
 #define pfn_pte(pfn,prot)	(__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
 
 #define pte_none(pte)		(!pte_val(pte))
-#define pte_clear(ptep)		set_pte((ptep), __pte(0))
+#define pte_clear(mm,addr,ptep)	set_pte_at((mm),(addr),(ptep), __pte(0))
 #define pte_page(pte)		(pfn_to_page(pte_pfn(pte)))
 #define pte_offset_kernel(dir,addr)	(pmd_page_kernel(*(dir)) + __pte_index(addr))
 #define pte_offset_map(dir,addr)	(pmd_page_kernel(*(dir)) + __pte_index(addr))
@@ -263,6 +263,7 @@
 #define pte_unmap_nested(pte)	do { } while (0)
 
 #define set_pte(ptep, pte)	cpu_set_pte(ptep,pte)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 /*
  * The following only work if pte_present() is true.
===== include/asm-arm26/pgtable.h 1.6 vs edited =====
--- 1.6/include/asm-arm26/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-arm26/pgtable.h	2005-02-23 12:25:07 -08:00
@@ -154,7 +154,8 @@
 #define pte_none(pte)           (!pte_val(pte))
 #define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
 #define set_pte(pte_ptr, pte)   ((*(pte_ptr)) = (pte))
-#define pte_clear(ptep)         set_pte((ptep), __pte(0))
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+#define pte_clear(mm,addr,ptep)	set_pte_at((mm),(addr),(ptep), __pte(0))
 
 /* macros to ease the getting of pointers to stuff... */
 #define pgd_offset(mm, addr)	((pgd_t *)(mm)->pgd        + __pgd_index(addr))
===== include/asm-cris/pgtable.h 1.17 vs edited =====
--- 1.17/include/asm-cris/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-cris/pgtable.h	2005-02-23 12:25:18 -08:00
@@ -34,6 +34,8 @@
  * hook is made available.
  */
 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+
 /*
  * (pmds are folded into pgds so this doesn't get actually called,
  * but the define is needed for a generic inline function.)
@@ -101,7 +103,7 @@
 
 #define pte_none(x)	(!pte_val(x))
 #define pte_present(x)	(pte_val(x) & _PAGE_PRESENT)
-#define pte_clear(xp)	do { pte_val(*(xp)) = 0; } while (0)
+#define pte_clear(mm,addr,xp)	do { pte_val(*(xp)) = 0; } while (0)
 
 #define pmd_none(x)	(!pmd_val(x))
 /* by removing the _PAGE_KERNEL bit from the comparision, the same pmd_bad
===== include/asm-frv/pgtable.h 1.4 vs edited =====
--- 1.4/include/asm-frv/pgtable.h	2005-01-04 18:48:10 -08:00
+++ edited/include/asm-frv/pgtable.h	2005-02-23 14:48:27 -08:00
@@ -173,6 +173,7 @@
 	*(pteptr) = (pteval);				\
 	asm volatile("dcf %M0" :: "U"(*pteptr));	\
 } while(0)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 #define set_pte_atomic(pteptr, pteval)		set_pte((pteptr), (pteval))
 
@@ -353,7 +354,7 @@
 #undef TEST_VERIFY_AREA
 
 #define pte_present(x)	(pte_val(x) & _PAGE_PRESENT)
-#define pte_clear(xp)	do { set_pte(xp, __pte(0)); } while (0)
+#define pte_clear(mm,addr,xp)	do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 
 #define pmd_none(x)	(!pmd_val(x))
 #define pmd_present(x)	(pmd_val(x) & _PAGE_PRESENT)
@@ -390,39 +391,33 @@
 static inline pte_t pte_mkyoung(pte_t pte)	{ (pte).pte |= _PAGE_ACCESSED; return pte; }
 static inline pte_t pte_mkwrite(pte_t pte)	{ (pte).pte &= ~_PAGE_WP; return pte; }
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	int i = test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
 	asm volatile("dcf %M0" :: "U"(*ptep));
 	return i;
 }
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	int i = test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
 	asm volatile("dcf %M0" :: "U"(*ptep));
 	return i;
 }
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	unsigned long x = xchg(&ptep->pte, 0);
 	asm volatile("dcf %M0" :: "U"(*ptep));
 	return __pte(x);
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	set_bit(_PAGE_BIT_WP, ptep);
 	asm volatile("dcf %M0" :: "U"(*ptep));
 }
 
-static inline void ptep_mkdirty(pte_t *ptep)
-{
-	set_bit(_PAGE_BIT_DIRTY, ptep);
-	asm volatile("dcf %M0" :: "U"(*ptep));
-}
-
 /*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
@@ -512,7 +507,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== include/asm-generic/pgtable.h 1.8 vs edited =====
--- 1.8/include/asm-generic/pgtable.h	2004-10-13 21:08:28 -07:00
+++ edited/include/asm-generic/pgtable.h	2005-02-23 12:25:55 -08:00
@@ -16,7 +16,7 @@
 #ifndef __HAVE_ARCH_SET_PTE_ATOMIC
 #define ptep_establish(__vma, __address, __ptep, __entry)		\
 do {				  					\
-	set_pte(__ptep, __entry);					\
+	set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry);	\
 	flush_tlb_page(__vma, __address);				\
 } while (0)
 #else /* __HAVE_ARCH_SET_PTE_ATOMIC */
@@ -37,26 +37,30 @@
  */
 #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
 do {				  					  \
-	set_pte(__ptep, __entry);					  \
+	set_pte_at((__vma)->vm_mm, (__address), __ptep, __entry);	  \
 	flush_tlb_page(__vma, __address);				  \
 } while (0)
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
-static inline int ptep_test_and_clear_young(pte_t *ptep)
-{
-	pte_t pte = *ptep;
-	if (!pte_young(pte))
-		return 0;
-	set_pte(ptep, pte_mkold(pte));
-	return 1;
-}
+#define ptep_test_and_clear_young(__vma, __address, __ptep)		\
+({									\
+	pte_t __pte = *(__ptep);					\
+	int r = 1;							\
+	if (!pte_young(__pte))						\
+		r = 0;							\
+	else								\
+		set_pte_at((__vma)->vm_mm, (__address),			\
+			   (__ptep), pte_mkold(__pte));			\
+	r;								\
+})
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
 #define ptep_clear_flush_young(__vma, __address, __ptep)		\
 ({									\
-	int __young = ptep_test_and_clear_young(__ptep);		\
+	int __young;							\
+	__young = ptep_test_and_clear_young(__vma, __address, __ptep);	\
 	if (__young)							\
 		flush_tlb_page(__vma, __address);			\
 	__young;							\
@@ -64,20 +68,24 @@
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
-{
-	pte_t pte = *ptep;
-	if (!pte_dirty(pte))
-		return 0;
-	set_pte(ptep, pte_mkclean(pte));
-	return 1;
-}
+#define ptep_test_and_clear_dirty(__vma, __address, __ptep)		\
+({									\
+	pte_t __pte = *ptep;						\
+	int r = 1;							\
+	if (!pte_dirty(__pte))						\
+		r = 0;							\
+	else								\
+		set_pte_at((__vma)->vm_mm, (__address), (__ptep),	\
+			   pte_mkclean(__pte));				\
+	r;								\
+})
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
 #define ptep_clear_flush_dirty(__vma, __address, __ptep)		\
 ({									\
-	int __dirty = ptep_test_and_clear_dirty(__ptep);		\
+	int __dirty;							\
+	__dirty = ptep_test_and_clear_dirty(__vma, __address, __ptep);	\
 	if (__dirty)							\
 		flush_tlb_page(__vma, __address);			\
 	__dirty;							\
@@ -85,36 +93,29 @@
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
-{
-	pte_t pte = *ptep;
-	pte_clear(ptep);
-	return pte;
-}
+#define ptep_get_and_clear(__mm, __address, __ptep)			\
+({									\
+	pte_t __pte = *(__ptep);					\
+	pte_clear((__mm), (__address), (__ptep));			\
+	__pte;								\
+})
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
 #define ptep_clear_flush(__vma, __address, __ptep)			\
 ({									\
-	pte_t __pte = ptep_get_and_clear(__ptep);			\
+	pte_t __pte;							\
+	__pte = ptep_get_and_clear((__vma)->vm_mm, __address, __ptep);	\
 	flush_tlb_page(__vma, __address);				\
 	__pte;								\
 })
 #endif
 
 #ifndef __HAVE_ARCH_PTEP_SET_WRPROTECT
-static inline void ptep_set_wrprotect(pte_t *ptep)
-{
-	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_wrprotect(old_pte));
-}
-#endif
-
-#ifndef __HAVE_ARCH_PTEP_MKDIRTY
-static inline void ptep_mkdirty(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep)
 {
 	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_mkdirty(old_pte));
+	set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
 }
 #endif
 
===== include/asm-i386/pgtable-2level.h 1.11 vs edited =====
--- 1.11/include/asm-i386/pgtable-2level.h	2004-12-22 01:31:43 -08:00
+++ edited/include/asm-i386/pgtable-2level.h	2005-02-23 13:03:18 -08:00
@@ -14,10 +14,11 @@
  * hook is made available.
  */
 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
 
-#define ptep_get_and_clear(xp)	__pte(xchg(&(xp)->pte_low, 0))
+#define ptep_get_and_clear(mm,addr,xp)	__pte(xchg(&(xp)->pte_low, 0))
 #define pte_same(a, b)		((a).pte_low == (b).pte_low)
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
 #define pte_none(x)		(!(x).pte_low)
===== include/asm-i386/pgtable-3level.h 1.22 vs edited =====
--- 1.22/include/asm-i386/pgtable-3level.h	2004-12-22 01:31:49 -08:00
+++ edited/include/asm-i386/pgtable-3level.h	2005-02-23 13:03:24 -08:00
@@ -56,6 +56,8 @@
 	smp_wmb();
 	ptep->pte_low = pte.pte_low;
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+
 #define __HAVE_ARCH_SET_PTE_ATOMIC
 #define set_pte_atomic(pteptr,pteval) \
 		set_64bit((unsigned long long *)(pteptr),pte_val(pteval))
@@ -88,7 +90,7 @@
 #define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
 			pmd_index(address))
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t res;
 
===== include/asm-i386/pgtable.h 1.56 vs edited =====
--- 1.56/include/asm-i386/pgtable.h	2005-01-03 15:49:21 -08:00
+++ edited/include/asm-i386/pgtable.h	2005-02-23 14:48:21 -08:00
@@ -201,7 +201,7 @@
 extern unsigned long pg0[];
 
 #define pte_present(x)	((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(xp)	do { set_pte(xp, __pte(0)); } while (0)
+#define pte_clear(mm,addr,xp)	do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 
 #define pmd_none(x)	(!pmd_val(x))
 #define pmd_present(x)	(pmd_val(x) & _PAGE_PRESENT)
@@ -243,22 +243,24 @@
 # include <asm/pgtable-2level.h>
 #endif
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	if (!pte_dirty(*ptep))
 		return 0;
 	return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte_low);
 }
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	if (!pte_young(*ptep))
 		return 0;
 	return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte_low);
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)		{ clear_bit(_PAGE_BIT_RW, &ptep->pte_low); }
-static inline void ptep_mkdirty(pte_t *ptep)			{ set_bit(_PAGE_BIT_DIRTY, &ptep->pte_low); }
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+	clear_bit(_PAGE_BIT_RW, &ptep->pte_low);
+}
 
 /*
  * Macro to mark a page protection value as "uncacheable".  On processors which do not support
@@ -407,7 +409,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== include/asm-ia64/pgtable.h 1.52 vs edited =====
--- 1.52/include/asm-ia64/pgtable.h	2005-01-02 16:45:04 -08:00
+++ edited/include/asm-ia64/pgtable.h	2005-02-23 14:48:38 -08:00
@@ -202,6 +202,7 @@
  * the PTE in a page table.  Nothing special needs to be on IA-64.
  */
 #define set_pte(ptep, pteval)	(*(ptep) = (pteval))
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 #define RGN_SIZE	(1UL << 61)
 #define RGN_KERNEL	7
@@ -243,7 +244,7 @@
 
 #define pte_none(pte) 			(!pte_val(pte))
 #define pte_present(pte)		(pte_val(pte) & (_PAGE_P | _PAGE_PROTNONE))
-#define pte_clear(pte)			(pte_val(*(pte)) = 0UL)
+#define pte_clear(mm,addr,pte)		(pte_val(*(pte)) = 0UL)
 /* pte_page() returns the "struct page *" corresponding to the PTE: */
 #define pte_page(pte)			virt_to_page(((pte_val(pte) & _PFN_MASK) + PAGE_OFFSET))
 
@@ -345,7 +346,7 @@
 /* atomic versions of the some PTE manipulations: */
 
 static inline int
-ptep_test_and_clear_young (pte_t *ptep)
+ptep_test_and_clear_young (struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	if (!pte_young(*ptep))
@@ -355,13 +356,13 @@
 	pte_t pte = *ptep;
 	if (!pte_young(pte))
 		return 0;
-	set_pte(ptep, pte_mkold(pte));
+	set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
 	return 1;
 #endif
 }
 
 static inline int
-ptep_test_and_clear_dirty (pte_t *ptep)
+ptep_test_and_clear_dirty (struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	if (!pte_dirty(*ptep))
@@ -371,25 +372,25 @@
 	pte_t pte = *ptep;
 	if (!pte_dirty(pte))
 		return 0;
-	set_pte(ptep, pte_mkclean(pte));
+	set_pte_at(vma->vm_mm, addr, ptep, pte_mkclean(pte));
 	return 1;
 #endif
 }
 
 static inline pte_t
-ptep_get_and_clear (pte_t *ptep)
+ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	return __pte(xchg((long *) ptep, 0));
 #else
 	pte_t pte = *ptep;
-	pte_clear(ptep);
+	pte_clear(mm, addr, ptep);
 	return pte;
 #endif
 }
 
 static inline void
-ptep_set_wrprotect (pte_t *ptep)
+ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	unsigned long new, old;
@@ -400,18 +401,7 @@
 	} while (cmpxchg((unsigned long *) ptep, old, new) != old);
 #else
 	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_wrprotect(old_pte));
-#endif
-}
-
-static inline void
-ptep_mkdirty (pte_t *ptep)
-{
-#ifdef CONFIG_SMP
-	set_bit(_PAGE_D_BIT, ptep);
-#else
-	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_mkdirty(old_pte));
+	set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
 #endif
 }
 
@@ -558,7 +548,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #define __HAVE_ARCH_PGD_OFFSET_GATE
 #include <asm-generic/pgtable.h>
===== include/asm-m32r/pgtable-2level.h 1.4 vs edited =====
--- 1.4/include/asm-m32r/pgtable-2level.h	2005-01-03 15:49:31 -08:00
+++ edited/include/asm-m32r/pgtable-2level.h	2005-02-23 13:03:44 -08:00
@@ -44,6 +44,7 @@
  * hook is made available.
  */
 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 #define set_pte_atomic(pteptr, pteval)	set_pte(pteptr, pteval)
 /*
  * (pmds are folded into pgds so this doesnt get actually called,
@@ -60,7 +61,7 @@
 	return (pmd_t *) dir;
 }
 
-#define ptep_get_and_clear(xp)	__pte(xchg(&(xp)->pte, 0))
+#define ptep_get_and_clear(mm,addr,xp)	__pte(xchg(&(xp)->pte, 0))
 #define pte_same(a, b)		(pte_val(a) == pte_val(b))
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
 #define pte_none(x)		(!pte_val(x))
===== include/asm-m32r/pgtable.h 1.8 vs edited =====
--- 1.8/include/asm-m32r/pgtable.h	2005-01-03 15:49:31 -08:00
+++ edited/include/asm-m32r/pgtable.h	2005-02-23 14:48:48 -08:00
@@ -176,7 +176,7 @@
 /* page table for 0-4MB for everybody */
 
 #define pte_present(x)	(pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(xp)	do { set_pte(xp, __pte(0)); } while (0)
+#define pte_clear(mm,addr,xp)	do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 
 #define pmd_none(x)	(!pmd_val(x))
 #define pmd_present(x)	(pmd_val(x) & _PAGE_PRESENT)
@@ -282,26 +282,21 @@
 	return pte;
 }
 
-static inline  int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline  int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
 }
 
-static inline  int ptep_test_and_clear_young(pte_t *ptep)
+static inline  int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	clear_bit(_PAGE_BIT_WRITE, ptep);
 }
 
-static inline void ptep_mkdirty(pte_t *ptep)
-{
-	set_bit(_PAGE_BIT_DIRTY, ptep);
-}
-
 /*
  * Macro and implementation to make a page protection as uncachable.
  */
@@ -390,7 +385,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== include/asm-m68k/motorola_pgtable.h 1.8 vs edited =====
--- 1.8/include/asm-m68k/motorola_pgtable.h	2004-04-04 03:11:21 -07:00
+++ edited/include/asm-m68k/motorola_pgtable.h	2005-02-23 12:28:22 -08:00
@@ -129,7 +129,7 @@
 
 #define pte_none(pte)		(!pte_val(pte))
 #define pte_present(pte)	(pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(ptep)		({ pte_val(*(ptep)) = 0; })
+#define pte_clear(mm,addr,ptep)		({ pte_val(*(ptep)) = 0; })
 
 #define pte_page(pte)		(mem_map + ((unsigned long)(__va(pte_val(pte)) - PAGE_OFFSET) >> PAGE_SHIFT))
 #define pte_pfn(pte)		(pte_val(pte) >> PAGE_SHIFT)
===== include/asm-m68k/pgtable.h 1.13 vs edited =====
--- 1.13/include/asm-m68k/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-m68k/pgtable.h	2005-02-23 12:20:24 -08:00
@@ -26,6 +26,7 @@
 	do{							\
 		*(pteptr) = (pteval);				\
 	} while(0)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 
 /* PMD_SHIFT determines the size of the area a second-level page table can map */
===== include/asm-m68k/sun3_pgtable.h 1.7 vs edited =====
--- 1.7/include/asm-m68k/sun3_pgtable.h	2004-01-18 22:35:43 -08:00
+++ edited/include/asm-m68k/sun3_pgtable.h	2005-02-23 12:29:02 -08:00
@@ -123,7 +123,10 @@
 
 static inline int pte_none (pte_t pte) { return !pte_val (pte); }
 static inline int pte_present (pte_t pte) { return pte_val (pte) & SUN3_PAGE_VALID; }
-static inline void pte_clear (pte_t *ptep) { pte_val (*ptep) = 0; }
+static inline void pte_clear (struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+	pte_val (*ptep) = 0;
+}
 
 #define pte_pfn(pte)            (pte_val(pte) & SUN3_PAGE_PGNUM_MASK)
 #define pfn_pte(pfn, pgprot) \
===== include/asm-mips/pgtable.h 1.18 vs edited =====
--- 1.18/include/asm-mips/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-mips/pgtable.h	2005-02-23 12:29:49 -08:00
@@ -100,14 +100,15 @@
 			buddy->pte_low |= _PAGE_GLOBAL;
 	}
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
-static inline void pte_clear(pte_t *ptep)
+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	/* Preserve global status for the pair */
 	if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
-		set_pte(ptep, __pte(_PAGE_GLOBAL));
+		set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL));
 	else
-		set_pte(ptep, __pte(0));
+		set_pte_at(mm, addr, ptep, __pte(0));
 }
 #else
 /*
@@ -130,16 +131,17 @@
 	}
 #endif
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
-static inline void pte_clear(pte_t *ptep)
+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 #if !defined(CONFIG_CPU_R3000) && !defined(CONFIG_CPU_TX39XX)
 	/* Preserve global status for the pair */
 	if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL)
-		set_pte(ptep, __pte(_PAGE_GLOBAL));
+		set_pte_at(mm, addr, ptep, __pte(_PAGE_GLOBAL));
 	else
 #endif
-		set_pte(ptep, __pte(0));
+		set_pte_at(mm, addr, ptep, __pte(0));
 }
 #endif
 
===== include/asm-parisc/pgtable.h 1.23 vs edited =====
--- 1.23/include/asm-parisc/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-parisc/pgtable.h	2005-02-23 14:48:57 -08:00
@@ -39,6 +39,7 @@
         do{                                                     \
                 *(pteptr) = (pteval);                           \
         } while(0)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 #endif /* !__ASSEMBLY__ */
 
@@ -263,7 +264,7 @@
 
 #define pte_none(x)     ((pte_val(x) == 0) || (pte_val(x) & _PAGE_FLUSH))
 #define pte_present(x)	(pte_val(x) & _PAGE_PRESENT)
-#define pte_clear(xp)	do { pte_val(*(xp)) = 0; } while (0)
+#define pte_clear(mm,addr,xp)	do { pte_val(*(xp)) = 0; } while (0)
 
 #define pmd_flag(x)	(pmd_val(x) & PxD_FLAG_MASK)
 #define pmd_address(x)	((unsigned long)(pmd_val(x) &~ PxD_FLAG_MASK) << PxD_VALUE_SHIFT)
@@ -431,7 +432,7 @@
 #define __pte_to_swp_entry(pte)		((swp_entry_t) { pte_val(pte) })
 #define __swp_entry_to_pte(x)		((pte_t) { (x).val })
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	if (!pte_young(*ptep))
@@ -441,12 +442,12 @@
 	pte_t pte = *ptep;
 	if (!pte_young(pte))
 		return 0;
-	set_pte(ptep, pte_mkold(pte));
+	set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
 	return 1;
 #endif
 }
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	if (!pte_dirty(*ptep))
@@ -456,14 +457,14 @@
 	pte_t pte = *ptep;
 	if (!pte_dirty(pte))
 		return 0;
-	set_pte(ptep, pte_mkclean(pte));
+	set_pte_at(vma->vm_mm, addr, ptep, pte_mkclean(pte));
 	return 1;
 #endif
 }
 
 extern spinlock_t pa_dbit_lock;
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t old_pte;
 	pte_t pte;
@@ -472,13 +473,13 @@
 	pte = old_pte = *ptep;
 	pte_val(pte) &= ~_PAGE_PRESENT;
 	pte_val(pte) |= _PAGE_FLUSH;
-	set_pte(ptep,pte);
+	set_pte_at(mm,addr,ptep,pte);
 	spin_unlock(&pa_dbit_lock);
 
 	return old_pte;
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 #ifdef CONFIG_SMP
 	unsigned long new, old;
@@ -489,17 +490,7 @@
 	} while (cmpxchg((unsigned long *) ptep, old, new) != old);
 #else
 	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_wrprotect(old_pte));
-#endif
-}
-
-static inline void ptep_mkdirty(pte_t *ptep)
-{
-#ifdef CONFIG_SMP
-	set_bit(xlate_pabit(_PAGE_DIRTY_BIT), &pte_val(*ptep));
-#else
-	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_mkdirty(old_pte));
+	set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
 #endif
 }
 
@@ -518,7 +509,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== include/asm-ppc/highmem.h 1.20 vs edited =====
--- 1.20/include/asm-ppc/highmem.h	2005-01-03 15:49:15 -08:00
+++ edited/include/asm-ppc/highmem.h	2005-02-23 14:43:02 -08:00
@@ -114,7 +114,7 @@
 	 * force other mappings to Oops if they'll try to access
 	 * this pte without first remap it
 	 */
-	pte_clear(kmap_pte+idx);
+	pte_clear(&init_mm, vaddr, kmap_pte+idx);
 	flush_tlb_page(NULL, vaddr);
 #endif
 	dec_preempt_count();
===== include/asm-ppc/pgtable.h 1.40 vs edited =====
--- 1.40/include/asm-ppc/pgtable.h	2005-02-20 21:00:26 -08:00
+++ edited/include/asm-ppc/pgtable.h	2005-02-23 14:49:06 -08:00
@@ -448,7 +448,7 @@
 
 #define pte_none(pte)		((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
 #define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
-#define pte_clear(ptep)		do { set_pte((ptep), __pte(0)); } while (0)
+#define pte_clear(mm,addr,ptep)	do { set_pte_at((mm), (addr), (ptep), __pte(0)); } while (0)
 
 #define pmd_none(pmd)		(!pmd_val(pmd))
 #define	pmd_bad(pmd)		(pmd_val(pmd) & _PMD_BAD)
@@ -550,6 +550,7 @@
 	*ptep = pte;
 #endif
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 extern void flush_hash_one_pte(pte_t *ptep);
 
@@ -557,7 +558,7 @@
  * 2.6 calles this without flushing the TLB entry, this is wrong
  * for our hash-based implementation, we fix that up here
  */
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	unsigned long old;
 	old = pte_update(ptep, _PAGE_ACCESSED, 0);
@@ -568,26 +569,21 @@
 	return (old & _PAGE_ACCESSED) != 0;
 }
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	return (pte_update(ptep, (_PAGE_DIRTY | _PAGE_HWWRITE), 0) & _PAGE_DIRTY) != 0;
 }
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	return __pte(pte_update(ptep, ~_PAGE_HASHPTE, 0));
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_update(ptep, (_PAGE_RW | _PAGE_HWWRITE), 0);
 }
 
-static inline void ptep_mkdirty(pte_t *ptep)
-{
-	pte_update(ptep, 0, _PAGE_DIRTY);
-}
-
 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
 static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry, int dirty)
 {
@@ -747,7 +743,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== include/asm-ppc64/pgtable.h 1.45 vs edited =====
--- 1.45/include/asm-ppc64/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-ppc64/pgtable.h	2005-02-23 15:02:35 -08:00
@@ -317,7 +317,7 @@
  */
 extern void hpte_update(pte_t *ptep, unsigned long pte, int wrprot);
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	unsigned long old;
 
@@ -336,7 +336,7 @@
  * moment we always flush but we need to fix hpte_update and test if the
  * optimisation is worth it.
  */
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	unsigned long old;
 
@@ -348,7 +348,7 @@
 	return (old & _PAGE_DIRTY) != 0;
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	unsigned long old;
 
@@ -370,19 +370,21 @@
 #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
 #define ptep_clear_flush_young(__vma, __address, __ptep)		\
 ({									\
-	int __young = ptep_test_and_clear_young(__ptep);		\
+	int __young;							\
+	__young = ptep_test_and_clear_young(__vma, __address, __ptep);	\
 	__young;							\
 })
 
 #define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
 #define ptep_clear_flush_dirty(__vma, __address, __ptep)		\
 ({									\
-	int __dirty = ptep_test_and_clear_dirty(__ptep);		\
+	int __dirty;							\
+	__dirty = ptep_test_and_clear_dirty(__vma, __address, __ptep);	\
 	flush_tlb_page(__vma, __address);				\
 	__dirty;							\
 })
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	unsigned long old = pte_update(ptep, ~0UL);
 
@@ -391,7 +393,7 @@
 	return __pte(old);
 }
 
-static inline void pte_clear(pte_t * ptep)
+static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t * ptep)
 {
 	unsigned long old = pte_update(ptep, ~0UL);
 
@@ -402,10 +404,11 @@
 /*
  * set_pte stores a linux PTE into the linux page table.
  */
-static inline void set_pte(pte_t *ptep, pte_t pte)
+static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
+			      pte_t *ptep, pte_t pte)
 {
 	if (pte_present(*ptep)) {
-		pte_clear(ptep);
+		pte_clear(mm, addr, ptep);
 		flush_tlb_pending();
 	}
 	*ptep = __pte(pte_val(pte)) & ~_PAGE_HPTEFLAGS;
===== include/asm-s390/pgalloc.h 1.15 vs edited =====
--- 1.15/include/asm-s390/pgalloc.h	2004-04-12 10:54:30 -07:00
+++ edited/include/asm-s390/pgalloc.h	2005-02-23 14:43:59 -08:00
@@ -130,8 +130,10 @@
 
 	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte != NULL) {
-		for (i=0; i < PTRS_PER_PTE; i++)
-			pte_clear(pte+i);
+		for (i=0; i < PTRS_PER_PTE; i++) {
+			pte_clear(mm, vmaddr, pte+i);
+			vmaddr += PAGE_SIZE;
+		}
 	}
 	return pte;
 }
===== include/asm-s390/pgtable.h 1.35 vs edited =====
--- 1.35/include/asm-s390/pgtable.h	2005-01-06 08:58:52 -08:00
+++ edited/include/asm-s390/pgtable.h	2005-02-23 14:49:15 -08:00
@@ -322,6 +322,7 @@
 {
 	*pteptr = pteval;
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 /*
  * pgd/pmd/pte query functions
@@ -457,7 +458,7 @@
 
 #endif /* __s390x__ */
 
-extern inline void pte_clear(pte_t *ptep)
+extern inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_val(*ptep) = _PAGE_INVALID_EMPTY;
 }
@@ -521,7 +522,7 @@
 	return pte;
 }
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	return 0;
 }
@@ -531,10 +532,10 @@
 			unsigned long address, pte_t *ptep)
 {
 	/* No need to flush TLB; bits are in storage key */
-	return ptep_test_and_clear_young(ptep);
+	return ptep_test_and_clear_young(vma, address, ptep);
 }
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	return 0;
 }
@@ -544,13 +545,13 @@
 			unsigned long address, pte_t *ptep)
 {
 	/* No need to flush TLB; bits are in storage key */
-	return ptep_test_and_clear_dirty(ptep);
+	return ptep_test_and_clear_dirty(vma, address, ptep);
 }
 
-static inline pte_t ptep_get_and_clear(pte_t *ptep)
+static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t pte = *ptep;
-	pte_clear(ptep);
+	pte_clear(mm, addr, ptep);
 	return pte;
 }
 
@@ -573,19 +574,14 @@
 				      : "=m" (*ptep) : "m" (*ptep),
 				        "a" (ptep), "a" (address) );
 #endif /* __s390x__ */
-	pte_clear(ptep);
+	pte_clear(vma->vm_mm, address, ptep);
 	return pte;
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
 	pte_t old_pte = *ptep;
-	set_pte(ptep, pte_wrprotect(old_pte));
-}
-
-static inline void ptep_mkdirty(pte_t *ptep)
-{
-	pte_mkdirty(*ptep);
+	set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
 }
 
 static inline void
@@ -802,7 +798,6 @@
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_CLEAR_FLUSH
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
===== include/asm-sh/pgtable-2level.h 1.6 vs edited =====
--- 1.6/include/asm-sh/pgtable-2level.h	2002-10-18 14:24:01 -07:00
+++ edited/include/asm-sh/pgtable-2level.h	2005-02-23 12:21:37 -08:00
@@ -41,6 +41,8 @@
  * hook is made available.
  */
 #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
+
 /*
  * (pmds are folded into pgds so this doesn't get actually called,
  * but the define is needed for a generic inline function.)
===== include/asm-sh/pgtable.h 1.29 vs edited =====
--- 1.29/include/asm-sh/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-sh/pgtable.h	2005-02-23 13:04:31 -08:00
@@ -164,7 +164,7 @@
 
 #define pte_none(x)	(!pte_val(x))
 #define pte_present(x)	(pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(xp)	do { set_pte(xp, __pte(0)); } while (0)
+#define pte_clear(mm,addr,xp)	do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 
 #define pmd_none(x)	(!pmd_val(x))
 #define pmd_present(x)	(pmd_val(x) & _PAGE_PRESENT)
@@ -290,7 +290,7 @@
 
 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
-extern pte_t ptep_get_and_clear(pte_t *ptep);
+extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
 #endif
 
 #include <asm-generic/pgtable.h>
===== include/asm-sh64/pgtable.h 1.3 vs edited =====
--- 1.3/include/asm-sh64/pgtable.h	2004-12-22 01:36:07 -08:00
+++ edited/include/asm-sh64/pgtable.h	2005-02-23 12:33:06 -08:00
@@ -136,6 +136,7 @@
 	 */
 	*(xp) = (x & NPHYS_SIGN) ? (x | NPHYS_MASK) : x;
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 static __inline__ void pmd_set(pmd_t *pmdp,pte_t *ptep)
 {
@@ -383,7 +384,7 @@
  */
 #define _PTE_EMPTY	0x0
 #define pte_present(x)	(pte_val(x) & _PAGE_PRESENT)
-#define pte_clear(xp)	(set_pte(xp, __pte(_PTE_EMPTY)))
+#define pte_clear(mm,addr,xp)	(set_pte_at(mm, addr, xp, __pte(_PTE_EMPTY)))
 #define pte_none(x)	(pte_val(x) == _PTE_EMPTY)
 
 /*
===== include/asm-sparc/pgtable.h 1.25 vs edited =====
--- 1.25/include/asm-sparc/pgtable.h	2005-01-30 11:22:18 -08:00
+++ edited/include/asm-sparc/pgtable.h	2005-02-23 12:33:18 -08:00
@@ -157,7 +157,7 @@
 }
 
 #define pte_present(pte) BTFIXUP_CALL(pte_present)(pte)
-#define pte_clear(pte) BTFIXUP_CALL(pte_clear)(pte)
+#define pte_clear(mm,addr,pte) BTFIXUP_CALL(pte_clear)(pte)
 
 BTFIXUPDEF_CALL_CONST(int, pmd_bad, pmd_t)
 BTFIXUPDEF_CALL_CONST(int, pmd_present, pmd_t)
@@ -339,6 +339,7 @@
 BTFIXUPDEF_CALL(void, set_pte, pte_t *, pte_t)
 
 #define set_pte(ptep,pteval) BTFIXUP_CALL(set_pte)(ptep,pteval)
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 struct seq_file;
 BTFIXUPDEF_CALL(void, mmu_info, struct seq_file *)
===== include/asm-sparc64/pgtable.h 1.45 vs edited =====
--- 1.45/include/asm-sparc64/pgtable.h	2005-02-05 14:53:05 -08:00
+++ edited/include/asm-sparc64/pgtable.h	2005-02-23 12:33:36 -08:00
@@ -343,8 +343,10 @@
 	if (pte_present(orig))
 		tlb_batch_add(ptep, orig);
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
-#define pte_clear(ptep)		set_pte((ptep), __pte(0UL))
+#define pte_clear(mm,addr,ptep)		\
+	set_pte_at((mm), (addr), (ptep), __pte(0UL))
 
 extern pgd_t swapper_pg_dir[1];
 
===== include/asm-um/pgtable-2level.h 1.1 vs edited =====
--- 1.1/include/asm-um/pgtable-2level.h	2005-01-11 16:42:49 -08:00
+++ edited/include/asm-um/pgtable-2level.h	2005-02-23 12:22:07 -08:00
@@ -59,6 +59,7 @@
 	*pteptr = pte_mknewpage(pteval);
 	if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
 
===== include/asm-um/pgtable-3level.h 1.1 vs edited =====
--- 1.1/include/asm-um/pgtable-3level.h	2005-01-11 16:42:49 -08:00
+++ edited/include/asm-um/pgtable-3level.h	2005-02-23 12:22:13 -08:00
@@ -84,6 +84,7 @@
 	*pteptr = pte_mknewpage(*pteptr);
 	if(pte_present(*pteptr)) *pteptr = pte_mknewprot(*pteptr);
 }
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 #define set_pmd(pmdptr, pmdval) set_64bit((phys_t *) (pmdptr), pmd_val(pmdval))
 
===== include/asm-um/pgtable.h 1.21 vs edited =====
--- 1.21/include/asm-um/pgtable.h	2005-02-03 10:06:13 -08:00
+++ edited/include/asm-um/pgtable.h	2005-02-23 12:34:08 -08:00
@@ -142,7 +142,7 @@
 #define PAGE_PTR(address) \
 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 
-#define pte_clear(xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEWPAGE))
+#define pte_clear(mm,addr,xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEWPAGE))
 
 #define pmd_none(x)	(!(pmd_val(x) & ~_PAGE_NEWPAGE))
 #define	pmd_bad(x)	((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
===== include/asm-x86_64/pgtable.h 1.39 vs edited =====
--- 1.39/include/asm-x86_64/pgtable.h	2005-02-10 12:33:18 -08:00
+++ edited/include/asm-x86_64/pgtable.h	2005-02-23 14:49:23 -08:00
@@ -73,6 +73,7 @@
 {
 	pte_val(*dst) = pte_val(val);
 } 
+#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
 static inline void set_pmd(pmd_t *dst, pmd_t val)
 {
@@ -102,7 +103,7 @@
 #define pud_page(pud) \
 ((unsigned long) __va(pud_val(pud) & PHYSICAL_PAGE_MASK))
 
-#define ptep_get_and_clear(xp)	__pte(xchg(&(xp)->pte, 0))
+#define ptep_get_and_clear(mm,addr,xp)	__pte(xchg(&(xp)->pte, 0))
 #define pte_same(a, b)		((a).pte == (b).pte)
 
 #define PMD_SIZE	(1UL << PMD_SHIFT)
@@ -224,7 +225,7 @@
 
 #define pte_none(x)	(!pte_val(x))
 #define pte_present(x)	(pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
-#define pte_clear(xp)	do { set_pte(xp, __pte(0)); } while (0)
+#define pte_clear(mm,addr,xp)	do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 
 #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))	/* FIXME: is this
 						   right? */
@@ -263,22 +264,24 @@
 extern inline pte_t pte_mkyoung(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
 extern inline pte_t pte_mkwrite(pte_t pte)	{ set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
 
-static inline int ptep_test_and_clear_dirty(pte_t *ptep)
+static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	if (!pte_dirty(*ptep))
 		return 0;
 	return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
 }
 
-static inline int ptep_test_and_clear_young(pte_t *ptep)
+static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
 {
 	if (!pte_young(*ptep))
 		return 0;
 	return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
 }
 
-static inline void ptep_set_wrprotect(pte_t *ptep)		{ clear_bit(_PAGE_BIT_RW, ptep); }
-static inline void ptep_mkdirty(pte_t *ptep)			{ set_bit(_PAGE_BIT_DIRTY, ptep); }
+static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+	clear_bit(_PAGE_BIT_RW, ptep);
+}
 
 /*
  * Macro to mark a page protection value as "uncacheable".
@@ -419,7 +422,6 @@
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
-#define __HAVE_ARCH_PTEP_MKDIRTY
 #define __HAVE_ARCH_PTE_SAME
 #include <asm-generic/pgtable.h>
 
===== mm/fremap.c 1.30 vs edited =====
--- 1.30/mm/fremap.c	2004-12-22 01:31:46 -08:00
+++ edited/mm/fremap.c	2005-02-23 12:39:35 -08:00
@@ -45,7 +45,7 @@
 	} else {
 		if (!pte_file(pte))
 			free_swap_and_cache(pte_to_swp_entry(pte));
-		pte_clear(ptep);
+		pte_clear(mm, addr, ptep);
 	}
 }
 
@@ -94,7 +94,7 @@
 
 	mm->rss++;
 	flush_icache_page(vma, page);
-	set_pte(pte, mk_pte(page, prot));
+	set_pte_at(mm, addr, pte, mk_pte(page, prot));
 	page_add_file_rmap(page);
 	pte_val = *pte;
 	pte_unmap(pte);
@@ -139,7 +139,7 @@
 
 	zap_pte(mm, vma, addr, pte);
 
-	set_pte(pte, pgoff_to_pte(pgoff));
+	set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
 	pte_val = *pte;
 	pte_unmap(pte);
 	update_mmu_cache(vma, addr, pte_val);
===== mm/highmem.c 1.55 vs edited =====
--- 1.55/mm/highmem.c	2005-01-07 21:44:13 -08:00
+++ edited/mm/highmem.c	2005-02-23 12:37:05 -08:00
@@ -90,7 +90,8 @@
 		 * So no dangers, even with speculative execution.
 		 */
 		page = pte_page(pkmap_page_table[i]);
-		pte_clear(&pkmap_page_table[i]);
+		pte_clear(&init_mm, (unsigned long)page_address(page),
+			  &pkmap_page_table[i]);
 
 		set_page_address(page, NULL);
 	}
@@ -138,7 +139,8 @@
 		}
 	}
 	vaddr = PKMAP_ADDR(last_pkmap_nr);
-	set_pte(&(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
+	set_pte_at(&init_mm, vaddr,
+		   &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
 
 	pkmap_count[last_pkmap_nr] = 1;
 	set_page_address(page, (void *)vaddr);
===== mm/memory.c 1.223 vs edited =====
--- 1.223/mm/memory.c	2005-02-15 18:45:11 -08:00
+++ edited/mm/memory.c	2005-02-23 12:09:02 -08:00
@@ -278,7 +278,7 @@
 	/* pte contains position in swap, so copy. */
 	if (!pte_present(pte)) {
 		copy_swap_pte(dst_mm, src_mm, pte);
-		set_pte(dst_pte, pte);
+		set_pte_at(dst_mm, addr, dst_pte, pte);
 		return;
 	}
 	pfn = pte_pfn(pte);
@@ -292,7 +292,7 @@
 		page = pfn_to_page(pfn);
 
 	if (!page || PageReserved(page)) {
-		set_pte(dst_pte, pte);
+		set_pte_at(dst_mm, addr, dst_pte, pte);
 		return;
 	}
 
@@ -301,7 +301,7 @@
 	 * in the parent and the child
 	 */
 	if ((vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE) {
-		ptep_set_wrprotect(src_pte);
+		ptep_set_wrprotect(src_mm, addr, src_pte);
 		pte = *src_pte;
 	}
 
@@ -316,7 +316,7 @@
 	dst_mm->rss++;
 	if (PageAnon(page))
 		dst_mm->anon_rss++;
-	set_pte(dst_pte, pte);
+	set_pte_at(dst_mm, addr, dst_pte, pte);
 	page_dup_rmap(page);
 }
 
@@ -502,14 +502,15 @@
 				     page->index > details->last_index))
 					continue;
 			}
-			pte = ptep_get_and_clear(ptep);
+			pte = ptep_get_and_clear(tlb->mm, address+offset, ptep);
 			tlb_remove_tlb_entry(tlb, ptep, address+offset);
 			if (unlikely(!page))
 				continue;
 			if (unlikely(details) && details->nonlinear_vma
 			    && linear_page_index(details->nonlinear_vma,
 					address+offset) != page->index)
-				set_pte(ptep, pgoff_to_pte(page->index));
+				set_pte_at(tlb->mm, address+offset,
+					   ptep, pgoff_to_pte(page->index));
 			if (pte_dirty(pte))
 				set_page_dirty(page);
 			if (PageAnon(page))
@@ -529,7 +530,7 @@
 			continue;
 		if (!pte_file(pte))
 			free_swap_and_cache(pte_to_swp_entry(pte));
-		pte_clear(ptep);
+		pte_clear(tlb->mm, address+offset, ptep);
 	}
 	pte_unmap(ptep-1);
 }
@@ -987,8 +988,9 @@
 
 EXPORT_SYMBOL(get_user_pages);
 
-static void zeromap_pte_range(pte_t * pte, unsigned long address,
-                                     unsigned long size, pgprot_t prot)
+static void zeromap_pte_range(struct mm_struct *mm, pte_t * pte,
+			      unsigned long address,
+			      unsigned long size, pgprot_t prot)
 {
 	unsigned long end;
 
@@ -999,7 +1001,7 @@
 	do {
 		pte_t zero_pte = pte_wrprotect(mk_pte(ZERO_PAGE(address), prot));
 		BUG_ON(!pte_none(*pte));
-		set_pte(pte, zero_pte);
+		set_pte_at(mm, address, pte, zero_pte);
 		address += PAGE_SIZE;
 		pte++;
 	} while (address && (address < end));
@@ -1019,7 +1021,7 @@
 		pte_t * pte = pte_alloc_map(mm, pmd, base + address);
 		if (!pte)
 			return -ENOMEM;
-		zeromap_pte_range(pte, base + address, end - address, prot);
+		zeromap_pte_range(mm, pte, base + address, end - address, prot);
 		pte_unmap(pte);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
@@ -1100,7 +1102,8 @@
  * in null mappings (currently treated as "copy-on-access")
  */
 static inline void
-remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
+remap_pte_range(struct mm_struct *mm, pte_t * pte,
+		unsigned long address, unsigned long size,
 		unsigned long pfn, pgprot_t prot)
 {
 	unsigned long end;
@@ -1112,7 +1115,7 @@
 	do {
 		BUG_ON(!pte_none(*pte));
 		if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
- 			set_pte(pte, pfn_pte(pfn, prot));
+			set_pte_at(mm, address, pte, pfn_pte(pfn, prot));
 		address += PAGE_SIZE;
 		pfn++;
 		pte++;
@@ -1135,7 +1138,7 @@
 		pte_t * pte = pte_alloc_map(mm, pmd, base + address);
 		if (!pte)
 			return -ENOMEM;
-		remap_pte_range(pte, base + address, end - address,
+		remap_pte_range(mm, pte, base + address, end - address,
 				(address >> PAGE_SHIFT) + pfn, prot);
 		pte_unmap(pte);
 		address = (address + PMD_SIZE) & PMD_MASK;
@@ -1758,7 +1761,7 @@
 	unlock_page(page);
 
 	flush_icache_page(vma, page);
-	set_pte(page_table, pte);
+	set_pte_at(mm, address, page_table, pte);
 	page_add_anon_rmap(page, vma, address);
 
 	if (write_access) {
@@ -1824,7 +1827,7 @@
 		page_add_anon_rmap(page, vma, addr);
 	}
 
-	set_pte(page_table, entry);
+	set_pte_at(mm, addr, page_table, entry);
 	pte_unmap(page_table);
 
 	/* No need to invalidate - it was non-present before */
@@ -1939,7 +1942,7 @@
 		entry = mk_pte(new_page, vma->vm_page_prot);
 		if (write_access)
 			entry = maybe_mkwrite(pte_mkdirty(entry), vma);
-		set_pte(page_table, entry);
+		set_pte_at(mm, address, page_table, entry);
 		if (anon) {
 			lru_cache_add_active(new_page);
 			page_add_anon_rmap(new_page, vma, address);
@@ -1983,7 +1986,7 @@
 	 */
 	if (!vma->vm_ops || !vma->vm_ops->populate || 
 			(write_access && !(vma->vm_flags & VM_SHARED))) {
-		pte_clear(pte);
+		pte_clear(mm, address, pte);
 		return do_no_page(mm, vma, address, write_access, pte, pmd);
 	}
 
===== mm/mprotect.c 1.40 vs edited =====
--- 1.40/mm/mprotect.c	2004-12-22 01:31:46 -08:00
+++ edited/mm/mprotect.c	2005-02-23 12:11:37 -08:00
@@ -26,7 +26,7 @@
 #include <asm/tlbflush.h>
 
 static inline void
-change_pte_range(pmd_t *pmd, unsigned long address,
+change_pte_range(struct mm_struct *mm, pmd_t *pmd, unsigned long address,
 		unsigned long size, pgprot_t newprot)
 {
 	pte_t * pte;
@@ -52,8 +52,8 @@
 			 * bits by wiping the pte and then setting the new pte
 			 * into place.
 			 */
-			entry = ptep_get_and_clear(pte);
-			set_pte(pte, pte_modify(entry, newprot));
+			entry = ptep_get_and_clear(mm, address, pte);
+			set_pte_at(mm, address, pte, pte_modify(entry, newprot));
 		}
 		address += PAGE_SIZE;
 		pte++;
@@ -62,8 +62,8 @@
 }
 
 static inline void
-change_pmd_range(pud_t *pud, unsigned long address,
-		unsigned long size, pgprot_t newprot)
+change_pmd_range(struct mm_struct *mm, pud_t *pud, unsigned long address,
+		 unsigned long size, pgprot_t newprot)
 {
 	pmd_t * pmd;
 	unsigned long end;
@@ -81,15 +81,15 @@
 	if (end > PUD_SIZE)
 		end = PUD_SIZE;
 	do {
-		change_pte_range(pmd, address, end - address, newprot);
+		change_pte_range(mm, pmd, address, end - address, newprot);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
 	} while (address && (address < end));
 }
 
 static inline void
-change_pud_range(pgd_t *pgd, unsigned long address,
-		unsigned long size, pgprot_t newprot)
+change_pud_range(struct mm_struct *mm, pgd_t *pgd, unsigned long address,
+		 unsigned long size, pgprot_t newprot)
 {
 	pud_t * pud;
 	unsigned long end;
@@ -107,7 +107,7 @@
 	if (end > PGDIR_SIZE)
 		end = PGDIR_SIZE;
 	do {
-		change_pmd_range(pud, address, end - address, newprot);
+		change_pmd_range(mm, pud, address, end - address, newprot);
 		address = (address + PUD_SIZE) & PUD_MASK;
 		pud++;
 	} while (address && (address < end));
@@ -130,7 +130,7 @@
 		next = (start + PGDIR_SIZE) & PGDIR_MASK;
 		if (next <= start || next > end)
 			next = end;
-		change_pud_range(pgd, start, next - start, newprot);
+		change_pud_range(mm, pgd, start, next - start, newprot);
 		start = next;
 		pgd++;
 	}
===== mm/mremap.c 1.62 vs edited =====
--- 1.62/mm/mremap.c	2005-01-07 21:44:05 -08:00
+++ edited/mm/mremap.c	2005-02-23 12:11:56 -08:00
@@ -150,7 +150,7 @@
 			if (dst) {
 				pte_t pte;
 				pte = ptep_clear_flush(vma, old_addr, src);
-				set_pte(dst, pte);
+				set_pte_at(mm, new_addr, dst, pte);
 			} else
 				error = -ENOMEM;
 			pte_unmap_nested(src);
===== mm/rmap.c 1.85 vs edited =====
--- 1.85/mm/rmap.c	2005-01-07 21:44:05 -08:00
+++ edited/mm/rmap.c	2005-02-23 12:12:28 -08:00
@@ -594,7 +594,7 @@
 			list_add(&mm->mmlist, &init_mm.mmlist);
 			spin_unlock(&mmlist_lock);
 		}
-		set_pte(pte, swp_entry_to_pte(entry));
+		set_pte_at(mm, address, pte, swp_entry_to_pte(entry));
 		BUG_ON(pte_file(*pte));
 		mm->anon_rss--;
 	}
@@ -697,7 +697,7 @@
 
 		/* If nonlinear, store the file page offset in the pte. */
 		if (page->index != linear_page_index(vma, address))
-			set_pte(pte, pgoff_to_pte(page->index));
+			set_pte_at(mm, address, pte, pgoff_to_pte(page->index));
 
 		/* Move the dirty bit to the physical page now the pte is gone. */
 		if (pte_dirty(pteval))
===== mm/swapfile.c 1.125 vs edited =====
--- 1.125/mm/swapfile.c	2005-01-11 16:42:36 -08:00
+++ edited/mm/swapfile.c	2005-02-23 12:12:45 -08:00
@@ -434,7 +434,8 @@
 {
 	vma->vm_mm->rss++;
 	get_page(page);
-	set_pte(dir, pte_mkold(mk_pte(page, vma->vm_page_prot)));
+	set_pte_at(vma->vm_mm, address, dir,
+		   pte_mkold(mk_pte(page, vma->vm_page_prot)));
 	page_add_anon_rmap(page, vma, address);
 	swap_free(entry);
 	acct_update_integrals();
===== mm/vmalloc.c 1.40 vs edited =====
--- 1.40/mm/vmalloc.c	2005-02-11 17:33:28 -08:00
+++ edited/mm/vmalloc.c	2005-02-23 13:31:29 -08:00
@@ -45,7 +45,7 @@
 
 	do {
 		pte_t page;
-		page = ptep_get_and_clear(pte);
+		page = ptep_get_and_clear(&init_mm, address, pte);
 		address += PAGE_SIZE;
 		pte++;
 		if (pte_none(page))
@@ -127,7 +127,7 @@
 		if (!page)
 			return -ENOMEM;
 
-		set_pte(pte, mk_pte(page, prot));
+		set_pte_at(&init_mm, address, pte, mk_pte(page, prot));
 		address += PAGE_SIZE;
 		pte++;
 		(*pages)++;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
@ 2005-02-24  0:55 Luck, Tony
  2005-02-24  4:02 ` David S. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Luck, Tony @ 2005-02-24  0:55 UTC (permalink / raw)
  To: David S. Miller, Benjamin Herrenschmidt; +Cc: linux-arch

>I've been over this a few times this afternoon and the patch looks
>correct.  Please test the build and boot of your platform, any build
>failures should be trivial typos and nothing major.

Builds (no new warnings) and boots on ia64.

-Tony

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-24  0:55 Luck, Tony
@ 2005-02-24  4:02 ` David S. Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David S. Miller @ 2005-02-24  4:02 UTC (permalink / raw)
  To: Luck, Tony; +Cc: benh, linux-arch

On Wed, 23 Feb 2005 16:55:50 -0800
"Luck, Tony" <tony.luck@intel.com> wrote:

> >I've been over this a few times this afternoon and the patch looks
> >correct.  Please test the build and boot of your platform, any build
> >failures should be trivial typos and nothing major.
> 
> Builds (no new warnings) and boots on ia64.

Thanks for testing Tony.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-24  0:11 ` [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte()) David S. Miller
@ 2005-02-25  9:32   ` Martin Schwidefsky
  2005-02-25 23:43     ` David S. Miller
  2005-02-25 13:29   ` Paul Mundt
  1 sibling, 1 reply; 10+ messages in thread
From: Martin Schwidefsky @ 2005-02-25  9:32 UTC (permalink / raw)
  To: David S. Miller; +Cc: Benjamin Herrenschmidt, linux-arch

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

"David S. Miller" <davem@davemloft.net> wrote on 24.02.2005 01:11:38:

> I'm taking a slightly different approach this time around so things
> are easier to integrate.  Here is the first patch which builds the
> infrastructure.  Basically:
>
> 2) pte_clear() gets "mm" and "addr" arguments now.
>    This had a cascading effect on many ptep_test_and_*() routines.
> Specifically:
>    a) ptep_test_and_clear_{young,dirty}() now take "vma" and "address"
args.
>    b) ptep_get_and_clear now take "mm" and "address" args.
>    c) ptep_mkdirty was deleted, unused by any code.
>    d) ptep_set_wrprotect now takes "mm" and "address" args.

The change in the pte_clear prototype broke compilation on s390.
The attached little patch takes care of that. Runs fine now.

blue skies,
   Martin

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

(See attached file: set_pte_at_s390.diff)

[-- Attachment #2: set_pte_at_s390.diff --]
[-- Type: application/octet-stream, Size: 657 bytes --]

diff -urN linux-2.6/include/asm-s390/pgtable.h linux-2.6-pte/include/asm-s390/pgtable.h
--- linux-2.6/include/asm-s390/pgtable.h	2005-02-25 10:18:05.000000000 +0100
+++ linux-2.6-pte/include/asm-s390/pgtable.h	2005-02-25 10:21:57.000000000 +0100
@@ -550,7 +550,7 @@
 static inline pte_t ptep_get_and_clear(pte_t *ptep)
 {
 	pte_t pte = *ptep;
-	pte_clear(mm, addr, ptep);
+	pte_val(*ptep) = _PAGE_INVALID_EMPTY;
 	return pte;
 }
 
@@ -573,7 +573,7 @@
 				      : "=m" (*ptep) : "m" (*ptep),
 				        "a" (ptep), "a" (address) );
 #endif /* __s390x__ */
-	pte_clear(vma->vm_mm, address, ptep);
+	pte_val(*ptep) = _PAGE_INVALID_EMPTY;
 	return pte;
 }
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-24  0:11 ` [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte()) David S. Miller
  2005-02-25  9:32   ` Martin Schwidefsky
@ 2005-02-25 13:29   ` Paul Mundt
  2005-02-25 23:43     ` David S. Miller
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Mundt @ 2005-02-25 13:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-arch

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

On Wed, Feb 23, 2005 at 04:11:38PM -0800, David S. Miller wrote:
> I've been over this a few times this afternoon and the patch looks
> correct.  Please test the build and boot of your platform, any build
> failures should be trivial typos and nothing major.
> 
This works fine for sh and sh64 too.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-25  9:32   ` Martin Schwidefsky
@ 2005-02-25 23:43     ` David S. Miller
  2005-02-28  9:27       ` Martin Schwidefsky
  0 siblings, 1 reply; 10+ messages in thread
From: David S. Miller @ 2005-02-25 23:43 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: benh, linux-arch

On Fri, 25 Feb 2005 10:32:57 +0100
Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:

> The change in the pte_clear prototype broke compilation on s390.
> The attached little patch takes care of that. Runs fine now.

ptep_get_and_clear() takes mm and addr argument now, and
ptep_clear_flush() takes vma, address, and ptep args now.

I'm very sure I didn't miss the asm-s390/pgtable.h instance.
And even weirder is that your patch is against a tree
where the ptep_get_and_clear() prototype was not updated:

--------------
@@ -550,7 +550,7 @@
 static inline pte_t ptep_get_and_clear(pte_t *ptep)
--------------

The only thing I could see breaking the build is that the structure
layout of "vma" is not available at the time pgtable.h is parsed, so
the vma->vm_mm causes a parse error.

In that case, please fix this simply by turning ptep_clear_flush()
(and thus ptep_establish) into a macro to fix the build as we have
done on the other platforms.

It is very useful to actually use set_pte_at() and pte_clear() whenever
possible, instead of open-coding things, so that you may experiment
quite simply with batched TLB flushing on your platform.

Please give this patch a shot.

===== include/asm-s390/pgtable.h 1.36 vs edited =====
--- 1.36/include/asm-s390/pgtable.h	2005-02-23 15:40:53 -08:00
+++ edited/include/asm-s390/pgtable.h	2005-02-25 15:09:14 -08:00
@@ -555,28 +555,31 @@
 	return pte;
 }
 
-static inline pte_t
-ptep_clear_flush(struct vm_area_struct *vma,
-		 unsigned long address, pte_t *ptep)
-{
-	pte_t pte = *ptep;
 #ifndef __s390x__
-	if (!(pte_val(pte) & _PAGE_INVALID)) {
-		/* S390 has 1mb segments, we are emulating 4MB segments */
-		pte_t *pto = (pte_t *) (((unsigned long) ptep) & 0x7ffffc00);
-		__asm__ __volatile__ ("ipte %2,%3"
-				      : "=m" (*ptep) : "m" (*ptep),
-				        "a" (pto), "a" (address) );
-	}
-#else /* __s390x__ */
-	if (!(pte_val(pte) & _PAGE_INVALID)) 
-		__asm__ __volatile__ ("ipte %2,%3"
-				      : "=m" (*ptep) : "m" (*ptep),
-				        "a" (ptep), "a" (address) );
-#endif /* __s390x__ */
-	pte_clear(vma->vm_mm, address, ptep);
-	return pte;
-}
+#define ptep_clear_flush(__vma,__addr,__ptep) \
+({	pte_t __pte = *(__ptep); \
+	if (!(pte_val(__pte) & _PAGE_INVALID)) { \
+		/* S390 has 1mb segments, we are emulating 4MB segments */ \
+		pte_t *__pto = (pte_t *) \
+		  (((unsigned long) (__ptep)) & 0x7ffffc00); \
+		__asm__ __volatile__ ("ipte %2,%3" \
+				      : "=m" (*(__ptep)) : "m" (*(__ptep)), \
+				        "a" (__pto), "a" (__addr) ); \
+	} \
+	pte_clear((__vma)->vm_mm, (__addr), (__ptep)); \
+	__pte; \
+})
+#else
+#define ptep_clear_flush(__vma,__addr,__ptep) \
+({	pte_t __pte = *(__ptep); \
+	if (!(pte_val(__pte) & _PAGE_INVALID))  \
+		__asm__ __volatile__ ("ipte %2,%3" \
+				      : "=m" (*(__ptep)) : "m" (*(__ptep)), \
+				        "a" (__ptep), "a" (__addr)); \
+	pte_clear((__vma)->vm_mm, (__addr), (__ptep)); \
+	__pte; \
+})
+#endif
 
 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
 {
@@ -584,14 +587,10 @@
 	set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
 }
 
-static inline void
-ptep_establish(struct vm_area_struct *vma, 
-	       unsigned long address, pte_t *ptep,
-	       pte_t entry)
-{
-	ptep_clear_flush(vma, address, ptep);
-	set_pte(ptep, entry);
-}
+#define ptep_establish(__vma, __addr, __ptep, __entry) \
+do {	ptep_clear_flush((__vma), (__addr), (__ptep)); \
+	set_pte((__ptep), (__entry)); \
+} while (0)
 
 #define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
 	ptep_establish(__vma, __address, __ptep, __entry)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-25 13:29   ` Paul Mundt
@ 2005-02-25 23:43     ` David S. Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David S. Miller @ 2005-02-25 23:43 UTC (permalink / raw)
  To: Paul Mundt; +Cc: linux-arch

On Fri, 25 Feb 2005 15:29:50 +0200
Paul Mundt <lethal@linux-sh.org> wrote:

> On Wed, Feb 23, 2005 at 04:11:38PM -0800, David S. Miller wrote:
> > I've been over this a few times this afternoon and the patch looks
> > correct.  Please test the build and boot of your platform, any build
> > failures should be trivial typos and nothing major.
> > 
> This works fine for sh and sh64 too.

Thanks for testing paul.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-25 23:43     ` David S. Miller
@ 2005-02-28  9:27       ` Martin Schwidefsky
  2005-03-01 23:30         ` David S. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Schwidefsky @ 2005-02-28  9:27 UTC (permalink / raw)
  To: David S. Miller; +Cc: benh, linux-arch

> The only thing I could see breaking the build is that the structure
> layout of "vma" is not available at the time pgtable.h is parsed, so
> the vma->vm_mm causes a parse error.

That is indeed the cause of the compile error on s390.

> In that case, please fix this simply by turning ptep_clear_flush()
> (and thus ptep_establish) into a macro to fix the build as we have
> done on the other platforms.

Please don't. There are too many macros from hell as things are now.
I prefer to sort out the compile errors with my inline functions than
to introduce more of that macro crap.

Simply expand the pte_clear inline into ptep_get_and_clear &
ptep_clear_flush gets you around the problem with deferencing "vma"
because on s390 we don't need the mm struct in pte_clear.

blue skies,
   Martin

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-02-28  9:27       ` Martin Schwidefsky
@ 2005-03-01 23:30         ` David S. Miller
  2005-03-02  8:23           ` Martin Schwidefsky
  0 siblings, 1 reply; 10+ messages in thread
From: David S. Miller @ 2005-03-01 23:30 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: benh, linux-arch

On Mon, 28 Feb 2005 10:27:03 +0100
Martin Schwidefsky <schwidefsky@de.ibm.com> wrote:

> > In that case, please fix this simply by turning ptep_clear_flush()
> > (and thus ptep_establish) into a macro to fix the build as we have
> > done on the other platforms.
> 
> Please don't. There are too many macros from hell as things are now.
> I prefer to sort out the compile errors with my inline functions than
> to introduce more of that macro crap.
> 
> Simply expand the pte_clear inline into ptep_get_and_clear &
> ptep_clear_flush gets you around the problem with deferencing "vma"
> because on s390 we don't need the mm struct in pte_clear.

I'll do as you wish no problem.

But you will need to address this should you ever want to
experiment with batched TLB flushing.  And I highly encourage
anyone with TLBs lacking true range flushing in hardware to
do so :-)  It is such an incredible improvement.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte())
  2005-03-01 23:30         ` David S. Miller
@ 2005-03-02  8:23           ` Martin Schwidefsky
  0 siblings, 0 replies; 10+ messages in thread
From: Martin Schwidefsky @ 2005-03-02  8:23 UTC (permalink / raw)
  To: David S. Miller; +Cc: benh, linux-arch

> But you will need to address this should you ever want to
> experiment with batched TLB flushing.  And I highly encourage
> anyone with TLBs lacking true range flushing in hardware to
> do so :-)  It is such an incredible improvement.

IDTE would be the instruction of choise on s390 for tlb range
flushing. I wanted to do some tlb work anyway to get rid of
the repeated flushes after process exit. There is no need to
flush every 500 odd pages, once is enough.

blue skies,
   Martin

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-03-02  8:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1109145729.5412.213.camel@gaston>
2005-02-24  0:11 ` [PATCH] set_pte() part 1 (was Re: [PATCH] ppc32: Wrong vaddr in flush_hash_one_pte()) David S. Miller
2005-02-25  9:32   ` Martin Schwidefsky
2005-02-25 23:43     ` David S. Miller
2005-02-28  9:27       ` Martin Schwidefsky
2005-03-01 23:30         ` David S. Miller
2005-03-02  8:23           ` Martin Schwidefsky
2005-02-25 13:29   ` Paul Mundt
2005-02-25 23:43     ` David S. Miller
2005-02-24  0:55 Luck, Tony
2005-02-24  4:02 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox