[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250729115839.1002232-1-dmantipov@yandex.ru>
Date: Tue, 29 Jul 2025 14:58:39 +0300
From: Dmitry Antipov <dmantipov@...dex.ru>
To: Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org,
Dmitry Antipov <dmantipov@...dex.ru>
Subject: [PATCH] objtool: speedup detection of noreturn functions
Running over KASAN-enabled vmlinux.o, some functions comes from the
sanitizer runtime may be processed by 'dead_end_function()' a lot of
times, so it's reasonable to record the result in 'struct symbol' of
the relevant function. Briefly testing over huge 'make allyesconfig'
result, this may speedup objtool by nearly 10%.
Signed-off-by: Dmitry Antipov <dmantipov@...dex.ru>
---
tools/objtool/check.c | 22 ++++++++++++++++++----
tools/objtool/include/objtool/elf.h | 1 +
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index d14f20ef1db1..21997f1846d8 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -236,6 +236,9 @@ static bool is_rust_noreturn(const struct symbol *func)
str_ends_with(func->name, "_fail"));
}
+static bool dead_end_function(struct objtool_file *file, struct symbol *func,
+ int recursion);
+
/*
* This checks to see if the given function is a "noreturn" function.
*
@@ -313,16 +316,27 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
return false;
}
- return __dead_end_function(file, insn_func(dest), recursion+1);
+ return dead_end_function(file, insn_func(dest),
+ recursion + 1);
}
}
return true;
}
-static bool dead_end_function(struct objtool_file *file, struct symbol *func)
+static bool dead_end_function(struct objtool_file *file, struct symbol *func,
+ int recursion)
{
- return __dead_end_function(file, func, 0);
+ /*
+ * Some functions (e.g. comes from the sanitizer runtimes, like
+ * __sanitizer_cov_trace_pc() or __asan_report_loadN_noabort(),
+ * may be examined a lot of times, so it's reasonable to record
+ * the result.
+ */
+ if (func->functype == UNKNOWN)
+ func->functype = (__dead_end_function(file, func, recursion)
+ ? NORETURN : REGULAR);
+ return func->functype == NORETURN;
}
static void init_cfi_state(struct cfi_state *cfi)
@@ -1359,7 +1373,7 @@ static int annotate_call_site(struct objtool_file *file,
!insn->_call_dest->embedded_insn)
list_add_tail(&insn->call_node, &file->call_list);
- if (!sibling && dead_end_function(file, sym))
+ if (!sibling && dead_end_function(file, sym, 0))
insn->dead_end = true;
return 0;
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 0a2fa3ac0079..ebf930e42736 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -65,6 +65,7 @@ struct symbol {
u8 return_thunk : 1;
u8 fentry : 1;
u8 profiling_func : 1;
+ enum { UNKNOWN, REGULAR, NORETURN } functype : 2;
u8 warned : 1;
u8 embedded_insn : 1;
u8 local_label : 1;
--
2.50.1
Powered by blists - more mailing lists