powerpc 44x: support for 256KB PAGE_SIZE
PATCH 1/1 powerpc 44x: support for 256KB PAGE_SIZE
This patch adds support for 256KB pages on ppc44x-based boards.
For simplification of implementation with 256KB pages we still assume 2-level paging. As a side effect this leads to wasting extra memory space reserved for PTE tables: only 1/4 of pages allocated for PTEs are actually used. But this may be an acceptable trade-off to achieve the high performance we have with big PAGE_SIZEs in some applications (e.g. RAID).
Also with 256KB PAGE_SIZE we increase THREAD_SIZE up to 32KB to minimize the risk of stack overflows in the cases of on-stack arrays, which size depends on the page size (e.g. multipage BIOs, NTFS, etc.).
With 256KB PAGE_SIZE we need to decrease the PKMAP_ORDER at least down to 9, otherwise all high memory (2 ^ 10 * PAGE_SIZE == 256MB) we'll be occupied by PKMAP addresses leaving no place for vmalloc. We do not separate PKMAP_ORDER for 256K from 16K/64K PAGE_SIZE here; actually that value of 10 in support for 16K/64K had been selected rather intuitively. Thus now for all cases of PAGE_SIZE on ppc44x (including the default, 4KB, one) we have 512 pages for PKMAP.
Because ELF standard supports only page sizes up to 64K, then you should use patched binutils for building applications to be run with the 256KB- page sized kernel. The patch for binutils is rather trivial, and may look as follows:
--- binutils/bfd/elf32-ppc.c.orig
+++ binutils/bfd/elf32-ppc.c
-#define ELF_MAXPAGESIZE 0x10000
+#define ELF_MAXPAGESIZE 0x40000
--- arch/powerpc/Kconfig | 10 ++++++++++ arch/powerpc/include/asm/highmem.h | 10 +++++----- arch/powerpc/include/asm/mmu-44x.h | 2 ++ arch/powerpc/include/asm/page.h | 6 ++++-- arch/powerpc/include/asm/page_32.h | 4 ++++ arch/powerpc/include/asm/thread_info.h | 4 ++++ arch/powerpc/kernel/head_booke.h | 10 +++++++++- init/Kconfig | 10 ++++++++++ 8 files changed, 48 insertions(+), 8 deletions(-)
arch/powerpc/Kconfig +10 -0
@@ -436,6 +436,14 @@ config PPC_64K_PAGES bool "64k page size" if 44x || PPC_STD_MMU_64 select PPC_HAS_HASH_64K if PPC_STD_MMU_64 +config PPC_256K_PAGES + bool "256k page size" if 44x + depends on !STDBINUTILS + help + ELF standard supports only page sizes up to 64K so you need a patched + binutils in order to use 256K pages. Chose it only if you know what + you are doing. + endchoice config FORCE_MAX_ZONEORDER
@@ -448,6 +456,8 @@ config FORCE_MAX_ZONEORDER default "9" if PPC_STD_MMU_32 && PPC_16K_PAGES range 7 64 if PPC_STD_MMU_32 && PPC_64K_PAGES default "7" if PPC_STD_MMU_32 && PPC_64K_PAGES + range 5 64 if PPC_STD_MMU_32 && PPC_256K_PAGES + default "5" if PPC_STD_MMU_32 && PPC_256K_PAGES range 11 64 default "11" help
arch/powerpc/include/asm/highmem.h +5 -5
@@ -39,15 +39,15 @@ extern pte_t *pkmap_page_table;* chunk of RAM. */ /* -* We use one full pte table with 4K pages. And with 16K/64K pages pte -* table covers enough memory (32MB and 512MB resp.) that both FIXMAP -* and PKMAP can be placed in single pte table. We use 1024 pages for -* PKMAP in case of 16K/64K pages. +* We use one full pte table with 4K pages. And with 16K/64K/256K pages pte +* table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP +* and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP +* in case of 16K/64K/256K page sizes. */ #ifdef CONFIG_PPC_4K_PAGES #define PKMAP_ORDER PTE_SHIFT#else -#define PKMAP_ORDER 10 +#define PKMAP_ORDER 9#endif #define LAST_PKMAP (1 << PKMAP_ORDER)#ifndef CONFIG_PPC_4K_PAGES
arch/powerpc/include/asm/mmu-44x.h +2 -0
@@ -81,6 +81,8 @@ typedef struct {#define PPC44x_TLBE_SIZE PPC44x_TLB_16K#elif (PAGE_SHIFT ==16 )#define PPC44x_TLBE_SIZE PPC44x_TLB_64K +#elif (PAGE_SHIFT ==18 ) +#define PPC44x_TLBE_SIZE PPC44x_TLB_256K#else #error "Unsupported PAGE_SIZE"#endif
arch/powerpc/include/asm/page.h +4 -2
@@ -19,12 +19,14 @@#include <asm/kdump.h> /* -* On regular PPC32 page size is 4K (but we support 4K/16K/64K pages +* On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages * on PPC44x). For PPC64 we support either 4K or 64K software * page size. When using 64K pages however, whether we are really supporting * 64K pages in HW or not is irrelevant to those definitions. */ -#if defined(CONFIG_PPC_64K_PAGES ) +#if defined(CONFIG_PPC_256K_PAGES ) +#define PAGE_SHIFT 18 +#elif defined(CONFIG_PPC_64K_PAGES )#define PAGE_SHIFT 16#elif defined(CONFIG_PPC_16K_PAGES )#define PAGE_SHIFT 14
arch/powerpc/include/asm/page_32.h +4 -0
@@ -19,7 +19,11 @@#define PTE_FLAGS_OFFSET 0#endif +#ifdef CONFIG_PPC_256K_PAGES +#define PTE_SHIFT (PAGE_SHIFT - PTE_T_LOG2 - 2)/* 1/4 of a page */ +#else #define PTE_SHIFT (PAGE_SHIFT - PTE_T_LOG2)/* full page */ +#endif #ifndef __ASSEMBLY__/*
arch/powerpc/include/asm/thread_info.h +4 -0
@@ -15,8 +15,12 @@#ifdef CONFIG_PPC64 #define THREAD_SHIFT 14#else +#ifdef CONFIG_PPC_256K_PAGES +#define THREAD_SHIFT 15 +#else #define THREAD_SHIFT 13#endif +#endif #define THREAD_SIZE (1 << THREAD_SHIFT)
arch/powerpc/kernel/head_booke.h +9 -1
@@ -10,6 +10,14 @@ mtspr SPRN_IVOR##vector_number,r26; \ sync +#ifndef CONFIG_PPC_256K_PAGES +#define ALLOC_STACK_FRAME (reg, val) addi reg,reg,val +#else +#define ALLOC_STACK_FRAME (reg, val) \ + addis reg,reg,val@ha; \ + addi reg,reg,val@l +#endif +#define NORMAL_EXCEPTION_PROLOG \ mtspr SPRN_SPRG0,r10;/* save two registers to work with */ \mtspr SPRN_SPRG1 ,r11; \
@@ -20,7 +28,7 @@ beq 1f; \mfspr r1,SPRN_SPRG3 ;/* if from user, start at top of */ \ lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ -addi r1,r1,THREAD_SIZE ; \ +ALLOC_STACK_FRAME (r1,THREAD_SIZE ); \ 1: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\mr r11,r1; \stw r10,_CCR (r11 );/* save various registers */ \
init/Kconfig +10 -0
@@ -635,6 +635,16 @@ config ELF_CORE help Enable support for generating core dumps. Disabling saves about 4k. +config STDBINUTILS + bool "Using standard binutils" if EMBEDDED + depends on 44x + default y + help + Turning this option off allows you to select 256KB PAGE_SIZE on 44x. + Note, that kernel will be able to run only those applications, + which had been compiled using the patched binutils (ELF standard + supports only page sizes up to 64K). + config PCSPKR_PLATFORM bool "Enable PC-Speaker support" if EMBEDDED depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP || PPC_PSERIES
Signature · 1 line
1.6.0.4
Quoted 2 lines · Yuri Tikhonov
This patch adds support for 256KB pages on ppc44x-based boards.
Hi. A couple of small comments.
Quoted 14 lines
arch/powerpc/Kconfig +5
-0@@ -436,6 +436,14 @@ config PPC_64K_PAGES bool "64k page size" if 44x || PPC_STD_MMU_64 select PPC_HAS_HASH_64K if PPC_STD_MMU_64 +config PPC_256K_PAGES + bool "256k page size" if 44x + depends on !STDBINUTILS + help + ELF standard supports only page sizes up to 64K so you need apatched
arch/powerpc/Kconfig config PPC_64K_PAGES · line 446
Quoted 3 lines
arch/powerpc/Kconfig +3
-0+ binutils in order to use 256K pages. Chose it only if you know what + you are doing. +
Make the page size 256k. As the ELF standard only requires alignment to
support page sizes up to 64k, you will need to compile all of your user space applications with a patched binutils.
Say N unless you know what you are doing.
(The previous text did not describe what the option actually did, and did not emphasize that all of user space had to be compiled).
Quoted 5 lines
arch/powerpc/include/asm/thread_info.h +0
-0
arch/powerpc/include/asm/thread_info.h line 23
Quoted 9 lines
arch/powerpc/include/asm/thread_info.h +4
-0@@ -15,8 +15,12 @@#ifdef CONFIG_PPC64 #define THREAD_SHIFT 14#else +#ifdef CONFIG_PPC_256K_PAGES +#define THREAD_SHIFT 15 +#else #define THREAD_SHIFT 13#endif +#endif
Switching to #elif would remove the nested ifdef here.
arch/powerpc/kernel/head_booke.h line 13
Quoted 12 lines
arch/powerpc/include/asm/thread_info.h +0
-0#define THREAD_SIZE (1 << THREAD_SHIFT)arch/powerpc/kernel/head_booke.h +1
-0@@ -10,6 +10,14 @@ mtspr SPRN_IVOR##vector_number,r26; \ sync +#ifndef CONFIG_PPC_256K_PAGES
This if should be on THREAD_SIZE or THREAD_SHIFT, not the option that causes it to be large.
Quoted 34 lines
arch/powerpc/kernel/head_booke.h +8
-1+#define ALLOC_STACK_FRAME (reg, val) addi reg,reg,val +#else +#define ALLOC_STACK_FRAME (reg, val) \ + addis reg,reg,val@ha; \ + addi reg,reg,val@l +#endif +#define NORMAL_EXCEPTION_PROLOG \ mtspr SPRN_SPRG0,r10;/* save two registers to work with */ \mtspr SPRN_SPRG1 ,r11; \@@ -20,7 +28,7 @@ beq 1f; \mfspr r1,SPRN_SPRG3 ;/* if from user, start at top of */ \ lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ -addi r1,r1,THREAD_SIZE ; \ +ALLOC_STACK_FRAME (r1,THREAD_SIZE ); \ 1: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\mr r11,r1; \stw r10,_CCR (r11 );/* save various registers */ \init/Kconfig +6
-0@@ -635,6 +635,16 @@ config ELF_CORE help Enable support for generating core dumps. Disabling saves about 4k. +config STDBINUTILS + bool "Using standard binutils" if EMBEDDED + depends on 44x + default y + help + Turning this option off allows you to select 256KB PAGE_SIZE on44x.
init/Kconfig config ELF_CORE · line 647
Quoted 4 lines
init/Kconfig +4
-0+ Note, that kernel will be able to run only those applications, + which had been compiled using the patched binutils (ELF standard + supports only page sizes up to 64K). +
The config variable 44x is pretty nondescript for a global config file.
If you leave it here, I would suggest making it depend on PPC && 44x
so that other people don't have to wonder what 44x means. I didn't look if there was a better place to put this option, somewhere architecture specific might be better (eg after selecting the 44x cpu type).
Quoted 5 lines
config
PCSPKR_PLATFORMinit/Kconfig +0
-0bool "Enable PC-Speaker support" if EMBEDDED depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP ||
PPC_PSERIES
thanks,
milton
=0D=0A Hello Milton,
Thanks for reviewing. I'll re-post the updated patch shortly.
Quoted 15 lines · On Sunday, December 21, 2008 you wrote:
Quoted 2 lines · Yuri Tikhonov
This patch adds support for 256KB pages on ppc44x-based boards.
Hi. A couple of small comments.
Quoted 8 lines
arch/powerpc/Kconfig +0
-0@@ -436,6 +436,14 @@ config PPC_64K_PAGES bool "64k page size" if 44x || PPC_STD_MMU_64 select PPC_HAS_HASH_64K if PPC_STD_MMU_64
Quoted 7 lines
Quoted 7 lines
arch/powerpc/Kconfig +5
-0+config PPC_256K_PAGES + bool "256k page size" if 44x + depends on !STDBINUTILS + help + ELF standard supports only page sizes up to 64K so you need a=20patched
+ binutils in order to use 256K pages. Chose it only if you know w=
hat
Quoted 49 lines
arch/powerpc/Kconfig config PPC_64K_PAGES · line 446
Quoted 2 lines
arch/powerpc/Kconfig +2
-0+ you are doing. +Make the page size 256k. As the ELF standard only requires alignment
to
support page sizes up to 64k, you will need to compile all of your user space applications with a patched binutils.Say N unless you know what you are doing.
(The previous text did not describe what the option actually did, and=20 did not emphasize that all of user space had to be compiled).
Quoted 6 lines
arch/powerpc/include/asm/thread_info.h +0
-0arch/powerpc/include/asm/thread_info.h line 23
Quoted 9 lines
arch/powerpc/include/asm/thread_info.h +4
-0@@ -15,8 +15,12 @@#ifdef CONFIG_PPC64 #define THREAD_SHIFT 14#else +#ifdef CONFIG_PPC_256K_PAGES +#define THREAD_SHIFT 15 +#else #define THREAD_SHIFT 13#endif +#endif Switching to #elif would remove the nested ifdef here.
arch/powerpc/kernel/head_booke.h line 13
Quoted 13 lines
arch/powerpc/include/asm/thread_info.h +0
-0#define THREAD_SIZE (1 << THREAD_SHIFT)arch/powerpc/kernel/head_booke.h +1
-0@@ -10,6 +10,14 @@ mtspr SPRN_IVOR##vector_number,r26; \ sync +#ifndef CONFIG_PPC_256K_PAGES This if should be on
THREAD_SIZEorTHREAD_SHIFT, not the option that=20 causes it to be large.
Quoted 8 lines
arch/powerpc/kernel/head_booke.h
Quoted 8 lines
arch/powerpc/kernel/head_booke.h +7
-0+#define ALLOC_STACK_FRAME (reg, val) addi reg,reg,val +#else +#define ALLOC_STACK_FRAME (reg, val) \ + addis reg,reg,val@ha; \ + addi reg,reg,val@l +#endif +#define NORMAL_EXCEPTION_PROLOG =
\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 22
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0mtspr SPRN_SPRG0 ,r10;/* save two registers to work with=
*/\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 23
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0mtspr SPRN_SPRG1,r11; =
\
Quoted 2 lines
arch/powerpc/kernel/head_booke.h line 28
Quoted 2 lines
arch/powerpc/kernel/head_booke.h +0
-0@@ -20,7 +28,7 @@ beq 1f; =
\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 29
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0mfspr r1,SPRN_SPRG3 ;/* if from user, start at top of =
*/\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 30
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack =
*/\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 23
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-1- addi r1,r1,THREAD_SIZE; =
\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 31
Quoted 1 line
arch/powerpc/kernel/head_booke.h +1
-0+ ALLOC_STACK_FRAME(r1, THREAD_SIZE); =
\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 32
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-01: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame =
*/\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 33
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0mr r11,r1; =
\
Quoted 1 line
arch/powerpc/kernel/head_booke.h line 34
Quoted 1 line
arch/powerpc/kernel/head_booke.h +0
-0stw r10,_CCR (r11 );/* save various registers =
*/\
Quoted 7 lines
init/Kconfig config ELF_CORE · line 636
Quoted 7 lines
init/Kconfig +0
-0@@ -635,6 +635,16 @@ config ELF_CORE help Enable support for generating core dumps. Disabling saves about =
4k.
Quoted 7 lines
init/Kconfig config ELF_CORE
Quoted 7 lines
init/Kconfig +6
-0+config STDBINUTILS + bool "Using standard binutils" if EMBEDDED + depends on 44x + default y + help + Turning this option off allows you to select 256KB PAGE_SIZE on=
=20
Quoted 13 lines
init/Kconfig config ELF_CORE · line 647
Quoted 5 lines
44x.
init/Kconfig +4
-0+ Note, that kernel will be able to run only those applications, + which had been compiled using the patched binutils (ELF standard + supports only page sizes up to 64K). +The config variable 44x is pretty nondescript for a global config file.
If you leave it here, I would suggest making it depend on PPC && 44x
so that other people don't have to wonder what 44x means. I didn't=20 look if there was a better place to put this option, somewhere=20 architecture specific might be better (eg after selecting the 44x cpu=20 type).
Quoted 8 lines
Quoted 5 lines
config
PCSPKR_PLATFORM
bool "Enable PC-Speaker support" if EMBEDDED depends on ALPHA || X86 || MIPS ||PPC_PREP||PPC_CHRP||=20PPC_PSERIESthanks,
milton
Regards, Yuri
--
Yuri Tikhonov, Senior Software Engineer
Emcraft Systems, www.emcraft.com