Commit 4b3b4c5e authored by John Reiser's avatar John Reiser Committed by Steven Rostedt

ftrace: __start_mcount_loc should be .init.rodata

__start_mcount_loc[] is unused after init, yet occupies RAM forever
as part of .rodata.  152kiB is typical on a 64-bit architecture.  Instead,
__start_mcount_loc should be in the interval [__init_begin, __init_end)
so that the space is reclaimed after init.

__start_mcount_loc[] is generated during the load portion
of kernel build, and is used only by ftrace_init().  ftrace_init is declared
'__init' and is in .init.text, which is freed after init.
__start_mcount_loc is placed into .rodata by a call to MCOUNT_REC inside
the RO_DATA macro of include/asm-generic/vmlinux.lds.h.  The array *is*
read-only, but more importantly it is not used after init.  So the call to
MCOUNT_REC should be moved from RO_DATA to INIT_DATA.

This patch has been tested on x86_64 with CONFIG_DEBUG_PAGEALLOC=y
which verifies that the address range never is accessed after init.
Signed-off-by: default avatarJohn Reiser <jreiser@BitWagon.com>
LKML-Reference: <4A6DF0B6.7080402@bitwagon.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent b5130b1e
...@@ -91,7 +91,8 @@ ...@@ -91,7 +91,8 @@
#endif #endif
#ifdef CONFIG_FTRACE_MCOUNT_RECORD #ifdef CONFIG_FTRACE_MCOUNT_RECORD
#define MCOUNT_REC() VMLINUX_SYMBOL(__start_mcount_loc) = .; \ #define MCOUNT_REC() . = ALIGN(8); \
VMLINUX_SYMBOL(__start_mcount_loc) = .; \
*(__mcount_loc) \ *(__mcount_loc) \
VMLINUX_SYMBOL(__stop_mcount_loc) = .; VMLINUX_SYMBOL(__stop_mcount_loc) = .;
#else #else
...@@ -331,7 +332,6 @@ ...@@ -331,7 +332,6 @@
/* __*init sections */ \ /* __*init sections */ \
__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
*(.ref.rodata) \ *(.ref.rodata) \
MCOUNT_REC() \
DEV_KEEP(init.rodata) \ DEV_KEEP(init.rodata) \
DEV_KEEP(exit.rodata) \ DEV_KEEP(exit.rodata) \
CPU_KEEP(init.rodata) \ CPU_KEEP(init.rodata) \
...@@ -455,6 +455,7 @@ ...@@ -455,6 +455,7 @@
MEM_DISCARD(init.data) \ MEM_DISCARD(init.data) \
KERNEL_CTORS() \ KERNEL_CTORS() \
*(.init.rodata) \ *(.init.rodata) \
MCOUNT_REC() \
DEV_DISCARD(init.rodata) \ DEV_DISCARD(init.rodata) \
CPU_DISCARD(init.rodata) \ CPU_DISCARD(init.rodata) \
MEM_DISCARD(init.rodata) MEM_DISCARD(init.rodata)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment