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

Commit 1867ddb7 authored by Sami Tolvanen's avatar Sami Tolvanen Committed by Alistair Strachan
Browse files

FROMLIST: 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 cee5051d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -497,7 +497,7 @@ config LTO_NONE
config LTO_CLANG
	bool "Use clang Link Time Optimization (LTO) (EXPERIMENTAL)"
	depends on ARCH_SUPPORTS_LTO_CLANG
	depends on !FTRACE_MCOUNT_RECORD
	depends on !FTRACE_MCOUNT_RECORD || HAVE_C_RECORDMCOUNT
	depends on CC_IS_CLANG && LD_IS_LLD
	select LTO
	help
+1 −0
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@
		ALIGN_FUNCTION();					\
		*(.text.hot TEXT_MAIN .text.fixup .text.unlikely)	\
		*(.text..refcount)					\
		*(.text..ftrace)					\
		*(.ref.text)						\
	MEM_KEEP(init.text*)						\
	MEM_KEEP(exit.text*)						\
+7 −0
Original line number Diff line number Diff line
@@ -43,3 +43,10 @@
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
#define __assume_aligned(a, ...)	\
	__attribute__((__assume_aligned__(a, ## __VA_ARGS__)))

#ifdef CONFIG_LTO_CLANG
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
#define __norecordmcount \
	__attribute__((__section__(".text..ftrace")))
#endif
#endif
+4 −0
Original line number Diff line number Diff line
@@ -248,6 +248,10 @@ struct ftrace_likely_data {
# define __gnu_inline
#endif

#ifndef __norecordmcount
#define __norecordmcount
#endif

/*
 * Force always-inline if the user requests it so via the .config.
 * GCC does not warn about unused static inline functions for
+3 −3
Original line number Diff line number Diff line
@@ -5500,7 +5500,7 @@ static int ftrace_cmp_ips(const void *a, const void *b)
	return 0;
}

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