From patchwork Wed Sep 26 21:40:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Baatz X-Patchwork-Id: 1510991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 42C8FDFE81 for ; Wed, 26 Sep 2012 21:43:27 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TGzMX-00036I-TO; Wed, 26 Sep 2012 21:41:45 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TGzMQ-00035e-2w for linux-arm-kernel@lists.infradead.org; Wed, 26 Sep 2012 21:41:39 +0000 Received: by wgbdt14 with SMTP id dt14so588236wgb.18 for ; Wed, 26 Sep 2012 14:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=5OyfADNuqsB3xBnOHtRnPPolERQf6KvKSd8rtQJIb84=; b=WUM+4s0T+WCEMo7v9ON7U4sBZ24PM3NkV696PDrmCzrrQUcIEKG3WyZ4jikA4XQ0Kx PcV5Wq30bvjC7gt4mOCqpTSmKKcvqaqm9OtcBE0eG1JplNVLQs5wqJUcmYgjjlhqvx1q zmDW5+oo9uoD/WEDqpyCshYY4GMTG9bSF7JH+fICUSvC7xVNZ0/j/DjY8rv+ns3M8SWl BGNL3gNCQ8oOlEiznOuTPAQx/plQIlTjhD2nfpvyz5ZIL2Jdo2VMyt2rPF9YPf4p9AXy 9eu4xUNU3jDi91iVKZoWt4LTjxw8PDM//Z1QULmYD77pMj8Xn8NI/JH/TBfxHjLt9qg6 V42A== Received: by 10.180.85.99 with SMTP id g3mr3949892wiz.5.1348695694034; Wed, 26 Sep 2012 14:41:34 -0700 (PDT) Received: from gandalf.schnuecks.de (p5DE8D84E.dip.t-dialin.net. [93.232.216.78]) by mx.google.com with ESMTPS id fb20sm9298978wid.1.2012.09.26.14.41.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 14:41:33 -0700 (PDT) Received: by gandalf.schnuecks.de (Postfix, from userid 500) id 18D2040120; Wed, 26 Sep 2012 23:41:32 +0200 (CEST) From: Simon Baatz To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 1/2] ARM: Handle user space mapped pages in flush_kernel_dcache_page Date: Wed, 26 Sep 2012 23:40:58 +0200 Message-Id: <1348695659-27603-2-git-send-email-gmbnomis@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348695659-27603-1-git-send-email-gmbnomis@gmail.com> References: <1348695659-27603-1-git-send-email-gmbnomis@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (gmbnomis[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: catalin.marinas@arm.com, linux@arm.linux.org.uk, jason@lakedaemon.net, andrew@lunn.ch X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Cc: Catalin Marinas Cc: Russell King --- Changes 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 | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 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 40ca11e..982db2f 100644 --- a/arch/arm/mm/flush.c +++ b/arch/arm/mm/flush.c @@ -192,6 +192,45 @@ 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() && + mapping && !mapping_mapped(mapping)) + clear_bit(PG_dcache_clean, &page->flags); + else { + __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;