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 <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Zheng Yejian <[email protected]>
Cc: Martin  Kelly <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Steven Rostedt (Google) <[email protected]>
This commit is contained in:
Steven Rostedt authored and Steven Rostedt (Google) committed 2025-02-18 17:12:03 -05:00
1 parent ef378c3b82
commit 4a3efc6baf
1 file changed
+22 -1
+22 -1
View File
@@ -7111,7 +7111,28 @@ static int ftrace_process_locs(struct module *mod,
/* We should have used all pages unless we skipped some */
if (pg_unuse) {
WARN_ON(!skipped);
unsigned long pg_remaining, remaining = 0;
unsigned long skip;
/* Count the number of entries unused and compare it to skipped. */
pg_remaining = (ENTRIES_PER_PAGE << pg->order) - pg->index;
if (!WARN(skipped < pg_remaining, "Extra allocated pages for ftrace")) {
skip = skipped - pg_remaining;
for (pg = pg_unuse; pg; pg = pg->next)
remaining += 1 << pg->order;
skip = DIV_ROUND_UP(skip, ENTRIES_PER_PAGE);
/*
* Check to see if the number of pages remaining would
* just fit the number of entries skipped.
*/
WARN(skip != remaining, "Extra allocated pages for ftrace: %lu with %lu skipped",
remaining, skipped);
}
/* Need to synchronize with ftrace_location_range() */
synchronize_rcu();
ftrace_free_pages(pg_unuse);