linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Menglong Dong <menglong8.dong@gmail.com>
Cc: mhiramat@kernel.org, mark.rutland@arm.com,
	mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org,
	Menglong Dong <dongml2@chinatelecom.cn>
Subject: Re: [PATCH bpf] ftrace: fix incorrect hash size in register_ftrace_direct()
Date: Sat, 12 Apr 2025 10:09:39 -0400	[thread overview]
Message-ID: <20250412100939.7f8dbbb7@batman.local.home> (raw)
In-Reply-To: <20250412133348.92718-1-dongml2@chinatelecom.cn>

On Sat, 12 Apr 2025 21:33:48 +0800
Menglong Dong <menglong8.dong@gmail.com> wrote:

> The max ftrace hash bits is made fls(32) in register_ftrace_direct(),
> which seems illogical, and it seems to be a spelling mistake.
> 
> Just fix it.
> 
> (Do I misunderstand something?)

I think the logic is incorrect and this patch doesn't fix it.

> 
> Fixes: d05cb470663a ("ftrace: Fix modification of direct_function hash while in use")
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> ---
>  kernel/trace/ftrace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 1a48aedb5255..7697605a41e6 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5914,7 +5914,7 @@ int register_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
>  
>  	/* Make a copy hash to place the new and the old entries in */
>  	size = hash->count + direct_functions->count;
> -	if (size > 32)
> +	if (size < 32)
>  		size = 32;
>  	new_hash = alloc_ftrace_hash(fls(size));
>  	if (!new_hash)

The above probably should be:

	size = hash->count + direct_functions->count
	size = fls(size);
	if (size > FTRACE_HASH_MAX_BITS)
                size = FTRACE_HASH_MAX_BITS;
	new_hash = alloc_ftrace_hash(size);

-- Steve



  reply	other threads:[~2025-04-12 14:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-12 13:33 [PATCH bpf] ftrace: fix incorrect hash size in register_ftrace_direct() Menglong Dong
2025-04-12 14:09 ` Steven Rostedt [this message]
2025-04-12 14:32   ` Menglong Dong
2025-04-12 14:36     ` Menglong Dong
2025-04-12 14:45       ` Steven Rostedt
2025-04-13  1:32         ` Menglong Dong

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=20250412100939.7f8dbbb7@batman.local.home \
    --to=rostedt@goodmis.org \
    --cc=bpf@vger.kernel.org \
    --cc=dongml2@chinatelecom.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=menglong8.dong@gmail.com \
    --cc=mhiramat@kernel.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;
as well as URLs for NNTP newsgroup(s).