From: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [RFC PATCH 1/2] zap_pte_range: update addr when forcing flush after TLB batching faiure
Date: Tue, 4 Nov 2014 14:29:55 +0000 [thread overview]
Message-ID: <20141104142955.GA24816@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <20141029194738.GA29911@arm.com>
(catching up with email after holiday)
On Wed, Oct 29, 2014 at 07:47:39PM +0000, Will Deacon wrote:
> mmu_gather: move minimal range calculations into generic code
>
> On architectures with hardware broadcasting of TLB invalidation messages
> , it makes sense to reduce the range of the mmu_gather structure when
> unmapping page ranges based on the dirty address information passed to
> tlb_remove_tlb_entry.
>
> arm64 already does this by directly manipulating the start/end fields
> of the gather structure, but this confuses the generic code which
> does not expect these fields to change and can end up calculating
> invalid, negative ranges when forcing a flush in zap_pte_range.
>
> This patch moves the minimal range calculation out of the arm64 code
> and into the generic implementation, simplifying zap_pte_range in the
> process (which no longer needs to care about start/end, since they will
> point to the appropriate ranges already).
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
Nice to see this clean-up for arm64, however I have a question below.
> diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
> index 5672d7ea1fa0..340bc5c5ca2d 100644
> --- a/include/asm-generic/tlb.h
> +++ b/include/asm-generic/tlb.h
> @@ -128,6 +128,46 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
> tlb_flush_mmu(tlb);
> }
>
> +static inline void __tlb_adjust_range(struct mmu_gather *tlb,
> + unsigned long address)
> +{
> + if (!tlb->fullmm) {
> + tlb->start = min(tlb->start, address);
> + tlb->end = max(tlb->end, address + PAGE_SIZE);
> + }
> +}
Here __tlb_adjust_range() assumes end to be (start + PAGE_SIZE) always.
> @@ -152,12 +193,14 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page)
> #define tlb_remove_pmd_tlb_entry(tlb, pmdp, address) \
> do { \
> tlb->need_flush = 1; \
> + __tlb_adjust_range(tlb, address); \
> __tlb_remove_pmd_tlb_entry(tlb, pmdp, address); \
> } while (0)
[...]
> #define pmd_free_tlb(tlb, pmdp, address) \
> do { \
> tlb->need_flush = 1; \
> + __tlb_adjust_range(tlb, address); \
> __pmd_free_tlb(tlb, pmdp, address); \
> } while (0)
This would work on arm64 but is the PAGE_SIZE range enough for all
architectures even when we flush a huge page or a pmd/pud table entry?
The approach Peter Z took with his patches was to use pmd_addr_end(addr,
TASK_SIZE) and change __tlb_adjust_range() to take start/end arguments:
https://lkml.org/lkml/2011/3/7/302
--
Catalin
next prev parent reply other threads:[~2014-11-04 14:30 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 [this message]
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 ` [RFC PATCH 2/2] zap_pte_range: fix partial TLB flushing in response to a dirty pte Will Deacon
2014-10-28 15:18 ` 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=20141104142955.GA24816@e104818-lin.cambridge.arm.com \
--to=catalin.marinas@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 \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®