From patchwork Fri Dec 27 18:00:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 305458 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4AEC62C00A1 for ; Sat, 28 Dec 2013 05:00:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754127Ab3L0SAV (ORCPT ); Fri, 27 Dec 2013 13:00:21 -0500 Received: from mga02.intel.com ([134.134.136.20]:57555 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753716Ab3L0SAV (ORCPT ); Fri, 27 Dec 2013 13:00:21 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 27 Dec 2013 10:00:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,561,1384329600"; d="scan'208";a="458488717" Received: from unknown (HELO rizzo.int.wil.cx) ([10.255.12.21]) by orsmga002.jf.intel.com with ESMTP; 27 Dec 2013 10:00:19 -0800 Received: by rizzo.int.wil.cx (Postfix, from userid 1000) id AB382172477; Fri, 27 Dec 2013 13:00:18 -0500 (EST) Date: Fri, 27 Dec 2013 13:00:18 -0500 From: Matthew Wilcox To: linux-mm@kvack.org Cc: "David S. Miller" , sparclinux@vger.kernel.org, linux-parisc@vger.kernel.org, linux-mips@linux-mips.org Subject: [PATCH] remap_file_pages needs to check for cache coherency Message-ID: <20131227180018.GC4945@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org It seems to me that while (for example) on SPARC, it's not possible to create a non-coherent mapping with mmap(), after we've done an mmap, we can then use remap_file_pages() to create a mapping that no longer aliases in the D-cache. I have only compile-tested this patch. I don't have any SPARC hardware, and my PA-RISC hardware hasn't been turned on in six years ... I noticed this while wandering around looking at some other stuff. --- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/mm/fremap.c b/mm/fremap.c index 5bff081..01fc2e7 100644 --- a/mm/fremap.c +++ b/mm/fremap.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "internal.h" @@ -177,6 +178,13 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, if (start < vma->vm_start || start + size > vma->vm_end) goto out; +#ifdef __ARCH_FORCE_SHMLBA + /* Is the mapping cache-coherent? */ + if ((pgoff ^ linear_page_index(vma, start)) & + ((SHMLBA-1) >> PAGE_SHIFT)) + goto out; +#endif + /* Must set VM_NONLINEAR before any pages are populated. */ if (!(vma->vm_flags & VM_NONLINEAR)) { /*