aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Daney <david.daney@cavium.com>2012-08-14 14:08:01 -0400
committerRalf Baechle <ralf@linux-mips.org>2012-10-11 05:02:40 -0400
commit485172b3dff29f888a88d3dba8caec5d589a4049 (patch)
treef496bccfd49a973be2f4789baa45574dbcb96af0 /arch
parentc87728ca82a1057eb8f84e139bf416ca5488b6fb (diff)
MIPS: Align swapper_pg_dir to 64K for better TLB Refill code.
We can save an instruction in the TLB Refill path for kernel mappings by aligning swapper_pg_dir on a 64K boundary. The address of swapper_pg_dir can be generated with a single LUI instead of LUI/{D}ADDUI. The alignment of __init_end is bumped up to 64K so there are no holes between it and swapper_pg_dir, which is placed at the very beginning of .bss. The alignment of invalid_pmd_table and invalid_pte_table can be relaxed to PAGE_SIZE. We do this by using __page_aligned_bss, which has the added benefit of eliminating alignment holes in .bss. Signed-off-by: David Daney <david.daney@cavium.com> Cc: linux-mips@linux-mips.org Cc: linux-arch@vger.kernel.org, Cc: linux-kernel@vger.kernel.org Acked-by: Arnd Bergmann <arnd@arndb.de> Patchwork: https://patchwork.linux-mips.org/patch/4220/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/kernel/vmlinux.lds.S21
-rw-r--r--arch/mips/mm/init.c17
2 files changed, 28 insertions, 10 deletions
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index df243a64f430..007ccbe1e264 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -1,6 +1,13 @@
1#include <asm/asm-offsets.h> 1#include <asm/asm-offsets.h>
2#include <asm/page.h> 2#include <asm/page.h>
3#include <asm/thread_info.h> 3#include <asm/thread_info.h>
4
5/*
6 * Put .bss..swapper_pg_dir as the first thing in .bss. This will
7 * ensure that it has .bss alignment (64K).
8 */
9#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
10
4#include <asm-generic/vmlinux.lds.h> 11#include <asm-generic/vmlinux.lds.h>
5 12
6#undef mips 13#undef mips
@@ -119,11 +126,21 @@ SECTIONS
119 } 126 }
120 127
121 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 128 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
122 . = ALIGN(PAGE_SIZE); 129 /*
130 * Align to 64K in attempt to eliminate holes before the
131 * .bss..swapper_pg_dir section at the start of .bss. This
132 * also satisfies PAGE_SIZE alignment as the largest page size
133 * allowed is 64K.
134 */
135 . = ALIGN(0x10000);
123 __init_end = .; 136 __init_end = .;
124 /* freed after init ends here */ 137 /* freed after init ends here */
125 138
126 BSS_SECTION(0, 0, 0) 139 /*
140 * Force .bss to 64K alignment so that .bss..swapper_pg_dir
141 * gets that alignment. .sbss should be empty, so there will be
142 * no holes after __init_end. */
143 BSS_SECTION(0, 0x10000, 0)
127 144
128 _end = . ; 145 _end = . ;
129 146
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 1a85ba92eb5c..be9acb2b959d 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -469,19 +469,20 @@ void __init_refok free_initmem(void)
469#ifndef CONFIG_MIPS_PGD_C0_CONTEXT 469#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
470unsigned long pgd_current[NR_CPUS]; 470unsigned long pgd_current[NR_CPUS];
471#endif 471#endif
472/*
473 * On 64-bit we've got three-level pagetables with a slightly
474 * different layout ...
475 */
476#define __page_aligned(order) __attribute__((__aligned__(PAGE_SIZE<<order)))
477 472
478/* 473/*
479 * gcc 3.3 and older have trouble determining that PTRS_PER_PGD and PGD_ORDER 474 * gcc 3.3 and older have trouble determining that PTRS_PER_PGD and PGD_ORDER
480 * are constants. So we use the variants from asm-offset.h until that gcc 475 * are constants. So we use the variants from asm-offset.h until that gcc
481 * will officially be retired. 476 * will officially be retired.
477 *
478 * Align swapper_pg_dir in to 64K, allows its address to be loaded
479 * with a single LUI instruction in the TLB handlers. If we used
480 * __aligned(64K), its size would get rounded up to the alignment
481 * size, and waste space. So we place it in its own section and align
482 * it in the linker script.
482 */ 483 */
483pgd_t swapper_pg_dir[_PTRS_PER_PGD] __page_aligned(_PGD_ORDER); 484pgd_t swapper_pg_dir[_PTRS_PER_PGD] __section(.bss..swapper_pg_dir);
484#ifndef __PAGETABLE_PMD_FOLDED 485#ifndef __PAGETABLE_PMD_FOLDED
485pmd_t invalid_pmd_table[PTRS_PER_PMD] __page_aligned(PMD_ORDER); 486pmd_t invalid_pmd_table[PTRS_PER_PMD] __page_aligned_bss;
486#endif 487#endif
487pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER); 488pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned_bss;