Skip to content

Commit b9af7c0

Browse files
Suresh SiddhaH. Peter Anvin
authored andcommitted
x86-64: preserve large page mapping for 1st 2MB kernel txt with CONFIG_DEBUG_RODATA
In the first 2MB, kernel text is co-located with kernel static page tables setup by head_64.S. CONFIG_DEBUG_RODATA chops this 2MB large page mapping to small 4KB pages as we mark the kernel text as RO, leaving the static page tables as RW. With CONFIG_DEBUG_RODATA disabled, OLTP run on NHM-EP shows 1% improvement with 2% reduction in system time and 1% improvement in iowait idle time. To recover this, move the kernel static page tables to .data section, so that we don't have to break the first 2MB of kernel text to small pages with CONFIG_DEBUG_RODATA. Signed-off-by: Suresh Siddha <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent adc1938 commit b9af7c0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

arch/x86/kernel/head_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ ENTRY(secondary_startup_64)
262262
.quad x86_64_start_kernel
263263
ENTRY(initial_gs)
264264
.quad INIT_PER_CPU_VAR(irq_stack_union)
265-
__FINITDATA
266265

267266
ENTRY(stack_start)
268267
.quad init_thread_union+THREAD_SIZE-8
269268
.word 0
269+
__FINITDATA
270270

271271
bad_address:
272272
jmp bad_address
@@ -340,6 +340,7 @@ ENTRY(name)
340340
i = i + 1 ; \
341341
.endr
342342

343+
.data
343344
/*
344345
* This default setting generates an ident mapping at address 0x100000
345346
* and a mapping for the kernel that precisely maps virtual address

arch/x86/mm/init_64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static int kernel_set_to_readonly;
699699

700700
void set_kernel_text_rw(void)
701701
{
702-
unsigned long start = PFN_ALIGN(_stext);
702+
unsigned long start = PFN_ALIGN(_text);
703703
unsigned long end = PFN_ALIGN(__start_rodata);
704704

705705
if (!kernel_set_to_readonly)
@@ -713,7 +713,7 @@ void set_kernel_text_rw(void)
713713

714714
void set_kernel_text_ro(void)
715715
{
716-
unsigned long start = PFN_ALIGN(_stext);
716+
unsigned long start = PFN_ALIGN(_text);
717717
unsigned long end = PFN_ALIGN(__start_rodata);
718718

719719
if (!kernel_set_to_readonly)
@@ -727,7 +727,7 @@ void set_kernel_text_ro(void)
727727

728728
void mark_rodata_ro(void)
729729
{
730-
unsigned long start = PFN_ALIGN(_stext), end = PFN_ALIGN(__end_rodata);
730+
unsigned long start = PFN_ALIGN(_text), end = PFN_ALIGN(__end_rodata);
731731
unsigned long rodata_start =
732732
((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
733733

0 commit comments

Comments
 (0)