Re: [PATCH v2 4/5] kfence: limit currently covered allocations when pool nearly full

From: Marco Elver
Date: Tue Sep 21 2021 - 07:35:58 EST


On Tue, 21 Sept 2021 at 13:05, Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
[...]
> > +/*
> > + * Adds (or subtracts) count @val for allocation stack trace hash
> > + * @alloc_stack_hash from Counting Bloom filter.
> > + */
> > +static void alloc_covered_add(u32 alloc_stack_hash, int val)
> > +{
> > + int i;
> > +
> > + if (!alloc_stack_hash)
> > + return;
>
> Nice!
> I like the hash seed, non-evicting cache and that threshold become a
> command line parameter.
>
> This check is the only place I don't understand. What's special about
> alloc_stack_hash == 0? I see that even double-free's won't call this
> with 0.

Indeed, it's no longer required (I think it was in a previous version
I played with). At this point, it should only be true if jhash()
returns 0 for something, and in that case might not even want the
check.

I can also remove the unnecessary "meta->alloc_stack_hash = 0;" in
kfence_guarded_free().

Unless I hear otherwise, I'll remove the unneeded code (and send a v3
of this series in a few days).