linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Linux Memory Management <linux-mm@kvack.org>
Cc: Andi Kleen <ak@suse.de>, Hugh Dickins <hugh@veritas.com>,
	Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH 8/10] alternate 4-level page tables patches
Date: Sat, 18 Dec 2004 18:00:12 +1100	[thread overview]
Message-ID: <41C3D57C.5020005@yahoo.com.au> (raw)
In-Reply-To: <41C3D548.6080209@yahoo.com.au>

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

8/10

[-- Attachment #2: 4level-ia64.patch --]
[-- Type: text/plain, Size: 7795 bytes --]



Convert ia64 architecture over to handle 4 level pagetables.

Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>


---

 linux-2.6-npiggin/arch/ia64/mm/fault.c       |    7 ++++-
 linux-2.6-npiggin/arch/ia64/mm/hugetlbpage.c |   35 ++++++++++++---------------
 linux-2.6-npiggin/arch/ia64/mm/init.c        |   14 +++++++++-
 linux-2.6-npiggin/include/asm-ia64/pgalloc.h |    5 +--
 linux-2.6-npiggin/include/asm-ia64/pgtable.h |   14 ++++++----
 linux-2.6-npiggin/include/asm-ia64/tlb.h     |    6 ++++
 6 files changed, 50 insertions(+), 31 deletions(-)

diff -puN include/asm-ia64/pgtable.h~4level-ia64 include/asm-ia64/pgtable.h
--- linux-2.6/include/asm-ia64/pgtable.h~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/include/asm-ia64/pgtable.h	2004-12-18 17:03:12.000000000 +1100
@@ -254,11 +254,12 @@ ia64_phys_addr_valid (unsigned long addr
 #define pmd_page_kernel(pmd)		((unsigned long) __va(pmd_val(pmd) & _PFN_MASK))
 #define pmd_page(pmd)			virt_to_page((pmd_val(pmd) + PAGE_OFFSET))
 
-#define pgd_none(pgd)			(!pgd_val(pgd))
-#define pgd_bad(pgd)			(!ia64_phys_addr_valid(pgd_val(pgd)))
-#define pgd_present(pgd)		(pgd_val(pgd) != 0UL)
-#define pgd_clear(pgdp)			(pgd_val(*(pgdp)) = 0UL)
-#define pgd_page(pgd)			((unsigned long) __va(pgd_val(pgd) & _PFN_MASK))
+#define pud_none(pud)			(!pud_val(pud))
+#define pud_bad(pud)			(!ia64_phys_addr_valid(pud_val(pud)))
+#define pud_present(pud)		(pud_val(pud) != 0UL)
+#define pud_clear(pudp)			(pud_val(*(pudp)) = 0UL)
+
+#define pud_page(pud)			((unsigned long) __va(pud_val(pud) & _PFN_MASK))
 
 /*
  * The following have defined behavior only work if pte_present() is true.
@@ -328,7 +329,7 @@ pgd_offset (struct mm_struct *mm, unsign
 
 /* Find an entry in the second-level page table.. */
 #define pmd_offset(dir,addr) \
-	((pmd_t *) pgd_page(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
+	((pmd_t *) pud_page(*(dir)) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
 
 /*
  * Find an entry in the third-level page table.  This looks more complicated than it
@@ -561,5 +562,6 @@ do {											\
 #define __HAVE_ARCH_PTE_SAME
 #define __HAVE_ARCH_PGD_OFFSET_GATE
 #include <asm-generic/pgtable.h>
+#include <asm-generic/pgtable-nopud.h>
 
 #endif /* _ASM_IA64_PGTABLE_H */
diff -puN arch/ia64/mm/fault.c~4level-ia64 arch/ia64/mm/fault.c
--- linux-2.6/arch/ia64/mm/fault.c~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/arch/ia64/mm/fault.c	2004-12-18 17:03:12.000000000 +1100
@@ -51,6 +51,7 @@ static int
 mapped_kernel_page_is_present (unsigned long address)
 {
 	pgd_t *pgd;
+	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *ptep, pte;
 
@@ -58,7 +59,11 @@ mapped_kernel_page_is_present (unsigned 
 	if (pgd_none(*pgd) || pgd_bad(*pgd))
 		return 0;
 
-	pmd = pmd_offset(pgd, address);
+	pud = pud_offset(pgd, address);
+	if (pud_none(*pud) || pud_bad(*pud))
+		return 0;
+
+	pmd = pmd_offset(pud, address);
 	if (pmd_none(*pmd) || pmd_bad(*pmd))
 		return 0;
 
diff -puN arch/ia64/mm/hugetlbpage.c~4level-ia64 arch/ia64/mm/hugetlbpage.c
--- linux-2.6/arch/ia64/mm/hugetlbpage.c~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/arch/ia64/mm/hugetlbpage.c	2004-12-18 17:03:12.000000000 +1100
@@ -29,13 +29,17 @@ huge_pte_alloc (struct mm_struct *mm, un
 {
 	unsigned long taddr = htlbpage_to_page(addr);
 	pgd_t *pgd;
+	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte = NULL;
 
 	pgd = pgd_offset(mm, taddr);
-	pmd = pmd_alloc(mm, pgd, taddr);
-	if (pmd)
-		pte = pte_alloc_map(mm, pmd, taddr);
+	pud = pud_alloc(mm, pgd, taddr);
+	if (pud) {
+		pmd = pmd_alloc(mm, pud, taddr);
+		if (pmd)
+			pte = pte_alloc_map(mm, pmd, taddr);
+	}
 	return pte;
 }
 
@@ -44,14 +48,18 @@ huge_pte_offset (struct mm_struct *mm, u
 {
 	unsigned long taddr = htlbpage_to_page(addr);
 	pgd_t *pgd;
+	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte = NULL;
 
 	pgd = pgd_offset(mm, taddr);
 	if (pgd_present(*pgd)) {
-		pmd = pmd_offset(pgd, taddr);
-		if (pmd_present(*pmd))
-			pte = pte_offset_map(pmd, taddr);
+		pud = pud_offset(pgd, taddr);
+		if (pud_present(*pud)) {
+			pmd = pmd_offset(pud, taddr);
+			if (pmd_present(*pmd))
+				pte = pte_offset_map(pmd, taddr);
+		}
 	}
 
 	return pte;
@@ -187,7 +195,6 @@ void hugetlb_free_pgtables(struct mmu_ga
 {
 	unsigned long first = start & HUGETLB_PGDIR_MASK;
 	unsigned long last = end + HUGETLB_PGDIR_SIZE - 1;
-	unsigned long start_index, end_index;
 	struct mm_struct *mm = tlb->mm;
 
 	if (!prev) {
@@ -212,23 +219,13 @@ void hugetlb_free_pgtables(struct mmu_ga
 				last = next->vm_start;
 		}
 		if (prev->vm_end > first)
-			first = prev->vm_end + HUGETLB_PGDIR_SIZE - 1;
+			first = prev->vm_end;
 		break;
 	}
 no_mmaps:
 	if (last < first)	/* for arches with discontiguous pgd indices */
 		return;
-	/*
-	 * If the PGD bits are not consecutive in the virtual address, the
-	 * old method of shifting the VA >> by PGDIR_SHIFT doesn't work.
-	 */
-
-	start_index = pgd_index(htlbpage_to_page(first));
-	end_index = pgd_index(htlbpage_to_page(last));
-
-	if (end_index > start_index) {
-		clear_page_tables(tlb, start_index, end_index - start_index);
-	}
+	clear_page_range(tlb, first, last);
 }
 
 void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
diff -puN arch/ia64/mm/init.c~4level-ia64 arch/ia64/mm/init.c
--- linux-2.6/arch/ia64/mm/init.c~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/arch/ia64/mm/init.c	2004-12-18 17:03:12.000000000 +1100
@@ -237,6 +237,7 @@ struct page *
 put_kernel_page (struct page *page, unsigned long address, pgprot_t pgprot)
 {
 	pgd_t *pgd;
+	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte;
 
@@ -248,7 +249,11 @@ put_kernel_page (struct page *page, unsi
 
 	spin_lock(&init_mm.page_table_lock);
 	{
-		pmd = pmd_alloc(&init_mm, pgd, address);
+		pud = pud_alloc(&init_mm, pgd, address);
+		if (!pud)
+			goto out;
+
+		pmd = pmd_alloc(&init_mm, pud, address);
 		if (!pmd)
 			goto out;
 		pte = pte_alloc_map(&init_mm, pmd, address);
@@ -381,6 +386,7 @@ create_mem_map_page_table (u64 start, u6
 	struct page *map_start, *map_end;
 	int node;
 	pgd_t *pgd;
+	pud_t *pud;
 	pmd_t *pmd;
 	pte_t *pte;
 
@@ -395,7 +401,11 @@ create_mem_map_page_table (u64 start, u6
 		pgd = pgd_offset_k(address);
 		if (pgd_none(*pgd))
 			pgd_populate(&init_mm, pgd, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
-		pmd = pmd_offset(pgd, address);
+		pud = pud_offset(pgd, address);
+
+		if (pud_none(*pud))
+			pud_populate(&init_mm, pud, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
+		pmd = pmd_offset(pud, address);
 
 		if (pmd_none(*pmd))
 			pmd_populate_kernel(&init_mm, pmd, alloc_bootmem_pages_node(NODE_DATA(node), PAGE_SIZE));
diff -puN include/asm-ia64/pgalloc.h~4level-ia64 include/asm-ia64/pgalloc.h
--- linux-2.6/include/asm-ia64/pgalloc.h~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/include/asm-ia64/pgalloc.h	2004-12-18 17:03:12.000000000 +1100
@@ -79,12 +79,11 @@ pgd_free (pgd_t *pgd)
 }
 
 static inline void
-pgd_populate (struct mm_struct *mm, pgd_t *pgd_entry, pmd_t *pmd)
+pud_populate (struct mm_struct *mm, pud_t *pud_entry, pmd_t *pmd)
 {
-	pgd_val(*pgd_entry) = __pa(pmd);
+	pud_val(*pud_entry) = __pa(pmd);
 }
 
-
 static inline pmd_t*
 pmd_alloc_one_fast (struct mm_struct *mm, unsigned long addr)
 {
diff -puN include/asm-ia64/tlb.h~4level-ia64 include/asm-ia64/tlb.h
--- linux-2.6/include/asm-ia64/tlb.h~4level-ia64	2004-12-18 17:03:12.000000000 +1100
+++ linux-2.6-npiggin/include/asm-ia64/tlb.h	2004-12-18 17:03:12.000000000 +1100
@@ -236,4 +236,10 @@ do {							\
 	__pmd_free_tlb(tlb, ptep);			\
 } while (0)
 
+#define pud_free_tlb(tlb, pudp)				\
+do {							\
+	tlb->need_flush = 1;				\
+	__pud_free_tlb(tlb, pudp);			\
+} while (0)
+
 #endif /* _ASM_IA64_TLB_H */

_

  reply	other threads:[~2004-12-18  7:00 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-18  6:55 [RFC][PATCH 0/10] " Nick Piggin
2004-12-18  6:55 ` [PATCH 1/10] " Nick Piggin
2004-12-18  6:56   ` [PATCH 2/10] " Nick Piggin
2004-12-18  6:56     ` [PATCH 3/10] " Nick Piggin
2004-12-18  6:57       ` [PATCH 4/10] " Nick Piggin
2004-12-18  6:58         ` [PATCH 5/10] " Nick Piggin
2004-12-18  6:58           ` [PATCH 6/10] " Nick Piggin
2004-12-18  6:59             ` [PATCH 7/10] " Nick Piggin
2004-12-18  7:00               ` Nick Piggin [this message]
2004-12-18  7:00                 ` [PATCH 9/10] " Nick Piggin
2004-12-18  7:01                   ` [PATCH 10/10] " Nick Piggin
2004-12-18  7:31                     ` Andi Kleen
2004-12-18  7:46                       ` Nick Piggin
2004-12-18  8:08                       ` Andrew Morton
2004-12-18  9:48                         ` Andi Kleen
2004-12-18 19:06                       ` Linus Torvalds
2004-12-20 17:43                         ` Andi Kleen
2004-12-20 17:47                           ` Randy.Dunlap
2004-12-20 18:08                           ` Linus Torvalds
2004-12-20 18:15                             ` Linus Torvalds
2004-12-20 18:19                             ` Andi Kleen
2004-12-20 18:47                               ` Linus Torvalds
2004-12-20 18:52                                 ` Linus Torvalds
2004-12-20 18:59                                 ` Andi Kleen
2004-12-20 18:57                                   ` Randy.Dunlap
2004-12-18  9:05         ` [PATCH 4/10] " Nick Piggin
2004-12-18  9:50           ` Andi Kleen
2004-12-18 10:06             ` Nick Piggin
2004-12-18 10:11               ` Andi Kleen
2004-12-18 10:22               ` Nick Piggin
2004-12-18 10:29                 ` Nick Piggin
2004-12-18 11:06               ` William Lee Irwin III
2004-12-18 11:17                 ` Nick Piggin
2004-12-18 11:32                   ` William Lee Irwin III
2004-12-18 11:55                     ` Nick Piggin
2004-12-18 12:46                       ` William Lee Irwin III
2004-12-18 12:48                         ` William Lee Irwin III
2004-12-19  0:05                         ` Nick Piggin
2004-12-19  0:20                           ` William Lee Irwin III
2004-12-19  0:38                             ` Nick Piggin
2004-12-19  1:01                               ` William Lee Irwin III
2004-12-19  1:31                             ` Linus Torvalds
2004-12-19  2:08                               ` William Lee Irwin III
2004-12-19  2:26                                 ` Nick Piggin
2004-12-19  5:23                                 ` Linus Torvalds
2004-12-19  6:02                                   ` William Lee Irwin III
2004-12-19 18:17                                     ` Linus Torvalds
2004-12-20  1:00                                       ` William Lee Irwin III
2004-12-18 10:45         ` William Lee Irwin III
2004-12-18 10:58           ` Nick Piggin
2004-12-19  0:07 ` [RFC][PATCH 0/10] " Hugh Dickins
2004-12-19  0:33   ` Nick Piggin
2004-12-20 18:04   ` Andi Kleen
2004-12-20 18:40     ` Linus Torvalds
2004-12-20 18:53       ` Andi Kleen
2004-12-21  0:04         ` Linus Torvalds
2004-12-21  0:22           ` Andi Kleen
2004-12-21  0:43             ` Linus Torvalds
2004-12-21  0:47             ` Nick Piggin
2004-12-21  2:55               ` Hugh Dickins
2004-12-21  3:21                 ` Nick Piggin
2004-12-21  3:47                 ` Linus Torvalds
2004-12-21  3:56                   ` Linus Torvalds
2004-12-21  4:04                     ` Nick Piggin
2004-12-21  4:08                       ` Nick Piggin
2004-12-21  9:36                     ` Andi Kleen
2004-12-21 10:13                       ` Hugh Dickins
2004-12-21 10:59                       ` Nick Piggin
2004-12-21 17:36                       ` Linus Torvalds
2004-12-21 20:19                         ` Andi Kleen
2004-12-21 23:49                           ` Nick Piggin
2004-12-22 10:38                             ` Andi Kleen
2004-12-22 11:19                               ` Nick Piggin
2004-12-22 11:23                                 ` Nick Piggin
2004-12-22 18:07                                 ` Andi Kleen
2004-12-30 21:24                                   ` Nick Piggin
2004-12-21 10:52                     ` Nick Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41C3D57C.5020005@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox