Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752043AbbGMOfv (ORCPT ); Mon, 13 Jul 2015 10:35:51 -0400 Received: from mga11.intel.com ([192.55.52.93]:43425 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbbGMOft (ORCPT ); Mon, 13 Jul 2015 10:35:49 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,463,1432623600"; d="scan'208";a="727964605" Date: Mon, 13 Jul 2015 10:35:45 -0400 From: Matthew Wilcox To: Boaz Harrosh Cc: Geert Uytterhoeven , Andrew Morton , Paul Bolle , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Arnd Bergmann Subject: Re: [PATCH] fs: dax: do not build on ARC or SH Message-ID: <20150713143545.GF13681@linux.intel.com> References: <1436781167-14446-1-git-send-email-geert+renesas@glider.be> <55A3A796.4050108@plexistor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A3A796.4050108@plexistor.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2564 Lines: 51 On Mon, Jul 13, 2015 at 02:57:10PM +0300, Boaz Harrosh wrote: > I do not understand why we need to call copy_user_page here at all? > the destination is kmap_atomic() so it must be there right? also the > destination is the cow-to page so surly it is not yet mapped to user-space > mapping. > > the from is pmem which is just there. > > >From what I understand copy_user_page means: > On these ARCHs that each user-mapping has its own VM cache, please invalidate > the other VM caches. > Like on arm64 (arch/arm64/mm/copypage.c): > copy_page(kto, kfrom); > __flush_dcache_area(kto, PAGE_SIZE); You're confusing implementation with guaranteed semantics. The problem is for architectures which have virtually indexed caches, the kernel virtual address does not necessarily map to the same cacheline as user virtual addresses. The solution that has been adopted for page cache pages is that user addresses are flushed before the kernel reads from a page, and kernel addresses are flushed before the kernel writes to a page. Now, imagine task A mmaps a file using MAP_SHARED. Task B mmaps the same file using MAP_PRIVATE. Task A & B have a communication channel, maybe a socket. Task A stores a few bytes to a page in the mmap, and then sends a message down the communication channel. Task B stores a byte to a different part of the same page (causing the COW) and then examines the bytes that task A wrote. To avoid violating causality, we must have copied the bytes that task B would have seen at that time, as opposed to the bytes which were in storage before task A overwrote them. So either we flush the bytes that task A wrote before doing the COW, or we copy from an address that is cache-coherent with the address that A used to do the store. > So what I do not understand is why copy_user_page does not have a default > implementation for those ARCHs that don't override it. copy_user_page() is a documented part of the cache flushing protocols. Some architectures have chosen to not implement it, even though they actually need the flushing. There is a separate issue which is that DAX is not currently doing enough flushing. Fixing that is about fourth on my priority list right now. 2MB pages, RDMA access and a rather interesting bug reported to me last week are all higher priority. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/