Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bd125e5 authored by Sami Tolvanen's avatar Sami Tolvanen
Browse files

FROMLIST: BACKPORT: kbuild: fix dynamic ftrace with clang LTO

With CONFIG_LTO_CLANG enabled, LLVM IR won't be compiled into object
files until modpost_link. This change postpones calls to recordmcount
until after this step.

In order to exclude ftrace_process_locs from inspection, we add a new
code section .text..ftrace, which we tell recordmcount to ignore, and
a __norecordmcount attribute for moving functions to this section.

Bug: 62093296
Bug: 67506682
Change-Id: Iba2c053968206acf533fadab1eb34a743b5088ee
(am from https://patchwork.kernel.org/patch/10060327/

)
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 475bdd7d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -503,7 +503,7 @@ config ARCH_SUPPORTS_LTO_CLANG
config LTO_CLANG
config LTO_CLANG
	bool "Use clang Link Time Optimization (LTO) (EXPERIMENTAL)"
	bool "Use clang Link Time Optimization (LTO) (EXPERIMENTAL)"
	depends on ARCH_SUPPORTS_LTO_CLANG
	depends on ARCH_SUPPORTS_LTO_CLANG
	depends on !FTRACE_MCOUNT_RECORD
	depends on !FTRACE_MCOUNT_RECORD || HAVE_C_RECORDMCOUNT
	select LTO
	select LTO
	select THIN_ARCHIVES
	select THIN_ARCHIVES
	select LD_DEAD_CODE_DATA_ELIMINATION
	select LD_DEAD_CODE_DATA_ELIMINATION
+1 −0
Original line number Original line Diff line number Diff line
@@ -460,6 +460,7 @@
#define TEXT_TEXT							\
#define TEXT_TEXT							\
		ALIGN_FUNCTION();					\
		ALIGN_FUNCTION();					\
		*(.text.hot TEXT_MAIN .text.fixup .text.unlikely)	\
		*(.text.hot TEXT_MAIN .text.fixup .text.unlikely)	\
		*(.text..ftrace)					\
		*(.ref.text)						\
		*(.ref.text)						\
	MEM_KEEP(init.text)						\
	MEM_KEEP(init.text)						\
	MEM_KEEP(exit.text)						\
	MEM_KEEP(exit.text)						\
+7 −0
Original line number Original line Diff line number Diff line
@@ -15,3 +15,10 @@
 * with any version that can compile the kernel
 * with any version that can compile the kernel
 */
 */
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

#ifdef CONFIG_LTO_CLANG
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
#define __norecordmcount \
	__attribute__((__section__(".text..ftrace")))
#endif
#endif
+4 −0
Original line number Original line Diff line number Diff line
@@ -451,6 +451,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
#define __visible
#define __visible
#endif
#endif


#ifndef __norecordmcount
#define __norecordmcount
#endif

/*
/*
 * Assume alignment of return value.
 * Assume alignment of return value.
 */
 */
+3 −3
Original line number Original line Diff line number Diff line
@@ -4874,7 +4874,7 @@ static int ftrace_cmp_ips(const void *a, const void *b)
	return 0;
	return 0;
}
}


static int ftrace_process_locs(struct module *mod,
static int __norecordmcount ftrace_process_locs(struct module *mod,
						unsigned long *start,
						unsigned long *start,
						unsigned long *end)
						unsigned long *end)
{
{
Loading