Skip to contentSkip to conversation

consolidate pte mapping functions across all architectures

RFC PATCH In review Dave Hansen 2 participants 38 messages May 20, 2009

Subsystems (26)
lore
Share & tools
lore
#0 lore raw

v2 cover consolidate pte mapping functions across all architectures

This should address all the comments made on the last set.

Is there a linux-next tree into which it would be appropriate to integrate these? They should probably have at least a bit of incubation time there or in -mm.
--

I want to use pte_offset_map() and pte_unmap() for nefarious purposes. But, there are too many dang implementations in all the architectures. These patches set out to consolidate them.

These are mostly one patch per arch to make it easier for the individual arch maintainers to go and look at only the bits that they care about.

In the end, we go from 34 implementations of pte_offset_map{_nested}() and pte_unmap{_nested}() to only three:
1. all highpte implementations (x86, ppc32, frv)
2. all direct-mapped pte implementations (everything almost)
3. SUN3-based m68k

The SUN3 one is special because it uses kmap() instead of kmap_atomic() for which it is wholly unique.

The diffstat is long, but here's the summary. Pretty cool considering that 41 of these lines are just for #includes.

 67 files changed, 62 insertions(+), 196 deletions(-)

The steps are as follows, and should be bisectable:
1. Break out all the functions into a new asm/ptemap.h and include it in place of the original functions.
2. Move linux/mm.h arch-independent pte mapping code to linux/ptemap.h, include asm/ptemap.h there
3. Include linux/ptemap.h directly at all use sites (only 39 of these kernel-wide)
4. Standardize all the implementations to use pte_offset_kernel() as the basis for pte_offset_map() whenever possible.
5. Create asm-generic/ptemap.h and consolidate all the architectures that share the pte_offset_kernel() implementations.
6. Consolidate the three HIGHPTE implementations (x86, frv, ppc64) in asm-generic/ptemap.h.
7. Remove the direct asm/ptemap.h includes.

This passes my compile tests on x86, x86_64, sparc, sparc64 s390, ppc64, ppc32, m68k, arm and alpha.

The pte_offset_kernel() migrations help fix the issue that there are two basical variants of pte_offset_map() which is the same for pte_offset_kernel() for !HIGHPTE (this has a few casts removed for clarity):

	#define pte_offset_map(dir, address)   \
	       (page_address(pmd_page(*dir)) + pte_index(address))
and
	#define pte_offset_map(dir, address)   \
	       (pmd_page_vaddr(*dir) + pte_index(addr))

As you can see, the pte_index() is exactly the same. The only question is if

page_address(pmd_page(*dir))
and
pmd_page_vaddr(*dir)

are equivalent. I claim they are and that the pmd_page_vaddr() version is superior since it doesn't need to do the conversion to a 'struct page' and back.

Let's look at those with pmd_page_vaddr() and pmd_page expanded:

	page_address(pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))

	__va(pmd_val(pmd) & PTE_PFN_MASK)

pmd pages are never in highmem, so page_address() is always effectively lowmem_page_address(). Epanding that, we have:

	__va(page_to_pfn(pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) << PAGE_SHIFT)

doing page_to_pfn(pfn_to_page()) is a noop, so that simplifies to:

	__va((pmd_val(pmd) >> PAGE_SHIFT) << PAGE_SHIFT)
which we're comparing to:
	__va(pmd_val(pmd) & PTE_PFN_MASK)

the '>> PAGE_SHIFT << PAGE_SHIFT' just has the effect of masking out some low bits, which is exactly what '& PTE_PFN_MASK' does.

 67 files changed, 62 insertions(+), 196 deletions(-)
 arch/alpha/include/asm/pgtable.h         |    5 +----
 arch/arm/include/asm/pgtable.h           |    8 ++------
 arch/arm/kernel/traps.c                  |    1 +
 arch/arm/mm/fault-armv.c                 |    1 +
 arch/arm/mm/fault.c                      |    1 +
 arch/arm/mm/pgd.c                        |    1 +
 arch/cris/include/asm/pgtable.h          |    6 ------
 arch/frv/include/asm/highmem.h           |    5 +++++
 arch/frv/include/asm/pgtable.h           |   17 +----------------
 arch/frv/kernel/gdb-stub.c               |    2 +-
 arch/frv/mm/fault.c                      |    2 +-
 arch/ia64/include/asm/pgtable.h          |    4 ----
 arch/ia64/mm/hugetlbpage.c               |    1 +
 arch/m32r/include/asm/pgtable.h          |    5 -----
 arch/m68k/include/asm/motorola_pgtable.h |    5 -----
 arch/m68k/include/asm/sun3_pgtable.h     |    5 -----
 arch/m68k/mm/kmap.c                      |    1 +
 arch/mips/include/asm/pgtable-32.h       |   10 +---------
 arch/mips/include/asm/pgtable-64.h       |   10 +---------
 arch/mips/mm/tlb-r4k.c                   |    1 +
 arch/mips/mm/tlb-r8k.c                   |    1 +
 arch/mn10300/include/asm/pgtable.h       |    6 ------
 arch/mn10300/mm/cache.c                  |    1 +
 arch/parisc/include/asm/pgtable.h        |    7 -------
 arch/parisc/kernel/cache.c               |    1 +
 arch/parisc/kernel/pci-dma.c             |    2 ++
 arch/powerpc/Kconfig                     |    4 ++++
 arch/powerpc/include/asm/pgtable-ppc32.h |    8 --------
 arch/powerpc/include/asm/pgtable-ppc64.h |    5 -----
 arch/powerpc/mm/pgtable_32.c             |    1 +
 arch/powerpc/mm/pgtable_64.c             |    1 +
 arch/powerpc/mm/subpage-prot.c           |    1 +
 arch/s390/include/asm/pgtable.h          |    4 ----
 arch/s390/lib/uaccess_pt.c               |    1 +
 arch/sh/include/asm/pgtable_32.h         |    5 -----
 arch/sh/include/asm/pgtable_64.h         |    5 -----
 arch/sh/mm/cache-sh5.c                   |    1 +
 arch/sh/mm/hugetlbpage.c                 |    1 +
 arch/sparc/include/asm/pgtable_32.h      |   15 ---------------
 arch/sparc/include/asm/pgtable_64.h      |   14 +++++---------
 arch/sparc/kernel/signal32.c             |    1 +
 arch/sparc/mm/fault_64.c                 |    1 +
 arch/sparc/mm/generic_64.c               |    1 +
 arch/sparc/mm/hugetlbpage.c              |    1 +
 arch/sparc/mm/io-unit.c                  |    1 +
 arch/sparc/mm/iommu.c                    |    1 +
 arch/um/include/asm/pgtable.h            |    6 ------
 arch/um/kernel/tlb.c                     |    1 +
 arch/x86/include/asm/pgtable_32.h        |   17 -----------------
 arch/x86/include/asm/pgtable_64.h        |    6 ------
 arch/x86/kernel/vm86_32.c                |    1 +
 arch/x86/mm/gup.c                        |    1 +
 arch/xtensa/include/asm/pgtable.h        |    6 ------
 fs/proc/task_mmu.c                       |    1 +
 include/linux/mm.h                       |   26 --------------------------
 lib/ioremap.c                            |    1 +
 mm/fremap.c                              |    1 +
 mm/memory.c                              |    1 +
 mm/mempolicy.c                           |    1 +
 mm/migrate.c                             |    1 +
 mm/mincore.c                             |    1 +
 mm/mprotect.c                            |    1 +
 mm/mremap.c                              |    1 +
 mm/pagewalk.c                            |    1 +
 mm/rmap.c                                |    1 +
 mm/swapfile.c                            |    1 +
 mm/vmalloc.c                             |    1 +
 67 files changed, 62 insertions(+), 196 deletions(-)
#1 lore raw

RFC PATCH v2 1/35 rename arm and frv's __pte_index()

The arm and frv __pte_index()es are the exact same as everyone else's pte_index(). So, remove the __ and give them the same name as all the other implementations.

---

 linux-2.6.git-dave/arch/arm/include/asm/pgtable.h |    8 ++++----
 linux-2.6.git-dave/arch/frv/include/asm/pgtable.h |    2 +-
 linux-2.6.git-dave/arch/frv/kernel/gdb-stub.c     |    2 +-
 linux-2.6.git-dave/arch/frv/mm/fault.c            |    2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/include/asm/pgtable.h renamed from arch/arm/include/asm/pgtable.h~rename-arm-__pte_index +4 -4
diff -puN arch/arm/include/asm/pgtable.h~rename-arm-__pte_index arch/arm/include/asm/pgtable.h
@@ -263,9 +263,9 @@ extern struct page *empty_zero_page;
 #define pte_none(pte)		(!pte_val(pte))
 #define pte_clear(mm,addr,ptep)	set_pte_ext(ptep, __pte(0), 0)
 #define pte_page(pte)		(pfn_to_page(pte_pfn(pte)))
-#define pte_offset_kernel(dir,addr)	(pmd_page_vaddr(*(dir)) + __pte_index(addr))
-#define pte_offset_map(dir,addr)	(pmd_page_vaddr(*(dir)) + __pte_index(addr))
-#define pte_offset_map_nested(dir,addr)	(pmd_page_vaddr(*(dir)) + __pte_index(addr))
+#define pte_offset_kernel(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
+#define pte_offset_map(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
+#define pte_offset_map_nested(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
 #define pte_unmap(pte)		do { } while (0)
 #define pte_unmap_nested(pte)	do { } while (0)
 
@@ -373,7 +373,7 @@ static inline pte_t *pmd_page_vaddr(pmd_
 #define pmd_offset(dir, addr)	((pmd_t *)(dir))
 
 /* Find an entry in the third-level page table.. */
-#define __pte_index(addr)	(((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+#define pte_index(addr)	(((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
arch/frv/include/asm/pgtable.h renamed from arch/frv/include/asm/pgtable.h~rename-arm-__pte_index +1 -1
diff -puN arch/frv/include/asm/pgtable.h~rename-arm-__pte_index arch/frv/include/asm/pgtable.h
@@ -436,7 +436,7 @@ static inline pte_t pte_modify(pte_t pte
 #define pgd_index_k(addr) pgd_index(addr)
 
 /* Find an entry in the bottom-level page table.. */
-#define __pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 
 /*
  * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
arch/frv/kernel/gdb-stub.c renamed from arch/frv/kernel/gdb-stub.c~rename-arm-__pte_index +1 -1
diff -puN arch/frv/kernel/gdb-stub.c~rename-arm-__pte_index arch/frv/kernel/gdb-stub.c
@@ -465,7 +465,7 @@ static inline unsigned long gdbstub_virt
 	__set_DAMPR(5, val | xAMPRx_L | xAMPRx_SS_16Kb | xAMPRx_S | xAMPRx_C | xAMPRx_V);
 
 	/* now its safe to access pmd */
-	pte = (pte_t *)__get_DAMLR(5) + __pte_index(vaddr);
+	pte = (pte_t *)__get_DAMLR(5) + pte_index(vaddr);
 	if (pte_present(*pte))
 		val = pte_val(*pte);
 	else
arch/frv/mm/fault.c renamed from arch/frv/mm/fault.c~rename-arm-__pte_index +1 -1
diff -puN arch/frv/mm/fault.c~rename-arm-__pte_index arch/frv/mm/fault.c
@@ -240,7 +240,7 @@ asmlinkage void do_page_fault(int datamm
 			     : "r" (_pme | xAMPRx_L|xAMPRx_SS_16Kb|xAMPRx_S|xAMPRx_C|xAMPRx_V)
 			     );
 
-		pte = (pte_t *) damlr + __pte_index(ear0);
+		pte = (pte_t *) damlr + pte_index(ear0);
 		val = pte_val(*pte);
 
 		asm volatile("movgs %0,dampr2" :: "r" (dampr));

_

#2 lore raw

RFC PATCH v2 2/35 rework sparc pte functions to be consistent with other arches

In reply to Dave Hansen

sparc64 has a unique unusual pte_index(). All other architectures just take a virtual address and give back the offset inside the pte page of that address's pte.

The sparc64 one actually takes both the pmd_t and the virtual address and returns the pte_t itself. This is more akin to what pte_offset_map() does on all the other implementations.

This patch adds a new implementations of pte_index() and pmd_page_vaddr() which are pretty straighforward and just copied from other architectures.

Then, we use the new functions in pte_offset_kernel(). We use pte_offset_kernel() as the base from which we define pte_offset_map() and pte_offset_map_nested().

All of this brings sparc64 back inline with what all the other architectures are doing and prepares it for things to come. :)

---

 linux-2.6.git-dave/arch/sparc/include/asm/pgtable_64.h |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
arch/sparc/include/asm/pgtable_64.h renamed from arch/sparc/include/asm/pgtable_64.h~rename-sparc-pte_index +7 -6
diff -puN arch/sparc/include/asm/pgtable_64.h~rename-sparc-pte_index arch/sparc/include/asm/pgtable_64.h
@@ -619,6 +619,7 @@ static inline int pte_special(pte_t pte)
 #define __pmd_page(pmd)		\
 	((unsigned long) __va((((unsigned long)pmd_val(pmd))<<11UL)))
 #define pmd_page(pmd) 			virt_to_page((void *)__pmd_page(pmd))
+#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
 #define pud_page_vaddr(pud)		\
 	((unsigned long) __va((((unsigned long)pud_val(pud))<<11UL)))
 #define pud_page(pud) 			virt_to_page((void *)pud_page_vaddr(pud))
@@ -646,13 +647,13 @@ static inline int pte_special(pte_t pte)
 	((pmd_t *) pud_page_vaddr(*(pudp)) + \
 	 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)))
 
+#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+
 /* Find an entry in the third-level page table.. */
