Re: [PATCH 10/10] mm,sched: conditionally skip lazy TLB mm refcounting

From: Andy Lutomirski
Date: Sun Jul 29 2018 - 00:22:02 EST


On Sat, Jul 28, 2018 at 2:53 PM, Rik van Riel <riel@xxxxxxxxxxx> wrote:
> Conditionally skip lazy TLB mm refcounting. When an architecture has
> CONFIG_ARCH_NO_ACTIVE_MM_REFCOUNTING enabled, an mm that is used in
> lazy TLB mode anywhere will get shot down from exit_mmap, and there
> in no need to incur the cache line bouncing overhead of refcounting
> a lazy TLB mm.

Unless I've misunderstood something, this patch results in idle tasks
whose active_mm has been freed still having active_mm pointing at
freed memory. This isn't strictly speaking a bug, but it's extremely
confusing and risks all kinds of nasty errors. That's why I prefer
the approach of actually removing the active_mm field on x86 rather
than merely removing the refcount.

I realize that this will add more ifdeffery and make the patch a bit
bigger, but I think it'll be much more robust. Not to mention that it
will save a pointer an a refcount per mm_struct, but that barely
matters.