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:45:18 -0400 [thread overview]
Message-ID: <20250412104518.2b4598d3@batman.local.home> (raw)
In-Reply-To: <CADxym3bAXpqC3awWBTm+zc4Wn348=7cYVCN_+em=b5qPimUTYQ@mail.gmail.com>
On Sat, 12 Apr 2025 22:36:56 +0800
Menglong Dong <menglong8.dong@gmail.com> wrote:
> > Yeah, this seems to make more sense. And I'll send a V2
> > later.
> >
> > BTW, Should we still keep the "size = min(size, 32)" logic
>
> Oops, I mean "size = max(size, 32); size = fls(size);" here :/
>
> > to avoid the hash bits being too small, just like the origin
> > logic in "dup_hash"?
> >
If you have 5 functions, why do you need more that 5 buckets?
size = 5;
size = max(5, 32); // size = 32
size = fls(size); // size = 5
alloc_ftrace_hash(size);
size = 1 << size; // size = 32
hash->buckets = kcalloc(size, ...);
Now you have 32 buckets for 5 functions. Why waste the memory?
If you add more functions, the hash bucket size will get updated.
-- Steve
next prev parent reply other threads:[~2025-04-12 14:45 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
2025-04-12 14:32 ` Menglong Dong
2025-04-12 14:36 ` Menglong Dong
2025-04-12 14:45 ` Steven Rostedt [this message]
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=20250412104518.2b4598d3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.