-#define pte_index(dir, address)	\
-	((pte_t *) __pmd_page(*(dir)) + \
-	 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-#define pte_offset_kernel		pte_index
-#define pte_offset_map			pte_index
-#define pte_offset_map_nested		pte_index
+#define pte_offset_kernel(dir, address)	\
+	((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
+#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
+#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
 #define pte_unmap(pte)			do { } while (0)
 #define pte_unmap_nested(pte)		do { } while (0)
 

_

#3 lore raw

RFC PATCH v2 3/35 alpha: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/alpha/include/asm/pgtable.h |    5 +----
 linux-2.6.git-dave/arch/alpha/include/asm/ptemap.h  |    9 +++++++++
 2 files changed, 10 insertions(+), 4 deletions(-)
arch/alpha/include/asm/pgtable.h renamed from arch/alpha/include/asm/pgtable.h~alpha-ptemaph +1 -4
diff -puN arch/alpha/include/asm/pgtable.h~alpha-ptemaph arch/alpha/include/asm/pgtable.h
@@ -317,10 +317,7 @@ extern inline pte_t * pte_offset_kernel(
 	return ret;
 }
 
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
+#include <asm/ptemap.h>
 
 extern pgd_t swapper_pg_dir[1024];
 
arch/alpha/include/asm/ptemap.h new file +9 -0
diff -puN /dev/null arch/alpha/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _ALPHA_ASM_PTEMAP_H
+#define _ALPHA_ASM_PTEMAP_H
+
+#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
+#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
+#define pte_unmap(pte)			do { } while (0)
+#define pte_unmap_nested(pte)		do { } while (0)
+
+#endif /* _ALPHA_ASM_PTEMAP_H */

_

#4 lore raw

RFC PATCH v2 4/35 arm: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/arm/include/asm/pgtable.h |    6 ++----
 linux-2.6.git-dave/arch/arm/include/asm/ptemap.h  |    9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/arm/include/asm/pgtable.h renamed from arch/arm/include/asm/pgtable.h~arm-ptemaph +2 -4
diff -puN arch/arm/include/asm/pgtable.h~arm-ptemaph arch/arm/include/asm/pgtable.h
@@ -264,10 +264,8 @@ extern struct page *empty_zero_page;
 #define pte_clear(mm,addr,ptep)	set_pte_ext(ptep, __pte(0), 0)
 #define pte_page(pte)		(pfn_to_page(pte_pfn(pte)))
 #define pte_offset_kernel(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map_nested(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
+
+#include <asm/ptemap.h>
 
 #define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
 
arch/arm/include/asm/ptemap.h new file +9 -0
diff -puN /dev/null arch/arm/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _ARM_ASM_PTEMAP_H
+#define _ARM_ASM_PTEMAP_H
+
+#define pte_offset_map(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
+#define pte_offset_map_nested(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
+#define pte_unmap(pte)		do { } while (0)
+#define pte_unmap_nested(pte)	do { } while (0)
+
+#endif /* _ARM_ASM_PTEMAP_H */

_

#5 lore raw

RFC PATCH v2 5/35 avr32: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/avr32/include/asm/ptemap.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/avr32/include/asm/ptemap.h new file +9 -0
diff -puN /dev/null arch/avr32/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _AVR32_ASM_PTEMAP_H
+#define _AVR32_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
+#define pte_unmap(pte)		do { } while (0)
+#define pte_unmap_nested(pte)	do { } while (0)
+
+#endif /* _AVR32_ASM_PTEMAP_H */

_

#6 lore raw

RFC PATCH v2 6/35 cris: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/cris/include/asm/pgtable.h |    7 +------
 linux-2.6.git-dave/arch/cris/include/asm/ptemap.h  |   11 +++++++++++
 2 files changed, 12 insertions(+), 6 deletions(-)
arch/cris/include/asm/pgtable.h renamed from arch/cris/include/asm/pgtable.h~cris-ptemaph +1 -6
diff -puN arch/cris/include/asm/pgtable.h~cris-ptemaph arch/cris/include/asm/pgtable.h
@@ -244,12 +244,7 @@ static inline pgd_t * pgd_offset(const s
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  __pte_offset(address))
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
-
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
+#include <asm/ptemap.h>
 #define pte_pfn(x)		((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)
 #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
arch/cris/include/asm/ptemap.h renamed from arch/cris/include/asm/ptemap.h~cris-ptemaph +11 -0
diff -puN arch/cris/include/asm/ptemap.h~cris-ptemaph arch/cris/include/asm/ptemap.h
@@ -0,0 +1,11 @@
+#ifndef _CRIS_ASM_PTEMAP_H
+#define _CRIS_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address) \
+	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+
+#endif /* _CRIS_ASM_PTEMAP_H */

_

#7 lore raw

RFC PATCH v2 7/35 frv: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/frv/include/asm/pgtable.h |   15 +--------------
 linux-2.6.git-dave/arch/frv/include/asm/ptemap.h  |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 14 deletions(-)
arch/frv/include/asm/pgtable.h renamed from arch/frv/include/asm/pgtable.h~frv-ptemaph +1 -14
diff -puN arch/frv/include/asm/pgtable.h~frv-ptemaph arch/frv/include/asm/pgtable.h
@@ -449,20 +449,7 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  pte_index(address))
 
-#if defined(CONFIG_HIGHPTE)
-#define pte_offset_map(dir, address) \
-	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
-#define pte_offset_map_nested(dir, address) \
-	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
-#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
-#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
-#else
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-#endif
+#include <asm/ptemap.h>
 
 /*
  * Handle swap and file entries
arch/frv/include/asm/ptemap.h renamed from arch/frv/include/asm/ptemap.h~frv-ptemaph +19 -0
diff -puN arch/frv/include/asm/ptemap.h~frv-ptemaph arch/frv/include/asm/ptemap.h
@@ -0,0 +1,19 @@
+#ifndef _FRV_ASM_PTEMAP_H
+#define _FRV_ASM_PTEMAP_H
+
+#if defined(CONFIG_HIGHPTE)
+#define pte_offset_map(dir, address) \
+	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
+#define pte_offset_map_nested(dir, address) \
+	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
+#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
+#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
+#else
+#define pte_offset_map(dir, address) \
+	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+#endif
+
+#endif /* _FRV_ASM_PTEMAP_H */

_

#8 lore raw

RFC PATCH v2 8/35 ia64: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/ia64/include/asm/pgtable.h |    6 ++----
 linux-2.6.git-dave/arch/ia64/include/asm/ptemap.h  |    9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/ia64/include/asm/pgtable.h renamed from arch/ia64/include/asm/pgtable.h~ia64-ptemaph +2 -4
diff -puN arch/ia64/include/asm/pgtable.h~ia64-ptemaph arch/ia64/include/asm/pgtable.h
@@ -405,10 +405,8 @@ pgd_offset (const struct mm_struct *mm, 
  */
 #define pte_index(addr)	 	(((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir,addr)	((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir,addr)	pte_offset_kernel(dir, addr)
-#define pte_offset_map_nested(dir,addr)	pte_offset_map(dir, addr)
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
+
+#include <asm/ptemap.h>
 
 /* atomic versions of the some PTE manipulations: */
 
arch/ia64/include/asm/ptemap.h renamed from arch/ia64/include/asm/ptemap.h~ia64-ptemaph +9 -0
diff -puN arch/ia64/include/asm/ptemap.h~ia64-ptemaph arch/ia64/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _IA64_ASM_PTEMAP_H
+#define _IA64_ASM_PTEMAP_H
+
+#define pte_offset_map(dir,addr)	pte_offset_kernel(dir, addr)
+#define pte_offset_map_nested(dir,addr)	pte_offset_map(dir, addr)
+#define pte_unmap(pte)			do { } while (0)
+#define pte_unmap_nested(pte)		do { } while (0)
+
+#endif /* _IA64_ASM_PTEMAP_H */

_

#9 lore raw

RFC PATCH v2 9/35 m32r: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/m32r/include/asm/pgtable.h |    6 +-----
 linux-2.6.git-dave/arch/m32r/include/asm/ptemap.h  |   10 ++++++++++
 2 files changed, 11 insertions(+), 5 deletions(-)
arch/m32r/include/asm/pgtable.h renamed from arch/m32r/include/asm/pgtable.h~m32r-ptemaph +1 -5
diff -puN arch/m32r/include/asm/pgtable.h~m32r-ptemaph arch/m32r/include/asm/pgtable.h
@@ -330,11 +330,7 @@ static inline void pmd_set(pmd_t * pmdp,
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address)	\
 	((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address)	\
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address)	pte_offset_map(dir, address)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
+#include <asm/ptemap.h>
 
 /* Encode and de-code a swap entry */
 #define __swp_type(x)			(((x).val >> 2) & 0x1f)
arch/m32r/include/asm/ptemap.h renamed from arch/m32r/include/asm/ptemap.h~m32r-ptemaph +10 -0
diff -puN arch/m32r/include/asm/ptemap.h~m32r-ptemaph arch/m32r/include/asm/ptemap.h
@@ -0,0 +1,10 @@
+#ifndef _M32R_ASM_PTEMAP_H
+#define _M32R_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address)	\
+	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address)	pte_offset_map(dir, address)
+#define pte_unmap(pte)		do { } while (0)
+#define pte_unmap_nested(pte)	do { } while (0)
+
+#endif /* _M32R_ASM_PTEMAP_H */

_

#10 lore raw

RFC PATCH v2 10/35 m68k: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/m68k/include/asm/motorola_pgtable.h |    5 --
 linux-2.6.git-dave/arch/m68k/include/asm/ptemap.h           |   22 ++++++++++++
 linux-2.6.git-dave/arch/m68k/include/asm/sun3_pgtable.h     |    6 +--
 3 files changed, 25 insertions(+), 8 deletions(-)
arch/m68k/include/asm/motorola_pgtable.h renamed from arch/m68k/include/asm/motorola_pgtable.h~m68k-ptemaph +1 -4
diff -puN arch/m68k/include/asm/motorola_pgtable.h~m68k-ptemaph arch/m68k/include/asm/motorola_pgtable.h
@@ -220,10 +220,7 @@ static inline pte_t *pte_offset_kernel(p
 	return (pte_t *)__pmd_page(*pmdp) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
 }
 
-#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-#define pte_offset_map_nested(pmdp, address) pte_offset_map(pmdp, address)
-#define pte_unmap(pte)		((void)0)
-#define pte_unmap_nested(pte)	((void)0)
+#include <asm/ptemap.h>
 
 /*
  * Allocate and free page tables. The xxx_kernel() versions are
arch/m68k/include/asm/ptemap.h new file +22 -0
diff -puN /dev/null arch/m68k/include/asm/ptemap.h
@@ -0,0 +1,22 @@
+#ifndef _M68K_ASM_PTEMAP_H
+#define _M68K_ASM_PTEMAP_H
+
+#ifdef CONFIG_SUN3
+
+#include <linux/mm.h>
+
+#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address))
+#define pte_offset_map_nested(pmd, address) pte_offset_map(pmd, address)
+#define pte_unmap(pte) kunmap(pte)
+#define pte_unmap_nested(pte) kunmap(pte)
+
+#else /* !CONFIG_SUN3, Motorola */
+
+#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
+#define pte_offset_map_nested(pmdp, address) pte_offset_map(pmdp, address)
+#define pte_unmap(pte)		((void)0)
+#define pte_unmap_nested(pte)	((void)0)
+
+#endif /* CONFIG_SUN3 */
+
+#endif /* _M68K_ASM_PTEMAP_H */
arch/m68k/include/asm/sun3_pgtable.h renamed from arch/m68k/include/asm/sun3_pgtable.h~m68k-ptemaph +2 -4
diff -puN arch/m68k/include/asm/sun3_pgtable.h~m68k-ptemaph arch/m68k/include/asm/sun3_pgtable.h
@@ -218,10 +218,8 @@ static inline pte_t pgoff_to_pte(unsigne
 #define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
 #define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address))
 /* FIXME: should we bother with kmap() here? */
-#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address))
-#define pte_offset_map_nested(pmd, address) pte_offset_map(pmd, address)
-#define pte_unmap(pte) kunmap(pte)
-#define pte_unmap_nested(pte) kunmap(pte)
+
+#include <asm/ptemap.h>
 
 /* Macros to (de)construct the fake PTEs representing swap pages. */
 #define __swp_type(x)		((x).val & 0x7F)

_

#11 lore raw

RFC PATCH v2 11/35 mips: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/mips/include/asm/pgtable-32.h |    8 ------
 linux-2.6.git-dave/arch/mips/include/asm/pgtable-64.h |    8 ------
 linux-2.6.git-dave/arch/mips/include/asm/ptemap.h     |   22 ++++++++++++++++++
 3 files changed, 24 insertions(+), 14 deletions(-)
arch/mips/include/asm/pgtable-32.h renamed from arch/mips/include/asm/pgtable-32.h~mips-ptemaph +1 -7
diff -puN arch/mips/include/asm/pgtable-32.h~mips-ptemaph arch/mips/include/asm/pgtable-32.h
@@ -151,13 +151,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_kernel(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-
-#define pte_offset_map(dir, address)                                    \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address)                             \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-#define pte_unmap_nested(pte) ((void)(pte))
+#include <asm/ptemap.h>
 
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
 
arch/mips/include/asm/pgtable-64.h renamed from arch/mips/include/asm/pgtable-64.h~mips-ptemaph +1 -7
diff -puN arch/mips/include/asm/pgtable-64.h~mips-ptemaph arch/mips/include/asm/pgtable-64.h
@@ -215,13 +215,7 @@ static inline pmd_t *pmd_offset(pud_t * 
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_kernel(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_map(dir, address)					\
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address)				\
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-#define pte_unmap_nested(pte) ((void)(pte))
-
+#include <asm/ptemap.h>
 /*
  * Initialize a new pgd / pmd table with invalid pointers.
  */
arch/mips/include/asm/ptemap.h new file +22 -0
diff -puN /dev/null arch/mips/include/asm/ptemap.h
@@ -0,0 +1,22 @@
+#ifndef _MIPS_ASM_PTEMAP_H
+#define _MIPS_ASM_PTEMAP_H
+
+#ifdef CONFIG_32BIT
+#define pte_offset_map(dir, address)                                    \
+	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_offset_map_nested(dir, address)                             \
+	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_unmap(pte) ((void)(pte))
+#define pte_unmap_nested(pte) ((void)(pte))
+#endif
+
+#ifdef CONFIG_64BIT
+#define pte_offset_map(dir, address)					\
+	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_offset_map_nested(dir, address)				\
+	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_unmap(pte) ((void)(pte))
+#define pte_unmap_nested(pte) ((void)(pte))
+#endif
+
+#endif /* _MIPS_ASM_PTEMAP_H */

_

#12 lore raw

RFC PATCH v2 12/35 mn10300: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/mn10300/include/asm/pgtable.h |    6 +-----
 linux-2.6.git-dave/arch/mn10300/include/asm/ptemap.h  |   10 ++++++++++
 2 files changed, 11 insertions(+), 5 deletions(-)
arch/mn10300/include/asm/pgtable.h renamed from arch/mn10300/include/asm/pgtable.h~mn10300-ptemaph +1 -5
diff -puN arch/mn10300/include/asm/pgtable.h~mn10300-ptemaph arch/mn10300/include/asm/pgtable.h
@@ -455,11 +455,7 @@ static inline int set_kernel_exec(unsign
 	return 0;
 }
 
-#define pte_offset_map(dir, address) \
-	((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
-#define pte_unmap(pte)		do {} while (0)
-#define pte_unmap_nested(pte)	do {} while (0)
+#include <asm/ptemap.h>
 
 /*
  * The MN10300 has external MMU info in the form of a TLB: this is adapted from
arch/mn10300/include/asm/ptemap.h renamed from arch/mn10300/include/asm/ptemap.h~mn10300-ptemaph +10 -0
diff -puN arch/mn10300/include/asm/ptemap.h~mn10300-ptemaph arch/mn10300/include/asm/ptemap.h
@@ -0,0 +1,10 @@
+#ifndef _MN10300_ASM_PTEMAP_H
+#define _MN10300_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address) \
+	((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_unmap(pte)		do {} while (0)
+#define pte_unmap_nested(pte)	do {} while (0)
+
+#endif /* _MN10300_ASM_PTEMAP_H */

_

#13 lore raw

RFC PATCH v2 13/35 parisc: create ptemap.h

In reply to Dave Hansen

Note that parisc already had two pte_unmap{_unmap}() #defines. This removes the dup in addition to moving them.

---

 linux-2.6.git-dave/arch/parisc/include/asm/pgtable.h |    7 +------
 linux-2.6.git-dave/arch/parisc/include/asm/ptemap.h  |    9 +++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)
arch/parisc/include/asm/pgtable.h renamed from arch/parisc/include/asm/pgtable.h~parisc-ptemaph +1 -6
diff -puN arch/parisc/include/asm/pgtable.h~parisc-ptemaph arch/parisc/include/asm/pgtable.h
@@ -396,13 +396,8 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
 #define pte_offset_kernel(pmd, address) \
 	((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address))
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
 
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
+#include <asm/ptemap.h>
 
 extern void paging_init (void);
 
arch/parisc/include/asm/ptemap.h new file +9 -0
diff -puN /dev/null arch/parisc/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _PARISC_ASM_PTEMAP_H
+#define _PARISC_ASM_PTEMAP_H
+
+#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
+#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+
+#endif /* _PARISC_ASM_PTEMAP_H */

_

#14 lore raw

RFC PATCH v2 14/35 powerpc: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/powerpc/include/asm/pgtable-ppc32.h |    8 ----
 linux-2.6.git-dave/arch/powerpc/include/asm/pgtable-ppc64.h |    5 --
 linux-2.6.git-dave/arch/powerpc/include/asm/ptemap.h        |   23 ++++++++++++
 3 files changed, 24 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/pgtable-ppc32.h renamed from arch/powerpc/include/asm/pgtable-ppc32.h~powerpc-ptemaph +0 -8
diff -puN arch/powerpc/include/asm/pgtable-ppc32.h~powerpc-ptemaph arch/powerpc/include/asm/pgtable-ppc32.h
@@ -284,14 +284,6 @@ static inline void __ptep_set_access_fla
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, addr)	\
 	((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir, addr)		\
-	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr))
-#define pte_offset_map_nested(dir, addr)	\
-	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
-
-#define pte_unmap(pte)		kunmap_atomic(pte, KM_PTE0)
-#define pte_unmap_nested(pte)	kunmap_atomic(pte, KM_PTE1)
-
 /*
  * Encode and decode a swap entry.
  * Note that the bits we use in a PTE for representing a swap entry
arch/powerpc/include/asm/pgtable-ppc64.h renamed from arch/powerpc/include/asm/pgtable-ppc64.h~powerpc-ptemaph +1 -4
diff -puN arch/powerpc/include/asm/pgtable-ppc64.h~powerpc-ptemaph arch/powerpc/include/asm/pgtable-ppc64.h
@@ -162,10 +162,7 @@
 #define pte_offset_kernel(dir,addr) \
   (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
 
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir), (addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir), (addr))
-#define pte_unmap(pte)			do { } while(0)
-#define pte_unmap_nested(pte)		do { } while(0)
+#include <asm/ptemap.h>
 
 /* to find an entry in a kernel page-table-directory */
 /* This now only contains the vmalloc pages */
arch/powerpc/include/asm/ptemap.h new file +23 -0
diff -puN /dev/null arch/powerpc/include/asm/ptemap.h
@@ -0,0 +1,23 @@
+#ifndef _POWERPC_ASM_PTEMAP_H
+#define _POWERPC_ASM_PTEMAP_H
+
+#ifndef __powerpc64__
+
+#define pte_offset_map(dir, addr)		\
+	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr))
+#define pte_offset_map_nested(dir, addr)	\
+	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
+
+#define pte_unmap(pte)		kunmap_atomic(pte, KM_PTE0)
+#define pte_unmap_nested(pte)	kunmap_atomic(pte, KM_PTE1)
+
+#else /* __powerpc64__ */
+
+#define pte_offset_map(dir,addr)	pte_offset_kernel((dir), (addr))
+#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir), (addr))
+#define pte_unmap(pte)			do { } while(0)
+#define pte_unmap_nested(pte)		do { } while(0)
+
+#endif
+
+#endif /* _POWERPC_ASM_PTEMAP_H */

_

#15 lore raw

RFC PATCH v2 15/35 s390: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/s390/include/asm/pgtable.h |    6 ++----
 linux-2.6.git-dave/arch/s390/include/asm/ptemap.h  |    9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
arch/s390/include/asm/pgtable.h renamed from arch/s390/include/asm/pgtable.h~s390-ptemaph +2 -4
diff -puN arch/s390/include/asm/pgtable.h~s390-ptemaph arch/s390/include/asm/pgtable.h
@@ -1040,10 +1040,8 @@ static inline pmd_t *pmd_offset(pud_t *p
 /* Find an entry in the lowest level page table.. */
 #define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))
 #define pte_offset_kernel(pmd, address) pte_offset(pmd,address)
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
+
+#include <asm/ptemap.h>
 
 /*
  * 31 bit swap entry format:
arch/s390/include/asm/ptemap.h renamed from arch/s390/include/asm/ptemap.h~s390-ptemaph +9 -0
diff -puN arch/s390/include/asm/ptemap.h~s390-ptemaph arch/s390/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _S390_ASM_PTEMAP_H
+#define _S390_ASM_PTEMAP_H
+
+#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
+#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+
+#endif /* _S390_ASM_PTEMAP_H */

_

#16 lore raw

RFC PATCH v2 16/35 sh: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/sh/include/asm/pgtable_32.h |    6 +-----
 linux-2.6.git-dave/arch/sh/include/asm/pgtable_64.h |    5 +----
 linux-2.6.git-dave/arch/sh/include/asm/ptemap.h     |    9 +++++++++
 3 files changed, 11 insertions(+), 9 deletions(-)
arch/sh/include/asm/pgtable_32.h renamed from arch/sh/include/asm/pgtable_32.h~sh-ptemaph +1 -5
diff -puN arch/sh/include/asm/pgtable_32.h~sh-ptemaph arch/sh/include/asm/pgtable_32.h
@@ -403,11 +403,7 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_index(address)	((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address)		pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
-
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
+#include <asm/ptemap.h>
 
 #ifdef CONFIG_X2TLB
 #define pte_ERROR(e) \
arch/sh/include/asm/pgtable_64.h renamed from arch/sh/include/asm/pgtable_64.h~sh-ptemaph +1 -4
diff -puN arch/sh/include/asm/pgtable_64.h~sh-ptemaph arch/sh/include/asm/pgtable_64.h
@@ -83,10 +83,7 @@ static __inline__ void pmd_set(pmd_t *pm
 #define pte_offset_kernel(dir, addr) \
 		((pte_t *) ((pmd_val(*(dir))) & PAGE_MASK) + pte_index((addr)))
 
-#define pte_offset_map(dir,addr)	pte_offset_kernel(dir, addr)
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel(dir, addr)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
+#include <asm/ptemap.h>
 
 #ifndef __ASSEMBLY__
 #define IOBASE_VADDR	0xff000000
arch/sh/include/asm/ptemap.h new file +9 -0
diff -puN /dev/null arch/sh/include/asm/ptemap.h
@@ -0,0 +1,9 @@
+#ifndef _SH_ASM_PTEMAP_H
+#define _SH_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address)		pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
+#define pte_unmap(pte)		do { } while (0)
+#define pte_unmap_nested(pte)	do { } while (0)
+
+#endif /* _SH_ASM_PTEMAP_H */

_

#17 lore raw

RFC PATCH v2 17/35 sparc: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/sparc/include/asm/pgtable_32.h |   10 -------
 linux-2.6.git-dave/arch/sparc/include/asm/pgtable_64.h |    5 ---
 linux-2.6.git-dave/arch/sparc/include/asm/ptemap.h     |   24 +++++++++++++++++
 3 files changed, 26 insertions(+), 13 deletions(-)
arch/sparc/include/asm/pgtable_32.h renamed from arch/sparc/include/asm/pgtable_32.h~sparc-ptemaph +1 -9
diff -puN arch/sparc/include/asm/pgtable_32.h~sparc-ptemaph arch/sparc/include/asm/pgtable_32.h
@@ -300,15 +300,7 @@ BTFIXUPDEF_CALL(pmd_t *, pmd_offset, pgd
 BTFIXUPDEF_CALL(pte_t *, pte_offset_kernel, pmd_t *, unsigned long)
 #define pte_offset_kernel(dir,addr) BTFIXUP_CALL(pte_offset_kernel)(dir,addr)
 
-/*
- * This shortcut works on sun4m (and sun4d) because the nocache area is static,
- * and sun4c is guaranteed to have no highmem anyway.
- */
-#define pte_offset_map(d, a)		pte_offset_kernel(d,a)
-#define pte_offset_map_nested(d, a)	pte_offset_kernel(d,a)
-
-#define pte_unmap(pte)		do{}while(0)
-#define pte_unmap_nested(pte)	do{}while(0)
+#include <asm/ptemap.h>
 
 /* Certain architectures need to do special things when pte's
  * within a page table are directly modified.  Thus, the following
arch/sparc/include/asm/pgtable_64.h renamed from arch/sparc/include/asm/pgtable_64.h~sparc-ptemaph +1 -4
diff -puN arch/sparc/include/asm/pgtable_64.h~sparc-ptemaph arch/sparc/include/asm/pgtable_64.h
@@ -652,10 +652,7 @@ static inline int pte_special(pte_t pte)
 /* Find an entry in the third-level page table.. */
 #define pte_offset_kernel(dir, address)	\
 	((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
-#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
-#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
+#include <asm/ptemap.h>
 
 /* Actual page table PTE updates.  */
 extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig);
arch/sparc/include/asm/ptemap.h new file +24 -0
diff -puN /dev/null arch/sparc/include/asm/ptemap.h
@@ -0,0 +1,24 @@
+#ifndef _SPARC_ASM_PTEMAP_H
+#define _SPARC_ASM_PTEMAP_H
+
+#if defined(__sparc__) && defined(__arch64__)
+
+#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
+#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
+#define pte_unmap(pte)			do { } while (0)
+#define pte_unmap_nested(pte)		do { } while (0)
+
+#else
+/*
+ * This shortcut works on sun4m (and sun4d) because the nocache area is static,
+ * and sun4c is guaranteed to have no highmem anyway.
+ */
+#define pte_offset_map(d, a)		pte_offset_kernel(d,a)
+#define pte_offset_map_nested(d, a)	pte_offset_kernel(d,a)
+
+#define pte_unmap(pte)		do{}while(0)
+#define pte_unmap_nested(pte)	do{}while(0)
+
+#endif
+
+#endif /* _SPARC_ASM_PTEMAP_H */

_

#18 lore raw

RFC PATCH v2 18/35 um: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/um/include/asm/pgtable.h |    7 +------
 linux-2.6.git-dave/arch/um/include/asm/ptemap.h  |   10 ++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)
arch/um/include/asm/pgtable.h renamed from arch/um/include/asm/pgtable.h~um-ptemaph +1 -6
diff -puN arch/um/include/asm/pgtable.h~um-ptemaph arch/um/include/asm/pgtable.h
@@ -331,12 +331,7 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  pte_index(address))
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-
+#include <asm/ptemap.h>
 struct mm_struct;
 extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
 
arch/um/include/asm/ptemap.h renamed from arch/um/include/asm/ptemap.h~um-ptemaph +10 -0
diff -puN arch/um/include/asm/ptemap.h~um-ptemaph arch/um/include/asm/ptemap.h
@@ -0,0 +1,10 @@
+#ifndef _UM_ASM_PTEMAP_H
+#define _UM_ASM_PTEMAP_H
+
+#define pte_offset_map(dir, address) \
+	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+
+#endif /* _UM_ASM_PTEMAP_H */

_

#19 lore raw

RFC PATCH v2 19/35 x86: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/x86/include/asm/pgtable_32.h |   17 ---------
 linux-2.6.git-dave/arch/x86/include/asm/pgtable_64.h |    6 ---
 linux-2.6.git-dave/arch/x86/include/asm/ptemap.h     |   34 +++++++++++++++++++
 3 files changed, 36 insertions(+), 21 deletions(-)
arch/x86/include/asm/pgtable_32.h renamed from arch/x86/include/asm/pgtable_32.h~x86-ptemaph +1 -16
diff -puN arch/x86/include/asm/pgtable_32.h~x86-ptemaph arch/x86/include/asm/pgtable_32.h
@@ -48,22 +48,7 @@ extern void set_pmd_pfn(unsigned long, u
 # include <asm/pgtable-2level.h>
 #endif
 
-#if defined(CONFIG_HIGHPTE)
-#define pte_offset_map(dir, address)					\
-	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
-	 pte_index((address)))
-#define pte_offset_map_nested(dir, address)				\
-	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) +		\
-	 pte_index((address)))
-#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
-#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
-#else
-#define pte_offset_map(dir, address)					\
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
-#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-#endif
+#include <asm/ptemap.h>
 
 /* Clear a kernel PTE and flush it from the TLB */
 #define kpte_clear_flush(ptep, vaddr)		\
arch/x86/include/asm/pgtable_64.h renamed from arch/x86/include/asm/pgtable_64.h~x86-ptemaph +1 -5
diff -puN arch/x86/include/asm/pgtable_64.h~x86-ptemaph arch/x86/include/asm/pgtable_64.h
@@ -127,11 +127,7 @@ static inline int pgd_large(pgd_t pgd) {
 
 /* PTE - Level 1 access. */
 
-/* x86-64 always has all page tables mapped. */
-#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
-#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte) /* NOP */
-#define pte_unmap_nested(pte) /* NOP */
+#include <asm/ptemap.h>
 
 #define update_mmu_cache(vma, address, pte) do { } while (0)
 
arch/x86/include/asm/ptemap.h new file +34 -0
diff -puN /dev/null arch/x86/include/asm/ptemap.h
@@ -0,0 +1,34 @@
+#ifndef _X86_ASM_PTEMAP_H
+#define _X86_ASM_PTEMAP_H
+
+#ifdef CONFIG_X86_32
+
+#if defined(CONFIG_HIGHPTE)
+
+#define pte_offset_map(dir, address)					\
+	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
+	 pte_index((address)))
+#define pte_offset_map_nested(dir, address)				\
+	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) +		\
+	 pte_index((address)))
+#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
+#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
+#else
+#define pte_offset_map(dir, address)					\
+	((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
+#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+#endif
+
+#else /* x86-64 */
+
+/* x86-64 always has all page tables mapped. */
+#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
+#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
+#define pte_unmap(pte) /* NOP */
+#define pte_unmap_nested(pte) /* NOP */
+
+#endif
+
+#endif /* _X86_ASM_PTEMAP_H */

_

#20 lore raw

RFC PATCH v2 20/35 xtensa: create ptemap.h

In reply to Dave Hansen

---

 linux-2.6.git-dave/arch/xtensa/include/asm/pgtable.h |    6 ------
 linux-2.6.git-dave/arch/xtensa/include/asm/ptemap.h  |   10 ++++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)
arch/xtensa/include/asm/pgtable.h renamed from arch/xtensa/include/asm/pgtable.h~xtensa-ptemaph +0 -6
diff -puN arch/xtensa/include/asm/pgtable.h~xtensa-ptemaph arch/xtensa/include/asm/pgtable.h
@@ -323,12 +323,6 @@ ptep_set_wrprotect(struct mm_struct *mm,
 #define pte_index(address)	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir,addr) 					\
 	((pte_t*) pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
-
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
 
 /*
  * Encode and decode a swap entry.
arch/xtensa/include/asm/ptemap.h new file +10 -0
diff -puN /dev/null arch/xtensa/include/asm/ptemap.h
@@ -0,0 +1,10 @@
+#ifndef _XTENSA_ASM_PTEMAP_H
+#define _XTENSA_ASM_PTEMAP_H
+
+#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
+#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
+
+#define pte_unmap(pte)		do { } while (0)
+#define pte_unmap_nested(pte)	do { } while (0)
+
+#endif /* _XTENSA_ASM_PTEMAP_H */

_

#21 lore raw

RFC PATCH v2 21/35 create linux/ptemap.h for arch-independent pte mapping funcs

In reply to Dave Hansen

linux/mm.h has a couple of completely arch-independent pte mapping functions. Let's move them to their own header to help separate out their dependencies from the rest of mm.h.

I'll get the callsites in the next patch. For now, just include the new header where its functions used to be. I'll remove this in the next patch.

---

 linux-2.6.git-dave/include/linux/mm.h     |   26 ----------------------
 linux-2.6.git-dave/include/linux/ptemap.h |   34 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 26 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~linux-ptemap-h +0 -26
diff -puN include/linux/mm.h~linux-ptemap-h include/linux/mm.h
@@ -969,32 +969,6 @@ static inline void pgtable_page_dtor(str
 	dec_zone_page_state(page, NR_PAGETABLE);
 }
 
-#define pte_offset_map_lock(mm, pmd, address, ptlp)	\
-({							\
-	spinlock_t *__ptl = pte_lockptr(mm, pmd);	\
-	pte_t *__pte = pte_offset_map(pmd, address);	\
-	*(ptlp) = __ptl;				\
-	spin_lock(__ptl);				\
-	__pte;						\
-})
-
-#define pte_unmap_unlock(pte, ptl)	do {		\
-	spin_unlock(ptl);				\
-	pte_unmap(pte);					\
-} while (0)
-
-#define pte_alloc_map(mm, pmd, address)			\
-	((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
-		NULL: pte_offset_map(pmd, address))
-
-#define pte_alloc_map_lock(mm, pmd, address, ptlp)	\
-	((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
-		NULL: pte_offset_map_lock(mm, pmd, address, ptlp))
-
-#define pte_alloc_kernel(pmd, address)			\
-	((unlikely(!pmd_present(*(pmd))) && __pte_alloc_kernel(pmd, address))? \
-		NULL: pte_offset_kernel(pmd, address))
-
 extern void free_area_init(unsigned long * zones_size);
 extern void free_area_init_node(int nid, unsigned long * zones_size,
 		unsigned long zone_start_pfn, unsigned long *zholes_size);
include/linux/ptemap.h renamed from include/linux/ptemap.h~linux-ptemap-h +34 -0
diff -puN include/linux/ptemap.h~linux-ptemap-h include/linux/ptemap.h
@@ -0,0 +1,34 @@
+#ifndef _LINUX_PTE_MAP_H
+#define _LINUX_PTE_MAP_H
+
+#include <linux/mm.h>
+#include <asm/ptemap.h>
+
+#define pte_offset_map_lock(mm, pmd, address, ptlp)	\
+({							\
+	spinlock_t *__ptl = pte_lockptr(mm, pmd);	\
+	pte_t *__pte = pte_offset_map(pmd, address);	\
+	*(ptlp) = __ptl;				\
+	spin_lock(__ptl);				\
+	__pte;						\
+})
+
+#define pte_unmap_unlock(pte, ptl)	do {		\
+	spin_unlock(ptl);				\
+	pte_unmap(pte);					\
+} while (0)
+
+#define pte_alloc_map(mm, pmd, address)			\
+	((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
+		NULL: pte_offset_map(pmd, address))
+
+#define pte_alloc_map_lock(mm, pmd, address, ptlp)	\
+	((unlikely(!pmd_present(*(pmd))) && __pte_alloc(mm, pmd, address))? \
+		NULL: pte_offset_map_lock(mm, pmd, address, ptlp))
+
+#define pte_alloc_kernel(pmd, address)			\
+	((unlikely(!pmd_present(*(pmd))) && __pte_alloc_kernel(pmd, address))? \
+		NULL: pte_offset_kernel(pmd, address))
+
+
+#endif /* _LINUX_PTE_MAP_H */

_

#22 lore raw

RFC PATCH v2 22/35 include linux/ptemap.h at all use sites

In reply to Dave Hansen

This ensures that the users of the pte mapping functions are no longer depending on mm.h or any of the arch-specific header files.

---

 linux-2.6.git-dave/arch/arm/kernel/traps.c        |    1 +
 linux-2.6.git-dave/arch/arm/mm/fault-armv.c       |    1 +
 linux-2.6.git-dave/arch/arm/mm/fault.c            |    1 +
 linux-2.6.git-dave/arch/arm/mm/pgd.c              |    1 +
 linux-2.6.git-dave/arch/ia64/mm/hugetlbpage.c     |    1 +
 linux-2.6.git-dave/arch/m68k/mm/kmap.c            |    1 +
 linux-2.6.git-dave/arch/mips/mm/tlb-r4k.c         |    1 +
 linux-2.6.git-dave/arch/mips/mm/tlb-r8k.c         |    1 +
 linux-2.6.git-dave/arch/mn10300/mm/cache.c        |    1 +
 linux-2.6.git-dave/arch/parisc/kernel/cache.c     |    1 +
 linux-2.6.git-dave/arch/parisc/kernel/pci-dma.c   |    2 ++
 linux-2.6.git-dave/arch/powerpc/mm/pgtable_32.c   |    1 +
 linux-2.6.git-dave/arch/powerpc/mm/pgtable_64.c   |    1 +
 linux-2.6.git-dave/arch/powerpc/mm/subpage-prot.c |    1 +
 linux-2.6.git-dave/arch/s390/lib/uaccess_pt.c     |    1 +
 linux-2.6.git-dave/arch/sh/mm/cache-sh5.c         |    1 +
 linux-2.6.git-dave/arch/sh/mm/hugetlbpage.c       |    1 +
 linux-2.6.git-dave/arch/sparc/kernel/signal32.c   |    1 +
 linux-2.6.git-dave/arch/sparc/mm/fault_64.c       |    1 +
 linux-2.6.git-dave/arch/sparc/mm/generic_64.c     |    1 +
 linux-2.6.git-dave/arch/sparc/mm/hugetlbpage.c    |    1 +
 linux-2.6.git-dave/arch/sparc/mm/io-unit.c        |    1 +
 linux-2.6.git-dave/arch/sparc/mm/iommu.c          |    1 +
 linux-2.6.git-dave/arch/um/kernel/tlb.c           |    1 +
 linux-2.6.git-dave/arch/x86/kernel/vm86_32.c      |    1 +
 linux-2.6.git-dave/arch/x86/mm/gup.c              |    1 +
 linux-2.6.git-dave/fs/proc/task_mmu.c             |    1 +
 linux-2.6.git-dave/lib/ioremap.c                  |    1 +
 linux-2.6.git-dave/mm/fremap.c                    |    1 +
 linux-2.6.git-dave/mm/memory.c                    |    1 +
 linux-2.6.git-dave/mm/mempolicy.c                 |    1 +
 linux-2.6.git-dave/mm/migrate.c                   |    1 +
 linux-2.6.git-dave/mm/mincore.c                   |    1 +
 linux-2.6.git-dave/mm/mprotect.c                  |    1 +
 linux-2.6.git-dave/mm/mremap.c                    |    1 +
 linux-2.6.git-dave/mm/pagewalk.c                  |    1 +
 linux-2.6.git-dave/mm/rmap.c                      |    1 +
 linux-2.6.git-dave/mm/swapfile.c                  |    1 +
 linux-2.6.git-dave/mm/vmalloc.c                   |    1 +
 39 files changed, 40 insertions(+)
arch/arm/kernel/traps.c renamed from arch/arm/kernel/traps.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/arm/kernel/traps.c~include-linux-ptemaph-at-all-call-sites arch/arm/kernel/traps.c
@@ -21,6 +21,7 @@
 #include <linux/hardirq.h>
 #include <linux/init.h>
 #include <linux/uaccess.h>
+#include <linux/ptemap.h>
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
arch/arm/mm/fault-armv.c renamed from arch/arm/mm/fault-armv.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/arm/mm/fault-armv.c~include-linux-ptemaph-at-all-call-sites arch/arm/mm/fault-armv.c
@@ -16,6 +16,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/pagemap.h>
+#include <linux/ptemap.h>
 
 #include <asm/bugs.h>
 #include <asm/cacheflush.h>
arch/arm/mm/fault.c renamed from arch/arm/mm/fault.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/arm/mm/fault.c~include-linux-ptemaph-at-all-call-sites arch/arm/mm/fault.c
@@ -16,6 +16,7 @@
 #include <linux/kprobes.h>
 #include <linux/uaccess.h>
 #include <linux/page-flags.h>
+#include <linux/ptemap.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
arch/arm/mm/pgd.c renamed from arch/arm/mm/pgd.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/arm/mm/pgd.c~include-linux-ptemaph-at-all-call-sites arch/arm/mm/pgd.c
@@ -9,6 +9,7 @@
  */
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/page.h>
arch/ia64/mm/hugetlbpage.c renamed from arch/ia64/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/ia64/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites arch/ia64/mm/hugetlbpage.c
@@ -17,6 +17,7 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/log2.h>
+#include <linux/ptemap.h>
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
arch/m68k/mm/kmap.c renamed from arch/m68k/mm/kmap.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/m68k/mm/kmap.c~include-linux-ptemaph-at-all-call-sites arch/m68k/mm/kmap.c
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <linux/ptemap.h>
 
 #include <asm/setup.h>
 #include <asm/segment.h>
arch/mips/mm/tlb-r4k.c renamed from arch/mips/mm/tlb-r4k.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/mips/mm/tlb-r4k.c~include-linux-ptemaph-at-all-call-sites arch/mips/mm/tlb-r4k.c
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/ptemap.h>
 
 #include <asm/cpu.h>
 #include <asm/bootinfo.h>
arch/mips/mm/tlb-r8k.c renamed from arch/mips/mm/tlb-r8k.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/mips/mm/tlb-r8k.c~include-linux-ptemaph-at-all-call-sites arch/mips/mm/tlb-r8k.c
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/ptemap.h>
 
 #include <asm/cpu.h>
 #include <asm/bootinfo.h>
arch/mn10300/mm/cache.c renamed from arch/mn10300/mm/cache.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/mn10300/mm/cache.c~include-linux-ptemaph-at-all-call-sites arch/mn10300/mm/cache.c
@@ -12,6 +12,7 @@
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/threads.h>
+#include <linux/ptemap.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
arch/parisc/kernel/cache.c renamed from arch/parisc/kernel/cache.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/parisc/kernel/cache.c~include-linux-ptemaph-at-all-call-sites arch/parisc/kernel/cache.c
@@ -19,6 +19,7 @@
 #include <linux/seq_file.h>
 #include <linux/pagemap.h>
 #include <linux/sched.h>
+#include <linux/ptemap.h>
 #include <asm/pdc.h>
 #include <asm/cache.h>
 #include <asm/cacheflush.h>
arch/parisc/kernel/pci-dma.c renamed from arch/parisc/kernel/pci-dma.c~include-linux-ptemaph-at-all-call-sites +2 -0
diff -puN arch/parisc/kernel/pci-dma.c~include-linux-ptemaph-at-all-call-sites arch/parisc/kernel/pci-dma.c
@@ -21,11 +21,13 @@
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
+#include <linux/ptemap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/scatterlist.h>
+#include <linux/ptemap.h>
 
 #include <asm/cacheflush.h>
 #include <asm/dma.h>    /* for DMA_CHUNK_SIZE */
arch/powerpc/mm/pgtable_32.c renamed from arch/powerpc/mm/pgtable_32.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/powerpc/mm/pgtable_32.c~include-linux-ptemaph-at-all-call-sites arch/powerpc/mm/pgtable_32.c
@@ -26,6 +26,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/highmem.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
arch/powerpc/mm/pgtable_64.c renamed from arch/powerpc/mm/pgtable_64.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/powerpc/mm/pgtable_64.c~include-linux-ptemaph-at-all-call-sites arch/powerpc/mm/pgtable_64.c
@@ -33,6 +33,7 @@
 #include <linux/stddef.h>
 #include <linux/vmalloc.h>
 #include <linux/init.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/page.h>
arch/powerpc/mm/subpage-prot.c renamed from arch/powerpc/mm/subpage-prot.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/powerpc/mm/subpage-prot.c~include-linux-ptemaph-at-all-call-sites arch/powerpc/mm/subpage-prot.c
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
arch/s390/lib/uaccess_pt.c renamed from arch/s390/lib/uaccess_pt.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/s390/lib/uaccess_pt.c~include-linux-ptemaph-at-all-call-sites arch/s390/lib/uaccess_pt.c
@@ -11,6 +11,7 @@
 #include <linux/errno.h>
 #include <linux/hardirq.h>
 #include <linux/mm.h>
+#include <linux/ptemap.h>
 #include <asm/uaccess.h>
 #include <asm/futex.h>
 #include "uaccess.h"
arch/sh/mm/cache-sh5.c renamed from arch/sh/mm/cache-sh5.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sh/mm/cache-sh5.c~include-linux-ptemaph-at-all-call-sites arch/sh/mm/cache-sh5.c
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
+#include <linux/ptemap.h>
 #include <asm/tlb.h>
 #include <asm/processor.h>
 #include <asm/cache.h>
arch/sh/mm/hugetlbpage.c renamed from arch/sh/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sh/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites arch/sh/mm/hugetlbpage.c
@@ -15,6 +15,7 @@
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
+#include <linux/ptemap.h>
 
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
arch/sparc/kernel/signal32.c renamed from arch/sparc/kernel/signal32.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/kernel/signal32.c~include-linux-ptemaph-at-all-call-sites arch/sparc/kernel/signal32.c
@@ -20,6 +20,7 @@
 #include <linux/compat.h>
 #include <linux/bitops.h>
 #include <linux/tracehook.h>
+#include <linux/ptemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/ptrace.h>
arch/sparc/mm/fault_64.c renamed from arch/sparc/mm/fault_64.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/mm/fault_64.c~include-linux-ptemaph-at-all-call-sites arch/sparc/mm/fault_64.c
@@ -20,6 +20,7 @@
 #include <linux/kprobes.h>
 #include <linux/kdebug.h>
 #include <linux/percpu.h>
+#include <linux/ptemap.h>
 
 #include <asm/page.h>
 #include <asm/pgtable.h>
arch/sparc/mm/generic_64.c renamed from arch/sparc/mm/generic_64.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/mm/generic_64.c~include-linux-ptemaph-at-all-call-sites arch/sparc/mm/generic_64.c
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
arch/sparc/mm/hugetlbpage.c renamed from arch/sparc/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/mm/hugetlbpage.c~include-linux-ptemaph-at-all-call-sites arch/sparc/mm/hugetlbpage.c
@@ -12,6 +12,7 @@
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 #include <linux/sysctl.h>
+#include <linux/ptemap.h>
 
 #include <asm/mman.h>
 #include <asm/pgalloc.h>
arch/sparc/mm/iommu.c renamed from arch/sparc/mm/iommu.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/mm/iommu.c~include-linux-ptemaph-at-all-call-sites arch/sparc/mm/iommu.c
@@ -15,6 +15,7 @@
 #include <linux/scatterlist.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
arch/sparc/mm/io-unit.c renamed from arch/sparc/mm/io-unit.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/sparc/mm/io-unit.c~include-linux-ptemaph-at-all-call-sites arch/sparc/mm/io-unit.c
@@ -14,6 +14,7 @@
 #include <linux/scatterlist.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
arch/um/kernel/tlb.c renamed from arch/um/kernel/tlb.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/um/kernel/tlb.c~include-linux-ptemaph-at-all-call-sites arch/um/kernel/tlb.c
@@ -5,6 +5,7 @@
 
 #include <linux/mm.h>
 #include <linux/sched.h>
+#include <linux/ptemap.h>
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include "as-layout.h"
arch/x86/kernel/vm86_32.c renamed from arch/x86/kernel/vm86_32.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/x86/kernel/vm86_32.c~include-linux-ptemaph-at-all-call-sites arch/x86/kernel/vm86_32.c
@@ -41,6 +41,7 @@
 #include <linux/ptrace.h>
 #include <linux/audit.h>
 #include <linux/stddef.h>
+#include <linux/ptemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
arch/x86/mm/gup.c renamed from arch/x86/mm/gup.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN arch/x86/mm/gup.c~include-linux-ptemaph-at-all-call-sites arch/x86/mm/gup.c
@@ -10,6 +10,7 @@
 #include <linux/highmem.h>
 
 #include <asm/pgtable.h>
+#include <asm/ptemap.h>
 
 static inline pte_t gup_get_pte(pte_t *ptep)
 {
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN fs/proc/task_mmu.c~include-linux-ptemaph-at-all-call-sites fs/proc/task_mmu.c
@@ -8,6 +8,7 @@
 #include <linux/mempolicy.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/ptemap.h>
 
 #include <asm/elf.h>
 #include <asm/uaccess.h>
lib/ioremap.c renamed from lib/ioremap.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN lib/ioremap.c~include-linux-ptemaph-at-all-call-sites lib/ioremap.c
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/io.h>
+#include <linux/ptemap.h>
 #include <asm/cacheflush.h>
 #include <asm/pgtable.h>
 
mm/fremap.c renamed from mm/fremap.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/fremap.c~include-linux-ptemaph-at-all-call-sites mm/fremap.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/syscalls.h>
 #include <linux/mmu_notifier.h>
+#include <linux/ptemap.h>
 
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
mm/memory.c renamed from mm/memory.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/memory.c~include-linux-ptemaph-at-all-call-sites mm/memory.c
@@ -55,6 +55,7 @@
 #include <linux/kallsyms.h>
 #include <linux/swapops.h>
 #include <linux/elf.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
mm/mempolicy.c renamed from mm/mempolicy.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/mempolicy.c~include-linux-ptemaph-at-all-call-sites mm/mempolicy.c
@@ -89,6 +89,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/ctype.h>
+#include <linux/ptemap.h>
 
 #include <asm/tlbflush.h>
 #include <asm/uaccess.h>
mm/migrate.c renamed from mm/migrate.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/migrate.c~include-linux-ptemaph-at-all-call-sites mm/migrate.c
@@ -31,6 +31,7 @@
 #include <linux/security.h>
 #include <linux/memcontrol.h>
 #include <linux/syscalls.h>
+#include <linux/ptemap.h>
 
 #include "internal.h"
 
mm/mincore.c renamed from mm/mincore.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/mincore.c~include-linux-ptemaph-at-all-call-sites mm/mincore.c
@@ -14,6 +14,7 @@
 #include <linux/syscalls.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/ptemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
mm/mprotect.c renamed from mm/mprotect.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/mprotect.c~include-linux-ptemaph-at-all-call-sites mm/mprotect.c
@@ -23,6 +23,7 @@
 #include <linux/swapops.h>
 #include <linux/mmu_notifier.h>
 #include <linux/migrate.h>
+#include <linux/ptemap.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include <asm/cacheflush.h>
mm/mremap.c renamed from mm/mremap.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/mremap.c~include-linux-ptemaph-at-all-call-sites mm/mremap.c
@@ -19,6 +19,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/mmu_notifier.h>
+#include <linux/ptemap.h>
 
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
mm/pagewalk.c renamed from mm/pagewalk.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/pagewalk.c~include-linux-ptemaph-at-all-call-sites mm/pagewalk.c
@@ -1,6 +1,7 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
+#include <linux/ptemap.h>
 
 static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
 			  struct mm_walk *walk)
mm/rmap.c renamed from mm/rmap.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/rmap.c~include-linux-ptemaph-at-all-call-sites mm/rmap.c
@@ -50,6 +50,7 @@
 #include <linux/memcontrol.h>
 #include <linux/mmu_notifier.h>
 #include <linux/migrate.h>
+#include <linux/ptemap.h>
 
 #include <asm/tlbflush.h>
 
mm/swapfile.c renamed from mm/swapfile.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/swapfile.c~include-linux-ptemaph-at-all-call-sites mm/swapfile.c
@@ -29,6 +29,7 @@
 #include <linux/capability.h>
 #include <linux/syscalls.h>
 #include <linux/memcontrol.h>
+#include <linux/ptemap.h>
 
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
mm/vmalloc.c renamed from mm/vmalloc.c~include-linux-ptemaph-at-all-call-sites +1 -0
diff -puN mm/vmalloc.c~include-linux-ptemaph-at-all-call-sites mm/vmalloc.c
@@ -25,6 +25,7 @@
 #include <linux/rcupdate.h>
 #include <linux/bootmem.h>
 #include <linux/pfn.h>
+#include <linux/ptemap.h>
 
 #include <asm/atomic.h>
 #include <asm/uaccess.h>

_

arch/ia64/mm/init.c +1 -0
index c0f3bee..563d751 100644
@@ -20,6 +20,7 @@
 #include <linux/proc_fs.h>
 #include <linux/bitops.h>
 #include <linux/kexec.h>
+#include <linux/ptemap.h>
 
 #include <asm/dma.h>
 #include <asm/ia32.h>
#23 lore raw

RFC PATCH v2 23/35 factor x86 pte mapping code

In reply to Dave Hansen

x86 contains three separate pte_offset_map() implementations:
1. 32-bit highpte
2. 32-bit direct mapped
3. 64-bit direct mapped

This patch consolidates the 32-bit direct map and 64-bit implementations. You can look back at the 00 patch in this series to see a bit of proof about why

#define pte_offset_map(dir, address)                                   \
	((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))

and

#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))

are actually interchangable.

---

 linux-2.6.git-dave/arch/x86/include/asm/ptemap.h |   17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
arch/x86/include/asm/ptemap.h renamed from arch/x86/include/asm/ptemap.h~factor-x86 +3 -14
diff -puN arch/x86/include/asm/ptemap.h~factor-x86 arch/x86/include/asm/ptemap.h
@@ -1,10 +1,7 @@
 #ifndef _X86_ASM_PTEMAP_H
 #define _X86_ASM_PTEMAP_H
 
-#ifdef CONFIG_X86_32
-
 #if defined(CONFIG_HIGHPTE)
-
 #define pte_offset_map(dir, address)					\
 	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
 	 pte_index((address)))
@@ -13,21 +10,13 @@
 	 pte_index((address)))
 #define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
 #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
-#else
-#define pte_offset_map(dir, address)					\
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
-#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-#endif
 
-#else /* x86-64 */
+#else /* !CONFIG_HIGHPTE */
 
-/* x86-64 always has all page tables mapped. */
 #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
 #define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte) /* NOP */
-#define pte_unmap_nested(pte) /* NOP */
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
 
 #endif
 

_

#24 lore raw

RFC PATCH v2 24/35 arm: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/arm/include/asm/ptemap.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/ptemap.h renamed from arch/arm/include/asm/ptemap.h~arm-pte_offset_kernel +2 -2
diff -puN arch/arm/include/asm/ptemap.h~arm-pte_offset_kernel arch/arm/include/asm/ptemap.h
@@ -1,8 +1,8 @@
 #ifndef _ARM_ASM_PTEMAP_H
 #define _ARM_ASM_PTEMAP_H
 
-#define pte_offset_map(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
-#define pte_offset_map_nested(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
+#define pte_offset_map(dir,addr)	pte_offset_kernel(dir,addr)
+#define pte_offset_map_nested(dir,addr)	pte_offset_kernel(dir,addr)
 #define pte_unmap(pte)		do { } while (0)
 #define pte_unmap_nested(pte)	do { } while (0)
 

_

#25 lore raw

RFC PATCH v2 25/35 cris: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/cris/include/asm/ptemap.h |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/cris/include/asm/ptemap.h renamed from arch/cris/include/asm/ptemap.h~cris-pte_offset_kernel +2 -4
diff -puN arch/cris/include/asm/ptemap.h~cris-pte_offset_kernel arch/cris/include/asm/ptemap.h
@@ -1,10 +1,8 @@
 #ifndef _CRIS_ASM_PTEMAP_H
 #define _CRIS_ASM_PTEMAP_H
 
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
-
+#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
 #define pte_unmap(pte) do { } while (0)
 #define pte_unmap_nested(pte) do { } while (0)
 

_

#26 lore raw

RFC PATCH v2 26/35 frv: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/frv/include/asm/highmem.h |    5 +++++
 linux-2.6.git-dave/arch/frv/include/asm/ptemap.h  |    5 ++---
 2 files changed, 7 insertions(+), 3 deletions(-)
arch/frv/include/asm/highmem.h renamed from arch/frv/include/asm/highmem.h~frv-pte_offset_kernel +5 -0
diff -puN arch/frv/include/asm/highmem.h~frv-pte_offset_kernel arch/frv/include/asm/highmem.h
@@ -42,6 +42,11 @@ extern unsigned long highstart_pfn, high
 
 #define kmap_prot PAGE_KERNEL
 #define kmap_pte ______kmap_pte_in_TLB
+/*
+ * This lets us share the highpte pte_offset_map()
+ * with x86
+ */
+#define kmap_atomic_pte(page, type)     kmap_atomic(page, type)
 extern pte_t *pkmap_page_table;
 
 #define flush_cache_kmaps()  do { } while (0)
arch/frv/include/asm/ptemap.h renamed from arch/frv/include/asm/ptemap.h~frv-pte_offset_kernel +2 -3
diff -puN arch/frv/include/asm/ptemap.h~frv-pte_offset_kernel arch/frv/include/asm/ptemap.h
@@ -9,9 +9,8 @@
 #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
 #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
 #else
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
+#define pte_offset_map(dir, address)	pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
 #define pte_unmap(pte) do { } while (0)
 #define pte_unmap_nested(pte) do { } while (0)
 #endif

_

#27 lore raw

RFC PATCH v2 27/35 m32r: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/m32r/include/asm/ptemap.h |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/m32r/include/asm/ptemap.h renamed from arch/m32r/include/asm/ptemap.h~m32r-pte_offset_kernel +2 -3
diff -puN arch/m32r/include/asm/ptemap.h~m32r-pte_offset_kernel arch/m32r/include/asm/ptemap.h
@@ -1,9 +1,8 @@
 #ifndef _M32R_ASM_PTEMAP_H
 #define _M32R_ASM_PTEMAP_H
 
-#define pte_offset_map(dir, address)	\
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address)	pte_offset_map(dir, address)
+#define pte_offset_map(dir, address)	pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
 #define pte_unmap(pte)		do { } while (0)
 #define pte_unmap_nested(pte)	do { } while (0)
 

_

#28 lore raw

RFC PATCH v2 28/35 mips: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

On MIPS, it is also obvious at this point that the 32 and 64-bit implementations are identical. Coalesce them.

---

 linux-2.6.git-dave/arch/mips/include/asm/pgtable-32.h |    3 +--
 linux-2.6.git-dave/arch/mips/include/asm/pgtable-64.h |    3 +--
 linux-2.6.git-dave/arch/mips/include/asm/ptemap.h     |   17 ++---------------
 3 files changed, 4 insertions(+), 19 deletions(-)
arch/mips/include/asm/pgtable-32.h renamed from arch/mips/include/asm/pgtable-32.h~mips-pte_offset_kernel +1 -2
diff -puN arch/mips/include/asm/pgtable-32.h~mips-pte_offset_kernel arch/mips/include/asm/pgtable-32.h
@@ -149,8 +149,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_kernel(dir, address)					\
-	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_kernel(dir, address) pte_offset(dir, address)
 #include <asm/ptemap.h>
 
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
arch/mips/include/asm/pgtable-64.h renamed from arch/mips/include/asm/pgtable-64.h~mips-pte_offset_kernel +1 -2
diff -puN arch/mips/include/asm/pgtable-64.h~mips-pte_offset_kernel arch/mips/include/asm/pgtable-64.h
@@ -213,8 +213,7 @@ static inline pmd_t *pmd_offset(pud_t * 
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
-#define pte_offset_kernel(dir, address)					\
-	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_kernel(dir, address)	pte_offset(dir, address)
 #include <asm/ptemap.h>
 /*
  * Initialize a new pgd / pmd table with invalid pointers.
arch/mips/include/asm/ptemap.h renamed from arch/mips/include/asm/ptemap.h~mips-pte_offset_kernel +2 -15
diff -puN arch/mips/include/asm/ptemap.h~mips-pte_offset_kernel arch/mips/include/asm/ptemap.h
@@ -1,22 +1,9 @@
 #ifndef _MIPS_ASM_PTEMAP_H
 #define _MIPS_ASM_PTEMAP_H
 
-#ifdef CONFIG_32BIT
-#define pte_offset_map(dir, address)                                    \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address)                             \
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
 #define pte_unmap(pte) ((void)(pte))
 #define pte_unmap_nested(pte) ((void)(pte))
-#endif
-
-#ifdef CONFIG_64BIT
-#define pte_offset_map(dir, address)					\
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_offset_map_nested(dir, address)				\
-	((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
-#define pte_unmap(pte) ((void)(pte))
-#define pte_unmap_nested(pte) ((void)(pte))
-#endif
 
 #endif /* _MIPS_ASM_PTEMAP_H */

_

#29 lore raw

RFC PATCH v2 29/35 um: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/um/include/asm/ptemap.h |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/um/include/asm/ptemap.h renamed from arch/um/include/asm/ptemap.h~um-pte_offset_kernel +2 -3
diff -puN arch/um/include/asm/ptemap.h~um-pte_offset_kernel arch/um/include/asm/ptemap.h
@@ -1,9 +1,8 @@
 #ifndef _UM_ASM_PTEMAP_H
 #define _UM_ASM_PTEMAP_H
 
-#define pte_offset_map(dir, address) \
-	((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
 #define pte_unmap(pte) do { } while (0)
 #define pte_unmap_nested(pte) do { } while (0)
 

_

#30 lore raw

RFC PATCH v2 30/35 m68k: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/m68k/include/asm/ptemap.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/include/asm/ptemap.h renamed from arch/m68k/include/asm/ptemap.h~m68k-pte_offset_kernel +2 -2
diff -puN arch/m68k/include/asm/ptemap.h~m68k-pte_offset_kernel arch/m68k/include/asm/ptemap.h
@@ -12,8 +12,8 @@
 
 #else /* !CONFIG_SUN3, Motorola */
 
-#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
-#define pte_offset_map_nested(pmdp, address) pte_offset_map(pmdp, address)
+#define pte_offset_map(pmdp,address) pte_offset_kernel(pmdp, address)
+#define pte_offset_map_nested(pmdp, address) pte_offset_kernel(pmdp, address)
 #define pte_unmap(pte)		((void)0)
 #define pte_unmap_nested(pte)	((void)0)
 

_

#31 lore raw

RFC PATCH v2 31/35 mn10300: use pte_offset_kernel() as base for pte_offset_map*()

In reply to Dave Hansen

Some architectures use pte_offset_map() as a basis for pte_offset_kernel(). Others do the inverse.

Although arbitrary, Using pte_offset_kernel() as the base seems a wee bit more popular and it also fits in well with the way I'm breaking out the headers.

Instead of coding the same implementation twice, this makes pte_offset_map{,_nested}() call pte_offset_kernel() directly.

---

 linux-2.6.git-dave/arch/mn10300/include/asm/ptemap.h |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/mn10300/include/asm/ptemap.h renamed from arch/mn10300/include/asm/ptemap.h~mn10300-pte_offset_kernel +2 -3
diff -puN arch/mn10300/include/asm/ptemap.h~mn10300-pte_offset_kernel arch/mn10300/include/asm/ptemap.h
@@ -1,9 +1,8 @@
 #ifndef _MN10300_ASM_PTEMAP_H
 #define _MN10300_ASM_PTEMAP_H
 
-#define pte_offset_map(dir, address) \
-	((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address))
-#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
+#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
 #define pte_unmap(pte)		do {} while (0)
 #define pte_unmap_nested(pte)	do {} while (0)
 

_

#32 lore raw

RFC PATCH v2 32/35 Move users to asm-generic/ptemap.h

In reply to Dave Hansen

Now that we have everyone using pte_offset_kernel(), we can plainy see that almost all the implementations are exactly the same.

This takes all of those and moves them over to use esm-generic/ptemap.h instead.

---

 linux-2.6.git-dave/arch/alpha/include/asm/ptemap.h   |   10 -------
 linux-2.6.git-dave/arch/arm/include/asm/ptemap.h     |   10 -------
 linux-2.6.git-dave/arch/avr32/include/asm/ptemap.h   |   10 -------
 linux-2.6.git-dave/arch/cris/include/asm/ptemap.h    |   10 -------
 linux-2.6.git-dave/arch/frv/include/asm/ptemap.h     |    5 ---
 linux-2.6.git-dave/arch/ia64/include/asm/ptemap.h    |   10 -------
 linux-2.6.git-dave/arch/m32r/include/asm/ptemap.h    |   10 -------
 linux-2.6.git-dave/arch/m68k/include/asm/ptemap.h    |    5 ---
 linux-2.6.git-dave/arch/mips/include/asm/ptemap.h    |   10 -------
 linux-2.6.git-dave/arch/mn10300/include/asm/ptemap.h |   10 -------
 linux-2.6.git-dave/arch/parisc/include/asm/ptemap.h  |   10 -------
 linux-2.6.git-dave/arch/powerpc/include/asm/ptemap.h |    5 ---
 linux-2.6.git-dave/arch/s390/include/asm/ptemap.h    |   10 -------
 linux-2.6.git-dave/arch/sh/include/asm/ptemap.h      |   10 -------
 linux-2.6.git-dave/arch/sparc/include/asm/ptemap.h   |   25 -------------------
 linux-2.6.git-dave/arch/um/include/asm/ptemap.h      |   10 -------
 linux-2.6.git-dave/arch/x86/include/asm/ptemap.h     |    5 ---
 linux-2.6.git-dave/arch/xtensa/include/asm/ptemap.h  |   11 --------
 linux-2.6.git-dave/include/asm-generic/ptemap.h      |   15 +++++++++++
 19 files changed, 33 insertions(+), 158 deletions(-)
arch/alpha/include/asm/ptemap.h renamed from arch/alpha/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/alpha/include/asm/ptemap.h~asm-generic-ptemap-h arch/alpha/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _ALPHA_ASM_PTEMAP_H
-#define _ALPHA_ASM_PTEMAP_H
-
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
-
-#endif /* _ALPHA_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/arm/include/asm/ptemap.h renamed from arch/arm/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/arm/include/asm/ptemap.h~asm-generic-ptemap-h arch/arm/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _ARM_ASM_PTEMAP_H
-#define _ARM_ASM_PTEMAP_H
-
-#define pte_offset_map(dir,addr)	pte_offset_kernel(dir,addr)
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel(dir,addr)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
-#endif /* _ARM_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/avr32/include/asm/ptemap.h renamed from arch/avr32/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/avr32/include/asm/ptemap.h~asm-generic-ptemap-h arch/avr32/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _AVR32_ASM_PTEMAP_H
-#define _AVR32_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
-#endif /* _AVR32_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/cris/include/asm/ptemap.h renamed from arch/cris/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/cris/include/asm/ptemap.h~asm-generic-ptemap-h arch/cris/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _CRIS_ASM_PTEMAP_H
-#define _CRIS_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-
-#endif /* _CRIS_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/frv/include/asm/ptemap.h renamed from arch/frv/include/asm/ptemap.h~asm-generic-ptemap-h +1 -4
diff -puN arch/frv/include/asm/ptemap.h~asm-generic-ptemap-h arch/frv/include/asm/ptemap.h
@@ -9,10 +9,7 @@
 #define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
 #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
 #else
-#define pte_offset_map(dir, address)	pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
+#include <asm-generic/ptemap.h>
 #endif
 
 #endif /* _FRV_ASM_PTEMAP_H */
arch/ia64/include/asm/ptemap.h renamed from arch/ia64/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/ia64/include/asm/ptemap.h~asm-generic-ptemap-h arch/ia64/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _IA64_ASM_PTEMAP_H
-#define _IA64_ASM_PTEMAP_H
-
-#define pte_offset_map(dir,addr)	pte_offset_kernel(dir, addr)
-#define pte_offset_map_nested(dir,addr)	pte_offset_map(dir, addr)
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
-
-#endif /* _IA64_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/m32r/include/asm/ptemap.h renamed from arch/m32r/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/m32r/include/asm/ptemap.h~asm-generic-ptemap-h arch/m32r/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _M32R_ASM_PTEMAP_H
-#define _M32R_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address)	pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
-#endif /* _M32R_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/m68k/include/asm/ptemap.h renamed from arch/m68k/include/asm/ptemap.h~asm-generic-ptemap-h +1 -4
diff -puN arch/m68k/include/asm/ptemap.h~asm-generic-ptemap-h arch/m68k/include/asm/ptemap.h
@@ -12,10 +12,7 @@
 
 #else /* !CONFIG_SUN3, Motorola */
 
-#define pte_offset_map(pmdp,address) pte_offset_kernel(pmdp, address)
-#define pte_offset_map_nested(pmdp, address) pte_offset_kernel(pmdp, address)
-#define pte_unmap(pte)		((void)0)
-#define pte_unmap_nested(pte)	((void)0)
+#include <asm-generic/ptemap.h>
 
 #endif /* CONFIG_SUN3 */
 
arch/mips/include/asm/ptemap.h renamed from arch/mips/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/mips/include/asm/ptemap.h~asm-generic-ptemap-h arch/mips/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _MIPS_ASM_PTEMAP_H
-#define _MIPS_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
-#define pte_unmap(pte) ((void)(pte))
-#define pte_unmap_nested(pte) ((void)(pte))
-
-#endif /* _MIPS_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/mn10300/include/asm/ptemap.h renamed from arch/mn10300/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/mn10300/include/asm/ptemap.h~asm-generic-ptemap-h arch/mn10300/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _MN10300_ASM_PTEMAP_H
-#define _MN10300_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
-#define pte_unmap(pte)		do {} while (0)
-#define pte_unmap_nested(pte)	do {} while (0)
-
-#endif /* _MN10300_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/parisc/include/asm/ptemap.h renamed from arch/parisc/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/parisc/include/asm/ptemap.h~asm-generic-ptemap-h arch/parisc/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _PARISC_ASM_PTEMAP_H
-#define _PARISC_ASM_PTEMAP_H
-
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-
-#endif /* _PARISC_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/powerpc/include/asm/ptemap.h renamed from arch/powerpc/include/asm/ptemap.h~asm-generic-ptemap-h +1 -4
diff -puN arch/powerpc/include/asm/ptemap.h~asm-generic-ptemap-h arch/powerpc/include/asm/ptemap.h
@@ -13,10 +13,7 @@
 
 #else /* __powerpc64__ */
 
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir), (addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir), (addr))
-#define pte_unmap(pte)			do { } while(0)
-#define pte_unmap_nested(pte)		do { } while(0)
+#include <asm-generic/ptemap.h>
 
 #endif
 
arch/s390/include/asm/ptemap.h renamed from arch/s390/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/s390/include/asm/ptemap.h~asm-generic-ptemap-h arch/s390/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _S390_ASM_PTEMAP_H
-#define _S390_ASM_PTEMAP_H
-
-#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-
-#endif /* _S390_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/sh/include/asm/ptemap.h renamed from arch/sh/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/sh/include/asm/ptemap.h~asm-generic-ptemap-h arch/sh/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _SH_ASM_PTEMAP_H
-#define _SH_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address)		pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address)	pte_offset_kernel(dir, address)
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
-#endif /* _SH_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/sparc/include/asm/ptemap.h renamed from arch/sparc/include/asm/ptemap.h~asm-generic-ptemap-h +1 -24
diff -puN arch/sparc/include/asm/ptemap.h~asm-generic-ptemap-h arch/sparc/include/asm/ptemap.h
@@ -1,24 +1 @@
-#ifndef _SPARC_ASM_PTEMAP_H
-#define _SPARC_ASM_PTEMAP_H
-
-#if defined(__sparc__) && defined(__arch64__)
-
-#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
-#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte)			do { } while (0)
-#define pte_unmap_nested(pte)		do { } while (0)
-
-#else
-/*
- * This shortcut works on sun4m (and sun4d) because the nocache area is static,
- * and sun4c is guaranteed to have no highmem anyway.
- */
-#define pte_offset_map(d, a)		pte_offset_kernel(d,a)
-#define pte_offset_map_nested(d, a)	pte_offset_kernel(d,a)
-
-#define pte_unmap(pte)		do{}while(0)
-#define pte_unmap_nested(pte)	do{}while(0)
-
-#endif
-
-#endif /* _SPARC_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/um/include/asm/ptemap.h renamed from arch/um/include/asm/ptemap.h~asm-generic-ptemap-h +1 -9
diff -puN arch/um/include/asm/ptemap.h~asm-generic-ptemap-h arch/um/include/asm/ptemap.h
@@ -1,9 +1 @@
-#ifndef _UM_ASM_PTEMAP_H
-#define _UM_ASM_PTEMAP_H
-
-#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
-#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
-
-#endif /* _UM_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
arch/x86/include/asm/ptemap.h renamed from arch/x86/include/asm/ptemap.h~asm-generic-ptemap-h +1 -4
diff -puN arch/x86/include/asm/ptemap.h~asm-generic-ptemap-h arch/x86/include/asm/ptemap.h
@@ -13,10 +13,7 @@
 
 #else /* !CONFIG_HIGHPTE */
 
-#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
-#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
-#define pte_unmap(pte) do { } while (0)
-#define pte_unmap_nested(pte) do { } while (0)
+#include <asm-generic/ptemap.h>
 
 #endif
 
arch/xtensa/include/asm/ptemap.h renamed from arch/xtensa/include/asm/ptemap.h~asm-generic-ptemap-h +1 -10
diff -puN arch/xtensa/include/asm/ptemap.h~asm-generic-ptemap-h arch/xtensa/include/asm/ptemap.h
@@ -1,10 +1 @@
-#ifndef _XTENSA_ASM_PTEMAP_H
-#define _XTENSA_ASM_PTEMAP_H
-
-#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
-#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
-
-#define pte_unmap(pte)		do { } while (0)
-#define pte_unmap_nested(pte)	do { } while (0)
-
-#endif /* _XTENSA_ASM_PTEMAP_H */
+#include <asm-generic/ptemap.h>
include/asm-generic/ptemap.h new file +15 -0
diff -puN /dev/null include/asm-generic/ptemap.h
@@ -0,0 +1,15 @@
+#ifndef _ASM_GENERIC_PTEMAP_H
+#define _ASM_GENERIC_PTEMAP_H
+
+/*
+ * If your architecture has direct-mapped pte pages (no HIGHPTE)
+ * then you just need to implement pte_offset_kernel() and include
+ * this in your asm/ptemap.h.
+ */
+
+#define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
+#define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
+#define pte_unmap(pte)			do { } while (0)
+#define pte_unmap_nested(pte)		do { } while (0)
+
+#endif /* _ASM_GENERIC_PTEMAP_H */

_

#33 lore raw

RFC PATCH v2 33/35 asm-generic/ptemap.h for HIGHPTE implementations

In reply to Dave Hansen

x86 and frv have identical CONFIG_HIGHPTE implementations of the pte mapping functions. Consolidate and move these to asm-generic/ptemap.h.

---

 linux-2.6.git-dave/arch/frv/include/asm/ptemap.h  |   14 --------------
 linux-2.6.git-dave/arch/x86/include/asm/ptemap.h  |   19 -------------------
 linux-2.6.git-dave/include/asm-generic/ptemap.h   |   20 ++++++++++++++++++++
 linux-2.6.git-dave/orphan.dir/ptemap-overview.txt |   12 ++++++++++++
 4 files changed, 32 insertions(+), 33 deletions(-)
arch/frv/include/asm/ptemap.h renamed from arch/frv/include/asm/ptemap.h~asm-generic-ptemap-h-highpte +0 -14
diff -puN arch/frv/include/asm/ptemap.h~asm-generic-ptemap-h-highpte arch/frv/include/asm/ptemap.h
@@ -1,15 +1 @@
-#ifndef _FRV_ASM_PTEMAP_H
-#define _FRV_ASM_PTEMAP_H
-
-#if defined(CONFIG_HIGHPTE)
-#define pte_offset_map(dir, address) \
-	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
-#define pte_offset_map_nested(dir, address) \
-	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
-#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
-#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
-#else
 #include <asm-generic/ptemap.h>
-#endif
-
-#endif /* _FRV_ASM_PTEMAP_H */
arch/x86/include/asm/ptemap.h renamed from arch/x86/include/asm/ptemap.h~asm-generic-ptemap-h-highpte +0 -19
diff -puN arch/x86/include/asm/ptemap.h~asm-generic-ptemap-h-highpte arch/x86/include/asm/ptemap.h
@@ -1,20 +1 @@
-#ifndef _X86_ASM_PTEMAP_H
-#define _X86_ASM_PTEMAP_H
-
-#if defined(CONFIG_HIGHPTE)
-#define pte_offset_map(dir, address)					\
-	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE0) +		\
-	 pte_index((address)))
-#define pte_offset_map_nested(dir, address)				\
-	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)), KM_PTE1) +		\
-	 pte_index((address)))
-#define pte_unmap(pte) kunmap_atomic((pte), KM_PTE0)
-#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
-
-#else /* !CONFIG_HIGHPTE */
-
 #include <asm-generic/ptemap.h>
