On Tue, Jan 06, 2026 at 07:52:41PM -0500, Steven Rostedt wrote:
> On Tue, 6 Jan 2026 16:24:28 -0800
> Guenter Roeck <[email protected]> wrote:
>
> > if (pg_unuse) {
> > - 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;
> > -
>
> The above needs to be fixed though.
Yes, and
skip = DIV_ROUND_UP(skip, ENTRIES_PER_PAGE);
is also wrong. That means
WARN(skip != remaining, "Extra allocated pages for ftrace: %lu with %lu
skipped",
remaining, skipped);
will be hit because because 'skip' may be inaccurate. Example with added
debug log:
ftrace: skipped: 654 pg_remaining: 313 skip: 341 (3) pages: 310 remaining: 2
------------[ cut here ]------------
Extra allocated pages for ftrace: 2 with 654 skipped
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:7299
ftrace_process_locs+0x5a8/0x5c0
...
ftrace: allocating 52250 entries in 308 pages
ftrace: allocated 308 pages with 4 groups
The warning is seen because the number of pages needed for 341 entries is
mis-calculated as 3 instead of 2.
That means I'll need the added code from v1 to calculate the correct value
for the number of pages needed, at least if you want to keep the validation
code with the warning backtraces.
Thanks,
Guenter