On Sat, Apr 12, 2025 at 10:45 PM Steven Rostedt <[email protected]> wrote:
>
> On Sat, 12 Apr 2025 22:36:56 +0800
> Menglong Dong <[email protected]> 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

Reply via email to