linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: delete unnecessary and unsafe init_tlb_ubc()
@ 2016-09-22 17:41 Hugh Dickins
  2016-09-23  8:47 ` Mel Gorman
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2016-09-22 17:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, linux-kernel, linux-mm

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>
Cc: stable@vger.kernel.org # 4.3+
---

 mm/vmscan.c |   19 -------------------
 1 file changed, 19 deletions(-)

--- 4.8-rc7/mm/vmscan.c	2016-09-05 16:42:52.496692429 -0700
+++ linux/mm/vmscan.c	2016-09-22 09:32:37.900894833 -0700
@@ -2303,23 +2303,6 @@ out:
 	}
 }
 
-#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
-static void init_tlb_ubc(void)
-{
-	/*
-	 * This deliberately does not clear the cpumask as it's expensive
-	 * and unnecessary. If there happens to be data in there then the
-	 * first SWAP_CLUSTER_MAX pages will send an unnecessary IPI and
-	 * then will be cleared.
-	 */
-	current->tlb_ubc.flush_required = false;
-}
-#else
-static inline void init_tlb_ubc(void)
-{
-}
-#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
-
 /*
  * This is a basic per-node page freer.  Used by both kswapd and direct reclaim.
  */
@@ -2355,8 +2338,6 @@ static void shrink_node_memcg(struct pgl
 	scan_adjusted = (global_reclaim(sc) && !current_is_kswapd() &&
 			 sc->priority == DEF_PRIORITY);
 
-	init_tlb_ubc();
-
 	blk_start_plug(&plug);
 	while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
 					nr[LRU_INACTIVE_FILE]) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: delete unnecessary and unsafe init_tlb_ubc()
  2016-09-22 17:41 [PATCH] mm: delete unnecessary and unsafe init_tlb_ubc() Hugh Dickins
@ 2016-09-23  8:47 ` Mel Gorman
  0 siblings, 0 replies; 2+ messages in thread
From: Mel Gorman @ 2016-09-23  8:47 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Andrew Morton, linux-kernel, linux-mm

On Thu, Sep 22, 2016 at 10:41:50AM -0700, Hugh Dickins wrote:
> 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>
> Cc: stable@vger.kernel.org # 4.3+

Acked-by: Mel Gorman <mgorman@techsingularity.net>

-- 
Mel Gorman
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-23  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 17:41 [PATCH] mm: delete unnecessary and unsafe init_tlb_ubc() Hugh Dickins
2016-09-23  8:47 ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).