Skip to content

Commit a73c948

Browse files
rppttorvalds
authored andcommitted
alpha: use pgtable-nopud instead of 4level-fixup
Patch series "mm: remove __ARCH_HAS_4LEVEL_HACK", v13. These patches convert several architectures to use page table folding and remove __ARCH_HAS_4LEVEL_HACK along with include/asm-generic/4level-fixup.h. For the nommu configurations the folding is already implemented by the generic code so the only change was to use the appropriate header file. As for the rest, the changes are mostly about mechanical replacement of pgd accessors with pud/pmd ones and the addition of higher levels to page table traversals. With Vineet's patches from "elide extraneous generated code for folded p4d/pud/pmd" series [1] there is a small shrink of the kernel size of about -0.01% for the defconfig builds. This patch (of 13): It is not likely alpha will have 5-level page tables. Replace usage of include/asm-generic/4level-fixup.h and implied __ARCH_HAS_4LEVEL_HACK with include/asm-generic/pgtable-nopud.h and adjust page table manipulation macros and functions accordingly. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Rapoport <[email protected]> Cc: Anton Ivanov <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: Helge Deller <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Jeff Dike <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Mark Salter <[email protected]> Cc: Matt Turner <[email protected]> Cc: Michal Simek <[email protected]> Cc: Peter Rosin <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Rolf Eike Beer <[email protected]> Cc: Russell King <[email protected]> Cc: Sam Creasey <[email protected]> Cc: Vincent Chen <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Anatoly Pugachev <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b27d851 commit a73c948

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

arch/alpha/include/asm/mmzone.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n)
7373
#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
7474

7575
#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> 32))
76-
#define pgd_page(pgd) (pfn_to_page(pgd_val(pgd) >> 32))
7776
#define pte_pfn(pte) (pte_val(pte) >> 32)
7877

7978
#define mk_pte(page, pgprot) \

arch/alpha/include/asm/pgalloc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)
2727
}
2828

2929
static inline void
30-
pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
30+
pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
3131
{
32-
pgd_set(pgd, pmd);
32+
pud_set(pud, pmd);
3333
}
3434

3535
extern pgd_t *pgd_alloc(struct mm_struct *mm);

arch/alpha/include/asm/pgtable.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef _ALPHA_PGTABLE_H
33
#define _ALPHA_PGTABLE_H
44

5-
#include <asm-generic/4level-fixup.h>
5+
#include <asm-generic/pgtable-nopud.h>
66

77
/*
88
* This file contains the functions and defines necessary to modify and use
@@ -226,8 +226,8 @@ extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
226226
extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
227227
{ pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
228228

229-
extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
230-
{ pgd_val(*pgdp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
229+
extern inline void pud_set(pud_t * pudp, pmd_t * pmdp)
230+
{ pud_val(*pudp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
231231

232232

233233
extern inline unsigned long
@@ -238,11 +238,11 @@ pmd_page_vaddr(pmd_t pmd)
238238

239239
#ifndef CONFIG_DISCONTIGMEM
240240
#define pmd_page(pmd) (mem_map + ((pmd_val(pmd) & _PFN_MASK) >> 32))
241-
#define pgd_page(pgd) (mem_map + ((pgd_val(pgd) & _PFN_MASK) >> 32))
241+
#define pud_page(pud) (mem_map + ((pud_val(pud) & _PFN_MASK) >> 32))
242242
#endif
243243

244-
extern inline unsigned long pgd_page_vaddr(pgd_t pgd)
245-
{ return PAGE_OFFSET + ((pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
244+
extern inline unsigned long pud_page_vaddr(pud_t pgd)
245+
{ return PAGE_OFFSET + ((pud_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
246246

247247
extern inline int pte_none(pte_t pte) { return !pte_val(pte); }
248248
extern inline int pte_present(pte_t pte) { return pte_val(pte) & _PAGE_VALID; }
@@ -256,10 +256,10 @@ extern inline int pmd_bad(pmd_t pmd) { return (pmd_val(pmd) & ~_PFN_MASK) != _P
256256
extern inline int pmd_present(pmd_t pmd) { return pmd_val(pmd) & _PAGE_VALID; }
257257
extern inline void pmd_clear(pmd_t * pmdp) { pmd_val(*pmdp) = 0; }
258258

259-
extern inline int pgd_none(pgd_t pgd) { return !pgd_val(pgd); }
260-
extern inline int pgd_bad(pgd_t pgd) { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE; }
261-
extern inline int pgd_present(pgd_t pgd) { return pgd_val(pgd) & _PAGE_VALID; }
262-
extern inline void pgd_clear(pgd_t * pgdp) { pgd_val(*pgdp) = 0; }
259+
extern inline int pud_none(pud_t pud) { return !pud_val(pud); }
260+
extern inline int pud_bad(pud_t pud) { return (pud_val(pud) & ~_PFN_MASK) != _PAGE_TABLE; }
261+
extern inline int pud_present(pud_t pud) { return pud_val(pud) & _PAGE_VALID; }
262+
extern inline void pud_clear(pud_t * pudp) { pud_val(*pudp) = 0; }
263263

264264
/*
265265
* The following only work if pte_present() is true.
@@ -301,9 +301,9 @@ extern inline pte_t pte_mkspecial(pte_t pte) { return pte; }
301301
*/
302302

303303
/* Find an entry in the second-level page table.. */
304-
extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
304+
extern inline pmd_t * pmd_offset(pud_t * dir, unsigned long address)
305305
{
306-
pmd_t *ret = (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
306+
pmd_t *ret = (pmd_t *) pud_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
307307
smp_read_barrier_depends(); /* see above */
308308
return ret;
309309
}

arch/alpha/mm/init.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ callback_init(void * kernel_end)
146146
{
147147
struct crb_struct * crb;
148148
pgd_t *pgd;
149+
p4d_t *p4d;
150+
pud_t *pud;
149151
pmd_t *pmd;
150152
void *two_pages;
151153

@@ -184,8 +186,10 @@ callback_init(void * kernel_end)
184186
memset(two_pages, 0, 2*PAGE_SIZE);
185187

186188
pgd = pgd_offset_k(VMALLOC_START);
187-
pgd_set(pgd, (pmd_t *)two_pages);
188-
pmd = pmd_offset(pgd, VMALLOC_START);
189+
p4d = p4d_offset(pgd, VMALLOC_START);
190+
pud = pud_offset(p4d, VMALLOC_START);
191+
pud_set(pud, (pmd_t *)two_pages);
192+
pmd = pmd_offset(pud, VMALLOC_START);
189193
pmd_set(pmd, (pte_t *)(two_pages + PAGE_SIZE));
190194

191195
if (alpha_using_srm) {
@@ -214,9 +218,9 @@ callback_init(void * kernel_end)
214218
/* Newer consoles (especially on larger
215219
systems) may require more pages of
216220
PTEs. Grab additional pages as needed. */
217-
if (pmd != pmd_offset(pgd, vaddr)) {
221+
if (pmd != pmd_offset(pud, vaddr)) {
218222
memset(kernel_end, 0, PAGE_SIZE);
219-
pmd = pmd_offset(pgd, vaddr);
223+
pmd = pmd_offset(pud, vaddr);
220224
pmd_set(pmd, (pte_t *)kernel_end);
221225
kernel_end += PAGE_SIZE;
222226
}

0 commit comments

Comments
 (0)