[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260106203352.539b9548@gandalf.local.home>
Date: Tue, 6 Jan 2026 20:33:52 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Guenter Roeck <linux@...ck-us.net>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, Mark Rutland
<mark.rutland@....com>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v2] ftrace: Do not over-allocate ftrace memory
On Tue, 6 Jan 2026 16:54:27 -0800
Guenter Roeck <linux@...ck-us.net> wrote:
> > Don't remove this block. It's still needed. A lot of entries are
> > skipped when adding the records. Weak functions and zero'd pointers
> > that were part of the count are skipped. This is the code that handles
> > that. It has nothing to do with rounding errors.
> >
> Sorry, misunderstanding. I thought that is what you meant with "This will
> make pages equal the number of pages that were allocated. Then I'm not sure
> we need this extra logic."
>
> What is the no longer needed extra logic ?
I meant the added logic you had there, as I was a bit confused by the
"spaces" part.
The logic still needs to be updated, but I think it can be done with the
following:
if (pg_unuse) {
unsigned long pg_remaining, remaining = 0;
long skip;
/* Count the number of entries unused and compare it to skipped. */
pg_remaining = (PAGE_SIZE << pg->order) / ENTRIES_SIZE - pg->index;
if (!WARN(skipped < pg_remaining, "Extra allocated pages for ftrace")) {
skip = skipped - pg_remaining;
for (pg = pg_unuse; pg && skip > 0; pg = pg->next) {
remaining += 1 << pg->order;
skip -= (PAGE_SIZE << pg->order) / ENTRIES_SIZE;
}
pages -= remaining;
/*
* Check to see if the number of pages remaining would
* just fit the number of entries skipped.
*/
WARN(pg || skip > 0, "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);
}
-- Steve
Powered by blists - more mailing lists