Skip to content

Commit ea71454

Browse files
Jiri OlsaIngo Molnar
authored andcommitted
x86: Separate out entry text section
Put x86 entry code into a separate link section: .entry.text. Separating the entry text section seems to have performance benefits - caused by more efficient instruction cache usage. Running hackbench with perf stat --repeat showed that the change compresses the icache footprint. The icache load miss rate went down by about 15%: before patch: 19417627 L1-icache-load-misses ( +- 0.147% ) after patch: 16490788 L1-icache-load-misses ( +- 0.180% ) The motivation of the patch was to fix a particular kprobes bug that relates to the entry text section, the performance advantage was discovered accidentally. Whole perf output follows: - results for current tip tree: Performance counter stats for './hackbench/hackbench 10' (500 runs): 19417627 L1-icache-load-misses ( +- 0.147% ) 2676914223 instructions # 0.497 IPC ( +- 0.079% ) 5389516026 cycles ( +- 0.144% ) 0.206267711 seconds time elapsed ( +- 0.138% ) - results for current tip tree with the patch applied: Performance counter stats for './hackbench/hackbench 10' (500 runs): 16490788 L1-icache-load-misses ( +- 0.180% ) 2717734941 instructions # 0.502 IPC ( +- 0.079% ) 5414756975 cycles ( +- 0.148% ) 0.206747566 seconds time elapsed ( +- 0.137% ) Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: masami.hiramatsu.pt@hitachi.com Cc: ananth@in.ibm.com Cc: davem@davemloft.net Cc: 2nddept-manager@sdl.hitachi.co.jp LKML-Reference: <20110307181039.GB15197@jolsa.redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 86cb2ec commit ea71454

6 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎arch/x86/ia32/ia32entry.S‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define sysretl_audit ia32_ret_from_sys_call
2626
#endif
2727

28+
.section .entry.text, "ax"
29+
2830
#define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
2931

3032
.macro IA32_ARG_FIXUP noebp=0

‎arch/x86/kernel/entry_32.S‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#define sysexit_audit syscall_exit_work
6666
#endif
6767

68+
.section .entry.text, "ax"
69+
6870
/*
6971
* We use macros for low-level operations which need to be overridden
7072
* for paravirtualization. The following will never clobber any registers:
@@ -788,7 +790,7 @@ ENDPROC(ptregs_clone)
788790
*/
789791
.section .init.rodata,"a"
790792
ENTRY(interrupt)
791-
.text
793+
.section .entry.text, "ax"
792794
.p2align 5
793795
.p2align CONFIG_X86_L1_CACHE_SHIFT
794796
ENTRY(irq_entries_start)
@@ -807,7 +809,7 @@ vector=FIRST_EXTERNAL_VECTOR
807809
.endif
808810
.previous
809811
.long 1b
810-
.text
812+
.section .entry.text, "ax"
811813
vector=vector+1
812814
.endif
813815
.endr

‎arch/x86/kernel/entry_64.S‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#define __AUDIT_ARCH_LE 0x40000000
6262

6363
.code64
64+
.section .entry.text, "ax"
65+
6466
#ifdef CONFIG_FUNCTION_TRACER
6567
#ifdef CONFIG_DYNAMIC_FTRACE
6668
ENTRY(mcount)
@@ -744,7 +746,7 @@ END(stub_rt_sigreturn)
744746
*/
745747
.section .init.rodata,"a"
746748
ENTRY(interrupt)
747-
.text
749+
.section .entry.text
748750
.p2align 5
749751
.p2align CONFIG_X86_L1_CACHE_SHIFT
750752
ENTRY(irq_entries_start)
@@ -763,7 +765,7 @@ vector=FIRST_EXTERNAL_VECTOR
763765
.endif
764766
.previous
765767
.quad 1b
766-
.text
768+
.section .entry.text
767769
vector=vector+1
768770
.endif
769771
.endr

‎arch/x86/kernel/vmlinux.lds.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ SECTIONS
105105
SCHED_TEXT
106106
LOCK_TEXT
107107
KPROBES_TEXT
108+
ENTRY_TEXT
108109
IRQENTRY_TEXT
109110
*(.fixup)
110111
*(.gnu.warning)

‎include/asm-generic/sections.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extern char _sinittext[], _einittext[];
1111
extern char _end[];
1212
extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
1313
extern char __kprobes_text_start[], __kprobes_text_end[];
14+
extern char __entry_text_start[], __entry_text_end[];
1415
extern char __initdata_begin[], __initdata_end[];
1516
extern char __start_rodata[], __end_rodata[];
1617

‎include/asm-generic/vmlinux.lds.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@
424424
*(.kprobes.text) \
425425
VMLINUX_SYMBOL(__kprobes_text_end) = .;
426426

427+
#define ENTRY_TEXT \
428+
ALIGN_FUNCTION(); \
429+
VMLINUX_SYMBOL(__entry_text_start) = .; \
430+
*(.entry.text) \
431+
VMLINUX_SYMBOL(__entry_text_end) = .;
432+
427433
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
428434
#define IRQENTRY_TEXT \
429435
ALIGN_FUNCTION(); \

0 commit comments

Comments
 (0)