Skip to contentSkip to conversation

move around pgtable headers

RFC New Dave Hansen 1 participant 1 message Feb 26, 2003 Memory management

lore
Share & tools
lore
#0 lore raw

RFC 1/1 move around pgtable headers

I was screwing around with changing some macros in pgtable-3level.h into static inlines and I quickly ran into some dependency problems. Mainly, pgtable-3level.h was included from pgtable.h before __pmd_offset() was defined, and I wanted to use __pmd_offset() in a function instead of a macro.

Anyway I have some _really_ rough demonstration of what I would like to do in the attached patch. What I want to see is some more explicit definitions of what the dependencies are in the various header files. Is this anything that people would like to see expanded?

I haven't even gotten close to moving all of the macros into the ops.h file, but you can probably get the idea.

 page.h                 |   26 ------------------------
 pgtable-2level.h       |   19 +++--------------
 pgtable-3level.h       |   53 +++++++++++++++++++----------------------
 pgtable.h              |    3 --
 pgtable/const-2level.h |   17 +++++++++++++++
 pgtable/const-3level.h |   25 +++++++++++++++++++++++
 pgtable/const.h        |   12 +++++++++++
 pgtable/ops.h          |   17 +++++++++++++++
 pgtable/types-2level.h |   10 +++++++++
 pgtable/types-3level.h |   10 +++++++++
 pgtable/types.h        |   12 +++++++++++
 13 files changed, 132 insertions(+), 72 deletions(-)
Signature · 2 lines
Dave Hansen
[email protected]

Binary files linux-2.5.62-clean/include/asm-i386/.page.h.swp and linux-2.5.62-vm_names/include/asm-i386/.page.h.swp differ Binary files linux-2.5.62-clean/include/asm-i386/.pgtable-3level.h.swp and linux-2.5.62-vm_names/include/asm-i386/.pgtable-3level.h.swp differ

include/asm-i386/page.h +1 -25
diff -urN linux-2.5.62-clean/include/asm-i386/page.h linux-2.5.62-vm_names/include/asm-i386/page.h
@@ -13,6 +13,7 @@
 #ifndef __ASSEMBLY__
 
 #include <linux/config.h>
+#include <asm/pgtable/types.h>
 
 #ifdef CONFIG_X86_USE_3DNOW
 
@@ -36,22 +37,6 @@
 #define clear_user_page(page, vaddr, pg)	clear_page(page)
 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
 
-/*
- * These are used to make use of C type-checking..
- */
-#ifdef CONFIG_X86_PAE
-typedef struct { unsigned long pte_low, pte_high; } pte_t;
-typedef struct { unsigned long long pmd; } pmd_t;
-typedef struct { unsigned long long pgd; } pgd_t;
-#define pte_val(x)	((x).pte_low | ((unsigned long long)(x).pte_high << 32))
-#define HPAGE_SHIFT	21
-#else
-typedef struct { unsigned long pte_low; } pte_t;
-typedef struct { unsigned long pmd; } pmd_t;
-typedef struct { unsigned long pgd; } pgd_t;
-#define pte_val(x)	((x).pte_low)
-#define HPAGE_SHIFT	22
-#endif
 #define PTE_MASK	PAGE_MASK
 
 #ifdef CONFIG_HUGETLB_PAGE
@@ -61,15 +46,6 @@
 #endif
 
 typedef struct { unsigned long pgprot; } pgprot_t;
-
-#define pmd_val(x)	((x).pmd)
-#define pgd_val(x)	((x).pgd)
-#define pgprot_val(x)	((x).pgprot)
-
-#define __pte(x) ((pte_t) { (x) } )
-#define __pmd(x) ((pmd_t) { (x) } )
-#define __pgd(x) ((pgd_t) { (x) } )
-#define __pgprot(x)	((pgprot_t) { (x) } )
 
 #endif /* !__ASSEMBLY__ */
 
