mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux trace kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: Re: [PATCH] fgraph: Allocate ret_stack_list with proper size
Date: Mon, 21 Oct 2024 16:43:36 +0900	[thread overview]
Message-ID: <20241021164336.79a90af16419aa6e3f065bf3@kernel.org> (raw)
In-Reply-To: <20241018215212.23f13f40@rorschach>

On Fri, 18 Oct 2024 21:52:12 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <rostedt@goodmis.org>
> 
> The ret_stack_list is an array of ret_stack shadow stacks for the function
> graph usage. When the first function graph is enabled, all tasks in the
> system get a shadow stack. The ret_stack_list is a 32 element array of
> pointers to these shadow stacks. It allocates the shadow stack in batches
> (32 stacks at a time), assigns them to running tasks, and continues until
> all tasks are covered.
> 
> When the function graph shadow stack changed from an array of
> ftrace_ret_stack structures to an array of longs, the allocation of
> ret_stack_list went from allocating an array of 32 elements to just a
> block defined by SHADOW_STACK_SIZE. Luckily, that's defined as PAGE_SIZE
> and is much more than enough to hold 32 pointers. But it is way overkill
> for the amount needed to allocate.
> 
> Change the allocation of ret_stack_list back to a kcalloc() of
> FTRACE_RETSTACK_ALLOC_SIZE pointers.

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks,

> 
> Fixes: 42675b723b484 ("function_graph: Convert ret_stack to a series of longs")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  kernel/trace/fgraph.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> index 43f4e3f57438..41e7a15dcb50 100644
> --- a/kernel/trace/fgraph.c
> +++ b/kernel/trace/fgraph.c
> @@ -1162,7 +1162,8 @@ static int start_graph_tracing(void)
>  	unsigned long **ret_stack_list;
>  	int ret;
>  
> -	ret_stack_list = kmalloc(SHADOW_STACK_SIZE, GFP_KERNEL);
> +	ret_stack_list = kcalloc(FTRACE_RETSTACK_ALLOC_SIZE,
> +				 sizeof(*ret_stack_list), GFP_KERNEL);
>  
>  	if (!ret_stack_list)
>  		return -ENOMEM;
> -- 
> 2.45.2
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

      reply	other threads:[~2024-10-21  7:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19  1:52 Steven Rostedt
2024-10-21  7:43 ` Masami Hiramatsu [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=20241021164336.79a90af16419aa6e3f065bf3@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --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®