From: gmbnomis@gmail.com (Simon Baatz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 2/2] ARM: Handle user space mapped pages in flush_kernel_dcache_page
Date: Sun, 7 Oct 2012 13:29:12 +0200 [thread overview]
Message-ID: <1349609352-6408-3-git-send-email-gmbnomis@gmail.com> (raw)
In-Reply-To: <1349609352-6408-1-git-send-email-gmbnomis@gmail.com>
Commit f8b63c1 made flush_kernel_dcache_page() a no-op assuming that
the pages it needs to handle are kernel mapped only. However, for
example when doing direct I/O, pages with user space mappings may
occur.
Thus, do lazy flushing like in flush_dcache_page() if there are no user
space mappings. Otherwise, flush the kernel cache lines directly.
Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
Changes:
in V3:
- Followed Catalin's suggestion to reverse the order of the patches
in V2:
- flush_kernel_dcache_page() follows flush_dcache_page() now, except that it
does not flush the user mappings
arch/arm/include/asm/cacheflush.h | 4 ++++
arch/arm/mm/flush.c | 42 +++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index e4448e1..eca955f 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -307,6 +307,10 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
static inline void flush_kernel_dcache_page(struct page *page)
{
+ extern void __flush_kernel_dcache_page(struct page *);
+ /* highmem pages are always flushed upon kunmap already */
+ if (!PageHighMem(page))
+ __flush_kernel_dcache_page(page);
}
#define flush_dcache_mmap_lock(mapping) \
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 5c474a1..59ad4fc 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -192,6 +192,48 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
page->index << PAGE_CACHE_SHIFT);
}
+/*
+ * Ensure cache coherency for the kernel mapping of this page.
+ *
+ * If the page only exists in the page cache and there are no user
+ * space mappings, we can be lazy and remember that we may have dirty
+ * kernel cache lines for later. Otherwise, we need to flush the
+ * dirty kernel cache lines directly.
+ *
+ * Note that we disable the lazy flush for SMP configurations where
+ * the cache maintenance operations are not automatically broadcasted.
+ *
+ * We can assume that the page is no high mem page, see
+ * flush_kernel_dcache_page.
+ */
+void __flush_kernel_dcache_page(struct page *page)
+{
+ struct address_space *mapping;
+
+ /*
+ * The zero page is never written to, so never has any dirty
+ * cache lines, and therefore never needs to be flushed.
+ */
+ if (page == ZERO_PAGE(0))
+ return;
+
+ mapping = page_mapping(page);
+
+ if (!cache_ops_need_broadcast()) {
+ if ((mapping && !mapping_mapped(mapping)) ||
+ (!mapping && cache_is_vipt_nonaliasing())) {
+ clear_bit(PG_dcache_clean, &page->flags);
+ return;
+ }
+ }
+
+ __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
+ if (mapping && !cache_is_vivt())
+ __flush_icache_all();
+ set_bit(PG_dcache_clean, &page->flags);
+}
+EXPORT_SYMBOL(__flush_kernel_dcache_page);
+
static void __flush_dcache_aliases(struct address_space *mapping, struct page *page)
{
struct mm_struct *mm = current->active_mm;
--
1.7.9.5
next prev parent reply other threads:[~2012-10-07 11:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-07 11:29 [PATCH V2 0/2] fix and improvement of flush(_kernel)_dcache_page() Simon Baatz
2012-10-07 11:29 ` [PATCH V2 1/2] ARM: remove unnecessary flush of anon pages in flush_dcache_page() Simon Baatz
2012-10-08 11:36 ` Catalin Marinas
2012-10-08 17:38 ` Simon Baatz
2012-10-08 17:43 ` Catalin Marinas
2012-10-07 11:29 ` Simon Baatz [this message]
2012-10-08 17:44 ` [PATCH V3 2/2] ARM: Handle user space mapped pages in flush_kernel_dcache_page Catalin Marinas
2012-10-08 20:02 ` Simon Baatz
2012-10-08 20:20 ` Russell King - ARM Linux
2012-10-08 23:07 ` Simon Baatz
2012-11-18 21:10 ` Jason Cooper
2013-04-18 11:16 ` Jason Cooper
2013-04-18 11:22 ` Russell King - ARM Linux
2013-04-18 11:40 ` Jason Cooper
2013-04-18 13:51 ` Catalin Marinas
2013-04-21 22:06 ` Simon Baatz
2013-04-30 11:22 ` Catalin Marinas
2013-04-30 21:04 ` Simon Baatz
2013-05-01 14:22 ` Catalin Marinas
2013-05-01 19:04 ` Simon Baatz
2013-05-02 9:54 ` Catalin Marinas
2013-05-02 19:38 ` Simon Baatz
2013-05-03 10:02 ` Catalin Marinas
2013-05-04 8:21 ` Ming Lei
2013-05-08 15:08 ` Catalin Marinas
2013-05-08 18:43 ` Russell King - ARM Linux
2013-05-08 19:31 ` Simon Baatz
2013-05-08 21:13 ` Catalin Marinas
2013-05-09 1:52 ` Ming Lei
2013-05-11 6:27 ` Simon Baatz
2013-05-13 3:12 ` Ming Lei
2013-05-05 22:26 ` Simon Baatz
2013-05-08 15:28 ` Catalin Marinas
2013-04-18 19:39 ` Simon Baatz
2013-04-18 19:00 ` Simon Baatz
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=1349609352-6408-3-git-send-email-gmbnomis@gmail.com \
--to=gmbnomis@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).