mm: delete unnecessary and unsafe init_tlb_ubc()
authorHugh Dickins <hughd@google.com>
Sat, 24 Sep 2016 03:27:04 +0000 (20:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 24 Sep 2016 18:20:01 +0000 (11:20 -0700)
commitb385d21f27d86426472f6ae92a231095f7de2a8d
treea8e2a20246c8beaf70a429a1e66f07ad437320af
parent71664665c3e3ca5ff61ef5fc65480f82cd575eb2
mm: delete unnecessary and unsafe init_tlb_ubc()

init_tlb_ubc() looked unnecessary to me: tlb_ubc is statically
initialized with zeroes in the init_task, and copied from parent to
child while it is quiescent in arch_dup_task_struct(); so I went to
delete it.

But inserted temporary debug WARN_ONs in place of init_tlb_ubc() to
check that it was always empty at that point, and found them firing:
because memcg reclaim can recurse into global reclaim (when allocating
biosets for swapout in my case), and arrive back at the init_tlb_ubc()
in shrink_node_memcg().

Resetting tlb_ubc.flush_required at that point is wrong: if the upper
level needs a deferred TLB flush, but the lower level turns out not to,
we miss a TLB flush.  But fortunately, that's the only part of the
protocol that does not nest: with the initialization removed, cpumask
collects bits from upper and lower levels, and flushes TLB when needed.

Fixes: 72b252aed506 ("mm: send one IPI per CPU to TLB flush all entries after unmapping pages")
Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: stable@vger.kernel.org # 4.3+
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/vmscan.c