mm: use_mm: fix for arches checking mm_users to optimize TLB flushes
alpha, ia64, mips, powerpc, sh, sparc are relying on a check on
mm->mm_users to know if they can skip some remote TLB flushes for
single threaded processes.
Most callers of kthread_use_mm() tend to invoke mmget_not_zero() or
get_task_mm() before kthread_use_mm() to ensure the mm will remain
alive in between kthread_use_mm() and kthread_unuse_mm().
Some callers however don't increase mm_users and they instead rely on
serialization in __mmput() to ensure the mm will remain alive in
between kthread_use_mm() and kthread_unuse_mm(). Not increasing
mm_users during kthread_use_mm() is however unsafe for aforementioned
arch TLB flushes optimizations. So either mmget()/mmput() should be
added to the problematic callers of
kthread_use_mm()/kthread_unuse_mm() or we can embed them in
kthread_use_mm()/kthread_unuse_mm() which is more robust.
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
1 file changed