mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: torvalds@linux-foundation.org, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, linux@arm.linux.org.uk,
	benh@kernel.crashing.org, Will Deacon <will.deacon@arm.com>
Subject: [RFC PATCH 2/2] zap_pte_range: fix partial TLB flushing in response to a dirty pte
Date: Tue, 28 Oct 2014 11:44:22 +0000	[thread overview]
Message-ID: <1414496662-25202-3-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1414496662-25202-1-git-send-email-will.deacon@arm.com>

When we encounter a dirty page during unmap, we force a TLB invalidation
to avoid a race with pte_mkclean and stale, dirty TLB entries in the
CPU.

This uses the same force_flush logic as the batch failure code, but
since we don't break out of the loop when finding a dirty pte, tlb->end
can be < addr as we only batch for present ptes. This can result in a
negative range being passed to subsequent TLB invalidation calls,
potentially leading to massive over-invalidation of the TLB (observed
in practice running firefox on arm64).

This patch fixes the issue by restricting the use of addr in the TLB
range calculations. The first range then ends up covering tlb->start to
min(tlb->end, addr), which corresponds to the currently batched range.
The second range then covers anything remaining, which may still lead to
a (much reduced) over-invalidation of the TLB.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 mm/memory.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 3e503831e042..ea41508d41f3 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1194,11 +1194,10 @@ again:
 		 * then update the range to be the remaining
 		 * TLB range.
 		 */
-		old_end = tlb->end;
-		tlb->end = addr;
+		tlb->end = old_end = min(tlb->end, addr);
 		tlb_flush_mmu_tlbonly(tlb);
-		tlb->start = addr;
-		tlb->end = old_end;
+		tlb->start = old_end;
+		tlb->end = end;
 	}
 	pte_unmap_unlock(start_pte, ptl);
 
-- 
2.1.1


  parent reply	other threads:[~2014-10-28 11:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 11:44 [RFC PATCH 0/2] Fix a couple of issues with zap_pte_range and MMU gather Will Deacon
2014-10-28 11:44 ` [RFC PATCH 1/2] zap_pte_range: update addr when forcing flush after TLB batching faiure Will Deacon
2014-10-28 15:30   ` Linus Torvalds
2014-10-28 16:07     ` Will Deacon
2014-10-28 16:25       ` Linus Torvalds
2014-10-28 17:07         ` Will Deacon
2014-10-28 18:03           ` Linus Torvalds
2014-10-28 21:16         ` Benjamin Herrenschmidt
2014-10-28 21:32           ` Linus Torvalds
2014-10-28 21:40     ` Linus Torvalds
2014-10-29 19:47       ` Will Deacon
2014-10-29 21:11         ` Linus Torvalds
2014-10-29 21:27           ` Benjamin Herrenschmidt
2014-11-01 17:01             ` Linus Torvalds
2014-11-01 20:25               ` Benjamin Herrenschmidt
2014-11-03 17:56               ` Will Deacon
2014-11-03 18:05                 ` Linus Torvalds
2014-11-04 14:29         ` Catalin Marinas
2014-11-04 16:08           ` Linus Torvalds
2014-11-06 13:57             ` Catalin Marinas
2014-11-06 17:53               ` Linus Torvalds
2014-11-06 18:38                 ` Catalin Marinas
2014-11-06 21:29                   ` Linus Torvalds
2014-11-07 16:50                     ` Catalin Marinas
2014-11-10 13:56                       ` Will Deacon
2014-10-28 11:44 ` Will Deacon [this message]
2014-10-28 15:18   ` [RFC PATCH 2/2] zap_pte_range: fix partial TLB flushing in response to a dirty pte Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414496662-25202-3-git-send-email-will.deacon@arm.com \
    --to=will.deacon@arm.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome