Skip to content

Commit 4a3efc6

Browse files
committed
ftrace: Update the mcount_loc check of skipped entries
Now that weak functions turn into skipped entries, update the check to make sure the amount that was allocated would fit both the entries that were allocated as well as those that were skipped. Cc: bpf <bpf@vger.kernel.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nicolas Schier <nicolas@fjasle.eu> Cc: Zheng Yejian <zhengyejian1@huawei.com> Cc: Martin Kelly <martin.kelly@crowdstrike.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Link: https://lore.kernel.org/20250218200023.055162048@goodmis.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent ef378c3 commit 4a3efc6

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

kernel/trace/ftrace.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7111,7 +7111,28 @@ static int ftrace_process_locs(struct module *mod,
71117111

71127112
/* We should have used all pages unless we skipped some */
71137113
if (pg_unuse) {
7114-
WARN_ON(!skipped);
7114+
unsigned long pg_remaining, remaining = 0;
7115+
unsigned long skip;
7116+
7117+
/* Count the number of entries unused and compare it to skipped. */
7118+
pg_remaining = (ENTRIES_PER_PAGE << pg->order) - pg->index;
7119+
7120+
if (!WARN(skipped < pg_remaining, "Extra allocated pages for ftrace")) {
7121+
7122+
skip = skipped - pg_remaining;
7123+
7124+
for (pg = pg_unuse; pg; pg = pg->next)
7125+
remaining += 1 << pg->order;
7126+
7127+
skip = DIV_ROUND_UP(skip, ENTRIES_PER_PAGE);
7128+
7129+
/*
7130+
* Check to see if the number of pages remaining would
7131+
* just fit the number of entries skipped.
7132+
*/
7133+
WARN(skip != remaining, "Extra allocated pages for ftrace: %lu with %lu skipped",
7134+
remaining, skipped);
7135+
}
71157136
/* Need to synchronize with ftrace_location_range() */
71167137
synchronize_rcu();
71177138
ftrace_free_pages(pg_unuse);

0 commit comments

Comments
 (0)