-
-#endif
-
-#endif /* _X86_ASM_PTEMAP_H */
include/asm-generic/ptemap.h renamed from include/asm-generic/ptemap.h~asm-generic-ptemap-h-highpte +20 -0
diff -puN include/asm-generic/ptemap.h~asm-generic-ptemap-h-highpte include/asm-generic/ptemap.h
@@ -5,11 +5,31 @@
  * If your architecture has direct-mapped pte pages (no HIGHPTE)
  * then you just need to implement pte_offset_kernel() and include
  * this in your asm/ptemap.h.
+ *
+ * To support HIGHPTE, you need to have implementations of
+ * kmap_atomic_pte() (which usually just calls kmap_atomic()),
+ * pmd_page() and pmd_index().
  */
 
+#include <linux/mm.h>
+
+#ifdef CONFIG_HIGHPTE
+
+#include <asm/highmem.h>
+#define pte_offset_map(dir, address) \
+	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
+#define pte_offset_map_nested(dir, address) \
+	((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
+#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
+#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
+
+#else /* !CONFIG_HIGHPTE */
+
 #define pte_offset_map(dir,addr)	pte_offset_kernel((dir),(addr))
 #define pte_offset_map_nested(dir,addr)	pte_offset_kernel((dir),(addr))
 #define pte_unmap(pte)			do { } while (0)
 #define pte_unmap_nested(pte)		do { } while (0)
 
+#endif /* CONFIG_HIGHPTE */
+
 #endif /* _ASM_GENERIC_PTEMAP_H */

diff -puN orphan.dir/ptemap-overview.txt~asm-generic-ptemap-h-highpte orphan.dir/ptemap-overview.txt

#34 lore raw

RFC PATCH v2 34/35 powerpc use generic ptemap.h

In reply to Dave Hansen

powerpc is a bid of an oddball here. It seems to have CONFIG_HIGHPTE behavior at all times when compiled as 32-bit. There's even an #ifdef CONFIG_HIGHPTE in arch/powerpc/mm/pgtable_32.c, but there's no trace of HIGHPTE in Kconfig anywhere.

This gives ppc32 an explicit HIGHPTE in Kconfig so that we can use the #ifdef in asm-generic/ptemap.h and let ppc use the generic code with x86 and frv.

It also removes the HIGHPTE #ifdef on ppc32 since it will be on unconditionally.

---

 linux-2.6.git-dave/arch/powerpc/Kconfig              |   14 ++++++++++++++
 linux-2.6.git-dave/arch/powerpc/include/asm/ptemap.h |   14 ++------------
 linux-2.6.git-dave/arch/powerpc/mm/pgtable_32.c      |    4 ----
 linux-2.6.git-dave/orphan.dir/ptemap-overview.txt    |    5 +++++
 4 files changed, 21 insertions(+), 16 deletions(-)
arch/powerpc/include/asm/ptemap.h renamed from arch/powerpc/include/asm/ptemap.h~powerpc-pte_offset_kernel +2 -12
diff -puN arch/powerpc/include/asm/ptemap.h~powerpc-pte_offset_kernel arch/powerpc/include/asm/ptemap.h
@@ -2,19 +2,9 @@
 #define _POWERPC_ASM_PTEMAP_H
 
 #ifndef __powerpc64__
-
-#define pte_offset_map(dir, addr)		\
-	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr))
-#define pte_offset_map_nested(dir, addr)	\
-	((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
-
-#define pte_unmap(pte)		kunmap_atomic(pte, KM_PTE0)
-#define pte_unmap_nested(pte)	kunmap_atomic(pte, KM_PTE1)
-
-#else /* __powerpc64__ */
+#define kmap_atomic_pte(page, type) kmap_atomic(page, type)
+#endif
 
 #include <asm-generic/ptemap.h>
 
-#endif
-
 #endif /* _POWERPC_ASM_PTEMAP_H */
arch/powerpc/Kconfig renamed from arch/powerpc/Kconfig~powerpc-pte_offset_kernel +14 -0
diff -puN arch/powerpc/Kconfig~powerpc-pte_offset_kernel arch/powerpc/Kconfig
@@ -248,6 +248,20 @@ config HIGHMEM
 	bool "High memory support"
 	depends on PPC32
 
+config HIGHPTE
+	bool "Put PTE pages in high memory"
+	default n
+	depends on HIGHMEM && 6xx && EXPERIMENTAL
+	---help---
+	  The VM uses one page table entry for each page of physical memory.
+	  For 32-bit systems with a lot of RAM, this can be wasteful of
+	  precious low memory.  Setting this option will put user-space page
+	  table entries in high memory.
+
+	  This option is highly experimental.  Do not enable unless you are
+	  testing the VM.
+
+
 source kernel/time/Kconfig
 source kernel/Kconfig.hz
 source kernel/Kconfig.preempt
arch/powerpc/mm/pgtable_32.c renamed from arch/powerpc/mm/pgtable_32.c~powerpc-pte_offset_kernel +0 -4
diff -puN arch/powerpc/mm/pgtable_32.c~powerpc-pte_offset_kernel arch/powerpc/mm/pgtable_32.c
@@ -114,11 +114,7 @@ pgtable_t pte_alloc_one(struct mm_struct
 {
 	struct page *ptepage;
 
-#ifdef CONFIG_HIGHPTE
 	gfp_t flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT | __GFP_ZERO;
-#else
-	gfp_t flags = GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO;
-#endif
 
 	ptepage = alloc_pages(flags, 0);
 	if (!ptepage)
#35 lore raw

RFC PATCH v2 35/35 remove old ptemap.h includes

In reply to Dave Hansen

Now that we're directly including ptemap.h everywhere we need it we no longer need the includes from all the various arch headers. Kill them.

---

 linux-2.6.git-dave/arch/arm/include/asm/pgtable.h           |    2 --
 linux-2.6.git-dave/arch/cris/include/asm/pgtable.h          |    1 -
 linux-2.6.git-dave/arch/frv/include/asm/pgtable.h           |    2 --
 linux-2.6.git-dave/arch/ia64/include/asm/pgtable.h          |    2 --
 linux-2.6.git-dave/arch/m32r/include/asm/pgtable.h          |    1 -
 linux-2.6.git-dave/arch/m68k/include/asm/motorola_pgtable.h |    2 --
 linux-2.6.git-dave/arch/m68k/include/asm/sun3_pgtable.h     |    3 ---
 linux-2.6.git-dave/arch/mips/include/asm/pgtable-32.h       |    1 -
 linux-2.6.git-dave/arch/mips/include/asm/pgtable-64.h       |    1 -
 linux-2.6.git-dave/arch/mn10300/include/asm/pgtable.h       |    2 --
 linux-2.6.git-dave/arch/parisc/include/asm/pgtable.h        |    2 --
 linux-2.6.git-dave/arch/powerpc/include/asm/pgtable-ppc64.h |    2 --
 linux-2.6.git-dave/arch/s390/include/asm/pgtable.h          |    2 --
 linux-2.6.git-dave/arch/sh/include/asm/pgtable_32.h         |    1 -
 linux-2.6.git-dave/arch/sh/include/asm/pgtable_64.h         |    2 --
 linux-2.6.git-dave/arch/sparc/include/asm/pgtable_32.h      |    2 --
 linux-2.6.git-dave/arch/sparc/include/asm/pgtable_64.h      |    2 --
 linux-2.6.git-dave/arch/um/include/asm/pgtable.h            |    1 -
 linux-2.6.git-dave/arch/x86/include/asm/pgtable_32.h        |    2 --
 linux-2.6.git-dave/arch/x86/include/asm/pgtable_64.h        |    2 --
 20 files changed, 35 deletions(-)
arch/arm/include/asm/pgtable.h renamed from arch/arm/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/arm/include/asm/pgtable.h~remove-old-ptemap-includes arch/arm/include/asm/pgtable.h
@@ -265,8 +265,6 @@ extern struct page *empty_zero_page;
 #define pte_page(pte)		(pfn_to_page(pte_pfn(pte)))
 #define pte_offset_kernel(dir,addr)	(pmd_page_vaddr(*(dir)) + pte_index(addr))
 
-#include <asm/ptemap.h>
-
 #define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
 
 #define set_pte_at(mm,addr,ptep,pteval) do { \
arch/cris/include/asm/pgtable.h renamed from arch/cris/include/asm/pgtable.h~remove-old-ptemap-includes +0 -1
diff -puN arch/cris/include/asm/pgtable.h~remove-old-ptemap-includes arch/cris/include/asm/pgtable.h
@@ -244,7 +244,6 @@ static inline pgd_t * pgd_offset(const s
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  __pte_offset(address))
-#include <asm/ptemap.h>
 #define pte_pfn(x)		((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)
 #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
 
arch/frv/include/asm/pgtable.h renamed from arch/frv/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/frv/include/asm/pgtable.h~remove-old-ptemap-includes arch/frv/include/asm/pgtable.h
@@ -449,8 +449,6 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  pte_index(address))
 
-#include <asm/ptemap.h>
-
 /*
  * Handle swap and file entries
  * - the PTE is encoded in the following format:
arch/ia64/include/asm/pgtable.h renamed from arch/ia64/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/ia64/include/asm/pgtable.h~remove-old-ptemap-includes arch/ia64/include/asm/pgtable.h
@@ -406,8 +406,6 @@ pgd_offset (const struct mm_struct *mm, 
 #define pte_index(addr)	 	(((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir,addr)	((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
 
-#include <asm/ptemap.h>
-
 /* atomic versions of the some PTE manipulations: */
 
 static inline int
arch/m32r/include/asm/pgtable.h renamed from arch/m32r/include/asm/pgtable.h~remove-old-ptemap-includes +0 -1
diff -puN arch/m32r/include/asm/pgtable.h~remove-old-ptemap-includes arch/m32r/include/asm/pgtable.h
@@ -330,7 +330,6 @@ static inline void pmd_set(pmd_t * pmdp,
 	(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address)	\
 	((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
-#include <asm/ptemap.h>
 
 /* Encode and de-code a swap entry */
 #define __swp_type(x)			(((x).val >> 2) & 0x1f)
arch/m68k/include/asm/motorola_pgtable.h renamed from arch/m68k/include/asm/motorola_pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/m68k/include/asm/motorola_pgtable.h~remove-old-ptemap-includes arch/m68k/include/asm/motorola_pgtable.h
@@ -220,8 +220,6 @@ static inline pte_t *pte_offset_kernel(p
 	return (pte_t *)__pmd_page(*pmdp) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
 }
 
-#include <asm/ptemap.h>
-
 /*
  * Allocate and free page tables. The xxx_kernel() versions are
  * used to allocate a kernel page table - this turns on ASN bits
arch/m68k/include/asm/sun3_pgtable.h renamed from arch/m68k/include/asm/sun3_pgtable.h~remove-old-ptemap-includes +0 -3
diff -puN arch/m68k/include/asm/sun3_pgtable.h~remove-old-ptemap-includes arch/m68k/include/asm/sun3_pgtable.h
@@ -217,9 +217,6 @@ static inline pte_t pgoff_to_pte(unsigne
 /* Find an entry in the third-level pagetable. */
 #define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE-1))
 #define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address))
-/* FIXME: should we bother with kmap() here? */
-
-#include <asm/ptemap.h>
 
 /* Macros to (de)construct the fake PTEs representing swap pages. */
 #define __swp_type(x)		((x).val & 0x7F)
arch/mips/include/asm/pgtable-32.h renamed from arch/mips/include/asm/pgtable-32.h~remove-old-ptemap-includes +0 -1
diff -puN arch/mips/include/asm/pgtable-32.h~remove-old-ptemap-includes arch/mips/include/asm/pgtable-32.h
@@ -150,7 +150,6 @@ pfn_pte(unsigned long pfn, pgprot_t prot
 #define pte_offset(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_kernel(dir, address) pte_offset(dir, address)
-#include <asm/ptemap.h>
 
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
 
arch/mips/include/asm/pgtable-64.h renamed from arch/mips/include/asm/pgtable-64.h~remove-old-ptemap-includes +0 -1
diff -puN arch/mips/include/asm/pgtable-64.h~remove-old-ptemap-includes arch/mips/include/asm/pgtable-64.h
@@ -220,7 +220,6 @@ static inline pmd_t *pmd_offset(pud_t * 
 #define pte_offset(dir, address)					\
 	((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
 #define pte_offset_kernel(dir, address)	pte_offset(dir, address)
-#include <asm/ptemap.h>
 /*
  * Initialize a new pgd / pmd table with invalid pointers.
  */
arch/mn10300/include/asm/pgtable.h renamed from arch/mn10300/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/mn10300/include/asm/pgtable.h~remove-old-ptemap-includes arch/mn10300/include/asm/pgtable.h
@@ -455,8 +455,6 @@ static inline int set_kernel_exec(unsign
 	return 0;
 }
 
-#include <asm/ptemap.h>
-
 /*
  * The MN10300 has external MMU info in the form of a TLB: this is adapted from
  * the kernel page tables containing the necessary information by tlb-mn10300.S
arch/parisc/include/asm/pgtable.h renamed from arch/parisc/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/parisc/include/asm/pgtable.h~remove-old-ptemap-includes arch/parisc/include/asm/pgtable.h
@@ -397,8 +397,6 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_offset_kernel(pmd, address) \
 	((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address))
 
-#include <asm/ptemap.h>
-
 extern void paging_init (void);
 
 /* Used for deferring calls to flush_dcache_page() */
arch/powerpc/include/asm/pgtable-ppc64.h renamed from arch/powerpc/include/asm/pgtable-ppc64.h~remove-old-ptemap-includes +0 -2
diff -puN arch/powerpc/include/asm/pgtable-ppc64.h~remove-old-ptemap-includes arch/powerpc/include/asm/pgtable-ppc64.h
@@ -162,8 +162,6 @@
 #define pte_offset_kernel(dir,addr) \
   (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
 
-#include <asm/ptemap.h>
-
 /* to find an entry in a kernel page-table-directory */
 /* This now only contains the vmalloc pages */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
arch/s390/include/asm/pgtable.h renamed from arch/s390/include/asm/pgtable.h~remove-old-ptemap-includes +0 -2
diff -puN arch/s390/include/asm/pgtable.h~remove-old-ptemap-includes arch/s390/include/asm/pgtable.h
@@ -1041,8 +1041,6 @@ static inline pmd_t *pmd_offset(pud_t *p
 #define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))
 #define pte_offset_kernel(pmd, address) pte_offset(pmd,address)
 
-#include <asm/ptemap.h>
-
 /*
  * 31 bit swap entry format:
  * A page-table entry has some bits we have to treat in a special way.
arch/sh/include/asm/pgtable_32.h renamed from arch/sh/include/asm/pgtable_32.h~remove-old-ptemap-includes +0 -1
diff -puN arch/sh/include/asm/pgtable_32.h~remove-old-ptemap-includes arch/sh/include/asm/pgtable_32.h
@@ -403,7 +403,6 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_index(address)	((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
-#include <asm/ptemap.h>
 
 #ifdef CONFIG_X2TLB
 #define pte_ERROR(e) \
arch/sh/include/asm/pgtable_64.h renamed from arch/sh/include/asm/pgtable_64.h~remove-old-ptemap-includes +0 -2
diff -puN arch/sh/include/asm/pgtable_64.h~remove-old-ptemap-includes arch/sh/include/asm/pgtable_64.h
@@ -83,8 +83,6 @@ static __inline__ void pmd_set(pmd_t *pm
 #define pte_offset_kernel(dir, addr) \
 		((pte_t *) ((pmd_val(*(dir))) & PAGE_MASK) + pte_index((addr)))
 
-#include <asm/ptemap.h>
-
 #ifndef __ASSEMBLY__
 #define IOBASE_VADDR	0xff000000
 #define IOBASE_END	0xffffffff
arch/sparc/include/asm/pgtable_32.h renamed from arch/sparc/include/asm/pgtable_32.h~remove-old-ptemap-includes +0 -2
diff -puN arch/sparc/include/asm/pgtable_32.h~remove-old-ptemap-includes arch/sparc/include/asm/pgtable_32.h
@@ -300,8 +300,6 @@ BTFIXUPDEF_CALL(pmd_t *, pmd_offset, pgd
 BTFIXUPDEF_CALL(pte_t *, pte_offset_kernel, pmd_t *, unsigned long)
 #define pte_offset_kernel(dir,addr) BTFIXUP_CALL(pte_offset_kernel)(dir,addr)
 
-#include <asm/ptemap.h>
-
 /* Certain architectures need to do special things when pte's
  * within a page table are directly modified.  Thus, the following
  * hook is made available.
arch/sparc/include/asm/pgtable_64.h renamed from arch/sparc/include/asm/pgtable_64.h~remove-old-ptemap-includes +0 -2
diff -puN arch/sparc/include/asm/pgtable_64.h~remove-old-ptemap-includes arch/sparc/include/asm/pgtable_64.h
@@ -652,8 +652,6 @@ static inline int pte_special(pte_t pte)
 /* Find an entry in the third-level page table.. */
 #define pte_offset_kernel(dir, address)	\
 	((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
-#include <asm/ptemap.h>
-
 /* Actual page table PTE updates.  */
 extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig);
 
arch/um/include/asm/pgtable.h renamed from arch/um/include/asm/pgtable.h~remove-old-ptemap-includes +0 -1
diff -puN arch/um/include/asm/pgtable.h~remove-old-ptemap-includes arch/um/include/asm/pgtable.h
@@ -331,7 +331,6 @@ static inline pte_t pte_modify(pte_t pte
 #define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
 #define pte_offset_kernel(dir, address) \
 	((pte_t *) pmd_page_vaddr(*(dir)) +  pte_index(address))
-#include <asm/ptemap.h>
 struct mm_struct;
 extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
 
arch/x86/include/asm/pgtable_32.h renamed from arch/x86/include/asm/pgtable_32.h~remove-old-ptemap-includes +0 -2
diff -puN arch/x86/include/asm/pgtable_32.h~remove-old-ptemap-includes arch/x86/include/asm/pgtable_32.h
@@ -48,8 +48,6 @@ extern void set_pmd_pfn(unsigned long, u
 # include <asm/pgtable-2level.h>
 #endif
 
-#include <asm/ptemap.h>
-
 /* Clear a kernel PTE and flush it from the TLB */
 #define kpte_clear_flush(ptep, vaddr)		\
 do {						\
arch/x86/include/asm/pgtable_64.h renamed from arch/x86/include/asm/pgtable_64.h~remove-old-ptemap-includes +0 -2
diff -puN arch/x86/include/asm/pgtable_64.h~remove-old-ptemap-includes arch/x86/include/asm/pgtable_64.h
@@ -127,8 +127,6 @@ static inline int pgd_large(pgd_t pgd) {
 
 /* PTE - Level 1 access. */
 
-#include <asm/ptemap.h>
-
 #define update_mmu_cache(vma, address, pte) do { } while (0)
 
 extern int direct_gbpages;

diff -puN include/linux/ptemap.h~remove-old-ptemap-includes include/linux/ptemap.h diff -puN include/asm-generic/ptemap.h~remove-old-ptemap-includes include/asm-generic/ptemap.h _

#36 lore raw
In reply to Dave Hansen
Quoted 8 lines · Dave Hansen

The steps are as follows, and should be bisectable:
1. Break out all the functions into a new asm/ptemap.h and include it in place of the original functions.
2. Move linux/mm.h arch-independent pte mapping code to linux/ptemap.h, include asm/ptemap.h there
3. Include linux/ptemap.h directly at all use sites (only 39 of these kernel-wide)
4. Standardize all the implementations to use

Quoted 9 lines

pte_offset_kernel() as the basis for pte_offset_map() whenever possible.
5. Create asm-generic/ptemap.h and consolidate all the architectures that share the pte_offset_kernel() implementations.
6. Consolidate the three HIGHPTE implementations (x86, frv, ppc64) in asm-generic/ptemap.h.
7. Remove the direct asm/ptemap.h includes.

This is a nice cleanup. Did you consider going an extra step and converting all the macros into #defines?

J

#37 lore raw
Quoted 18 lines · Jeremy Fitzhardinge
Quoted 8 lines · Dave Hansen

The steps are as follows, and should be bisectable:
1. Break out all the functions into a new asm/ptemap.h and include it in place of the original functions.
2. Move linux/mm.h arch-independent pte mapping code to linux/ptemap.h, include asm/ptemap.h there
3. Include linux/ptemap.h directly at all use sites (only 39 of these kernel-wide)
4. Standardize all the implementations to use

Quoted 8 lines

pte_offset_kernel() as the basis for pte_offset_map() whenever possible.
5. Create asm-generic/ptemap.h and consolidate all the architectures that share the pte_offset_kernel() implementations.
6. Consolidate the three HIGHPTE implementations (x86, frv, ppc64) in asm-generic/ptemap.h.
7. Remove the direct asm/ptemap.h includes.

Quoted 2 lines

This is a nice cleanup. Did you consider going an extra step and converting all the macros into #defines?

Yup. I actually have a patch doing this sitting around that just needs a bit of cleanup. I'll certainly submit it if these get in.

-- Dave