Re: [PATCH 1/3] kfence: await for allocation using wait_event

From: Marco Elver
Date: Mon Apr 19 2021 - 05:44:27 EST


On Mon, 19 Apr 2021 at 11:41, Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Mon, 19 Apr 2021 10:50:25 Marco Elver wrote:
> > +
> > + WRITE_ONCE(kfence_timer_waiting, true);
> > + smp_mb(); /* See comment in __kfence_alloc(). */
>
> This is not needed given task state change in wait_event().

Yes it is. We want to avoid the unconditional irq_work in
__kfence_alloc(). When the system is under load doing frequent
allocations, at least in my tests this avoids the irq_work almost
always. Without the irq_work you'd be correct of course.

> > + wait_event_timeout(allocation_wait, atomic_read(&kfence_allocation_gate), HZ);
> > + smp_store_release(&kfence_timer_waiting, false); /* Order after wait_event(). */
> > +