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] ftrace: Do not over-allocate ftrace memory
Date: Tue, 6 Jan 2026 15:05:25 -0800	[thread overview]
Message-ID: <0a9cd12e-6db8-4b41-979e-95f06e9390f6@roeck-us.net> (raw)
In-Reply-To: <dc80ae8e-54f6-45f0-bf2f-69012c3b47aa@roeck-us.net>

On Tue, Jan 06, 2026 at 02:26:23PM -0800, Guenter Roeck wrote:
> > >  
> > >  			pages -= remaining;
> > 
> > I think pages is meaningless here, as it was set in the beginning with:
> > 
> > 	pages = DIV_ROUND_UP(count, ENTRIES_PER_PAGE);
> > 
> > Which is incorrect. I wonder if we should set it via:
> > 
> I know, I just didn't want to make more changes than absolutely
> necessary.
> 
> > 	/*
> > 	 * Use ftrace_number_of_pages to determine how many pages were
> > 	 * allocated
> > 	 */
> > 	pages = ftrace_number_of_pages;
> > 
> > 	start_pg = ftrace_allocate_pages(count);
> > 	if (!start_pg)
> > 		return -ENOMEM;
> > 
> > 	/* ftrace_allocate_pages() increments ftrace_number_of_pages */
> > 	pages = ftrace_number_of_pages - pages;
> > 
> 
> That might work, assuming that the code updating ftrace_number_of_pages
> is (mutex) protected. I don't immediately see that, and the
> "mutex_lock(&ftrace_lock);" right after the above code makes me a bit
> concerned.
> 

One way to avoid the locking problem without potentially risky code changes
would be to pass a pointer to pages to ftrace_allocate_pages() and to
ftrace_allocate_records(), and to update it from there. I tested that and
confirmed that it works.

Guenter

  reply	other threads:[~2026-01-06 23:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06 20:35 Guenter Roeck
2026-01-06 21:18 ` Steven Rostedt
2026-01-06 22:26   ` Guenter Roeck
2026-01-06 23:05     ` Guenter Roeck [this message]
2026-01-06 23:38       ` Steven Rostedt
2026-01-06 23:48         ` Guenter Roeck

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=0a9cd12e-6db8-4b41-979e-95f06e9390f6@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®