include/asm-i386/pgtable/const-2level.h +17 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/const-2level.h linux-2.5.62-vm_names/include/asm-i386/pgtable/const-2level.h
@@ -0,0 +1,17 @@
+
+/*
+ * traditional i386 two-level paging structure:
+ */
+
+#define PGDIR_SHIFT	22
+#define PTRS_PER_PGD	1024
+
+/*
+ * the i386 is two-level, so we don't really have any
+ * PMD directory physically.
+ */
+#define PMD_SHIFT	22
+#define PTRS_PER_PMD	1
+
+#define PTRS_PER_PTE	1024
+
include/asm-i386/pgtable/const-3level.h +25 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/const-3level.h linux-2.5.62-vm_names/include/asm-i386/pgtable/const-3level.h
@@ -0,0 +1,25 @@
+/*
+ * Intel Physical Address Extension (PAE) Mode - three-level page
+ * tables on PPro+ CPUs.
+ *
+ * Copyright (C) 1999 Ingo Molnar <[email protected]> 
+ */
+ 
+/*
+ * PGDIR_SHIFT determines what a top-level page table entry can map
+ */
+#define PGDIR_SHIFT     30 
+#define PTRS_PER_PGD    4
+
+/*
+ * PMD_SHIFT determines the size of the area a middle-level
+ * page table can map
+ */
+#define PMD_SHIFT       21
+#define PTRS_PER_PMD    512
+
+/*
+ * entries per page directory level
+ */
+#define PTRS_PER_PTE    512
+
include/asm-i386/pgtable/const.h +12 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/const.h linux-2.5.62-vm_names/include/asm-i386/pgtable/const.h
@@ -0,0 +1,12 @@
+#ifndef _I386_PGTABLE_CONST_H_
+#define _I386_PGTABLE_CONST_H_
+
+#include <linux/config.h>
+
+#ifdef CONFIG_X86_PAE
+ #include <asm/pgtable/const-3level.h>
+#else
+ #include <asm/pgtable/const-2level.h>
+#endif
+
+#endif
include/asm-i386/pgtable/ops.h +17 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/ops.h linux-2.5.62-vm_names/include/asm-i386/pgtable/ops.h
@@ -0,0 +1,17 @@
+#ifndef __I386_PGTABLE_OPS_H_
+#define __I386_PGTABLE_OPS_H_
+
+#define pmd_val(x)      ((x).pmd)
+#define pgd_val(x)      ((x).pgd)
+#define pgprot_val(x)   ((x).pgprot)
+
+#define __pte(x) ((pte_t) { (x) } )
+#define __pmd(x) ((pmd_t) { (x) } )
+#define __pgd(x) ((pgd_t) { (x) } )
+#define __pgprot(x)     ((pgprot_t) { (x) } )
+
+
+#define __pmd_offset(address) \
+		(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+
+#endif
include/asm-i386/pgtable/types-2level.h +10 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/types-2level.h linux-2.5.62-vm_names/include/asm-i386/pgtable/types-2level.h
@@ -0,0 +1,10 @@
+#ifndef _I386_PGTABLE_TYPES_2LEVEL_H_
+#define _I386_PGTABLE_TYPES_2LEVEL_H_
+
+typedef struct { unsigned long pte_low; } pte_t;
+typedef struct { unsigned long pmd; } pmd_t;
+typedef struct { unsigned long pgd; } pgd_t;
+#define pte_val(x)	((x).pte_low)
+#define HPAGE_SHIFT	22
+
+#endif
include/asm-i386/pgtable/types-3level.h +10 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/types-3level.h linux-2.5.62-vm_names/include/asm-i386/pgtable/types-3level.h
@@ -0,0 +1,10 @@
+#ifndef _I386_PGTABLE_TYPES_3LEVEL_H_
+#define _I386_PGTABLE_TYPES_3LEVEL_H_
+
+typedef struct { unsigned long pte_low, pte_high; } pte_t;
+typedef struct { unsigned long long pmd; } pmd_t;
+typedef struct { unsigned long long pgd; } pgd_t;
+#define pte_val(x)	((x).pte_low | ((unsigned long long)(x).pte_high << 32))
+#define HPAGE_SHIFT	21
+
+#endif
include/asm-i386/pgtable/types.h +12 -0
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable/types.h linux-2.5.62-vm_names/include/asm-i386/pgtable/types.h
@@ -0,0 +1,12 @@
+#ifndef _I386_PGTABLE_TYPES_H_
+#define _I386_PGTABLE_TYPES_H_
+
+#include <linux/config.h>
+
+#ifdef CONFIG_X86_PAE
+ #include <asm/pgtable/types-3level.h>
+#else
+ #include <asm/pgtable/types-2level.h>
+#endif
+
+#endif
include/asm-i386/pgtable-2level.h +4 -15
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable-2level.h linux-2.5.62-vm_names/include/asm-i386/pgtable-2level.h
@@ -1,21 +1,10 @@
 #ifndef _I386_PGTABLE_2LEVEL_H
 #define _I386_PGTABLE_2LEVEL_H
 
-/*
- * traditional i386 two-level paging structure:
- */
-
-#define PGDIR_SHIFT	22
-#define PTRS_PER_PGD	1024
-
-/*
- * the i386 is two-level, so we don't really have any
- * PMD directory physically.
- */
-#define PMD_SHIFT	22
-#define PTRS_PER_PMD	1
-
-#define PTRS_PER_PTE	1024
+/* these are order-dependent right now */
+#include <asm/pgtable/types.h>
+#include <asm/pgtable/const.h>
+#include <asm/pgtable/ops.h>
 
 #define pte_ERROR(e) \
 	printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
include/asm-i386/pgtable-3level.h +24 -29

66 lines not on this page · raw message

include/asm-i386/pgtable.h +0 -3
diff -urN linux-2.5.62-clean/include/asm-i386/pgtable.h linux-2.5.62-vm_names/include/asm-i386/pgtable.h
@@ -242,9 +242,6 @@
 /* to find an entry in a kernel page-table-directory */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
-#define __pmd_offset(address) \
-		(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
-
 /* Find an entry in the third-level page table.. */
 #define __pte_offset(address) \
 		(((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))