[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0a9cd12e-6db8-4b41-979e-95f06e9390f6@roeck-us.net>
Date: Tue, 6 Jan 2026 15:05:25 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Steven Rostedt <rostedt@...dmis.org>
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] ftrace: Do not over-allocate ftrace memory
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
Powered by blists - more mailing lists