mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ftrace: Do not over-allocate ftrace memory
Date: Tue, 6 Jan 2026 17:47:22 -0800	[thread overview]
Message-ID: <6909622a-7d96-41ff-aee1-d3b216033cfe@roeck-us.net> (raw)
In-Reply-To: <20260106195241.166f4115@fedora>

On Tue, Jan 06, 2026 at 07:52:41PM -0500, Steven Rostedt wrote:
> On Tue,  6 Jan 2026 16:24:28 -0800
> Guenter Roeck <linux@roeck-us.net> 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

      reply	other threads:[~2026-01-07  1:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  0:24 Guenter Roeck
2026-01-07  0:43 ` Steven Rostedt
2026-01-07  0:54   ` Guenter Roeck
2026-01-07  1:33     ` Steven Rostedt
2026-01-07  1:56       ` Guenter Roeck
2026-01-07  0:52 ` Steven Rostedt
2026-01-07  1:47   ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6909622a-7d96-41ff-aee1-d3b216033cfe@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®