On Thu, Sep 24, 2020 at 01:19:07PM +0200, Peter Zijlstra wrote:
> On Thu, Sep 24, 2020 at 10:16:14AM +0200, Uladzislau Rezki wrote:
> > The key point is "enough". We need pages to make a) fast progress b) support
> > single argument of kvfree_rcu(one_arg). Not vice versa. That "enough"
> > depends
> > on scheduler latency and vague pre-allocated number of pages, it might
> > be not enough what would require to refill it more and more or we can
> > overshoot
> > that would lead to memory overhead. So we have here timing issues and
> > not accurate model. IMHO.
>
> I'm firmly opposed to the single argument kvfree_rcu() idea, that's
> requiring memory to free memory.
Not quite.
First, there is a fallback when memory allocation fails. Second,
in heavy-use situations, there is only one allocation per about
500 kvfree_rcu() calls on 64-bit systems. Third, there are other
long-standing situations that require allocating memory in order to
free memory.
So I agree that it is a good general rule of thumb to avoid allocating
on free paths, but there are exceptions. This is one of them.
Thanx, Paul