[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADxym3Zzqw3SNP8Ef7pvTJLzOvt+PUvKguaAB2qRiaWM3GN8aQ@mail.gmail.com>
Date: Sun, 13 Apr 2025 09:32:01 +0800
From: Menglong Dong <menglong8.dong@...il.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: mhiramat@...nel.org, mark.rutland@....com, mathieu.desnoyers@...icios.com,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
bpf@...r.kernel.org, Menglong Dong <dongml2@...natelecom.cn>
Subject: Re: [PATCH bpf] ftrace: fix incorrect hash size in register_ftrace_direct()
On Sat, Apr 12, 2025 at 10:45 PM Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Sat, 12 Apr 2025 22:36:56 +0800
> Menglong Dong <menglong8.dong@...il.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.
Yeah, I see. The hash bucket will be reallocated when we
add more functions to the direct_funtions, so it is not
necessary to make the budget size large here.
Thanks!
Menglong Dong
>
> -- Steve
Powered by blists - more mailing lists