Re: [PATCH v2 11/11] mm,sched: conditionally skip lazy TLB mm refcounting
From: Rik van Riel
Date: Mon Jul 30 2018 - 21:06:14 EST
On Mon, 2018-07-30 at 18:26 +0200, Peter Zijlstra wrote:
>
> So for ARCH_NO_ACTIVE_MM we never touch ->active_mm and therefore
> ->active_mm == ->mm.
Close, but not true for kernel threads, which have a
NULL ->mm, but a non-null ->active_mm that gets passed
to enter_lazy_tlb().
I stuck to the structure of your code, but ended up
removing all the ifdefs because the final mmdrop requires
that we actually keep track of the ->active_mm across
potentially several kernel->kernel context switches.
Ifdefs around the reference counting code are also not
needed, because grab_lazy_mm and drop_lazy_mm already
contain the equivalent of an ifdef themselves.
By morning I should know what the test results look
like. I expect they will be identical to my patches,
since the refcounting is disabled completely anyway :)
> > + /*
> > + * kernel -> kernel lazy + transfer active
> > + * user -> kernel lazy + mmgrab() active
> > + *
> > + * kernel -> user switch + mmdrop() active
> > + * user -> user switch
> > + */
> > + if (!next->mm) { // to
> > kernel
> > + enter_lazy_tlb(prev->active_mm, next);
> > +
>
> #ifndef ARCH_NO_ACTIVE_MM
> > + next->active_mm = prev->active_mm;
> > + if (prev->mm) // from
> > user
> > + mmgrab(prev->active_mm);
>
> else
> prev->active_mm = NULL;
> > +#endif
> > + } else { // to user
> > + switch_mm_irqs_off(prev->active_mm, next->mm,
> > next);
> > +
>
> #ifndef ARCH_NO_ACTIVE_MM
> > + if (!prev->mm) { // from
> > kernel
> > + /* will mmdrop() in finish_task_switch().
> > */
> > + rq->prev_mm = prev->active_mm;
> > + prev->active_mm = NULL;
> > + }
> > +#endif
>
>
--
All Rights Reversed.Attachment:
signature.asc
Description: This is a digitally signed message part