From patchwork Sun Feb 21 17:06:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 8368471 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86F4A9F372 for ; Sun, 21 Feb 2016 17:06:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 962D92041D for ; Sun, 21 Feb 2016 17:06:21 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 866982041C for ; Sun, 21 Feb 2016 17:06:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CEBC31A1EED; Sun, 21 Feb 2016 09:06:21 -0800 (PST) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F3C3B1A1EED for ; Sun, 21 Feb 2016 09:06:20 -0800 (PST) Received: by mail-wm0-x22b.google.com with SMTP id b205so127416389wmb.1 for ; Sun, 21 Feb 2016 09:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexistor-com.20150623.gappssmtp.com; s=20150623; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=E6nk3p+zNyJCUhZm9oZbYXY4jHNzmUZb1VhE7LcPl74=; b=bVARD5rDRsLR7FqsNF0ZB31tnikJXBZrEdmFFPH2KcSs/KLm446hksryFzldwokDST xbQWgjM1gsegMJiEF0EWUFAFIRmtKzb9WZxF1iHBtWa1OdtdjES/3DnBtiT+gaivx6hq wKfO0S6bk9yK65FJjhMR8I4FNOAElPNVSmUAvBia5iDdo7vhHNq6Z1Gs+OeqekI+cHb0 1KVrlQesZ/uDCI2GNqIPFKRetb92GOR3ip/0UArX8hOqYbBRUJVzJlrijm7HrZbpUjCW AayA2doIAMKEyPqBl3Q6mRLqdYPjsu+GbjkPtrM0Ga1/JoTIe4ydW23ocMrWbcV8c2lf BTNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=E6nk3p+zNyJCUhZm9oZbYXY4jHNzmUZb1VhE7LcPl74=; b=SzOpL5ovQrW2E/BcxjWFMSGadDTxcxC4iOOS+yU4mg+hyVcingmn0q+T4/wGDXlixd gPH5Gc63P+iTR+vK5/wTLGXo6JEx81+jnXXNCW0qnKQOehNMdu5NK8hlJhJ/gQuw3gg8 WWt6hjtiLyZ7PDrvJIPRKWpjaQMzKUMzDaet45c3FSXL6GhbHCKKMXG6F5eBB1rX5xsK oWYtvxkw426pAW73Dh/RpRnjUvkoKXIti3MkukiNBKxl/EGHeSugADkT2XUKsswVyR9C uBUZdKoo/OJ1yJTg5iXmsj03DNU1Vg46tUSzmo2yjI8ROIBHA7sF6oiy34SpuMrpgbcj rtkw== X-Gm-Message-State: AG10YOQd0NbFktcPzckTTGB/SzjCHWd40znw29oTAp8ILEw9LRfBxqYiuImKDjlYfzyxEw== X-Received: by 10.28.127.150 with SMTP id a144mr7436473wmd.25.1456074378309; Sun, 21 Feb 2016 09:06:18 -0800 (PST) Received: from [10.0.0.5] ([207.232.55.62]) by smtp.googlemail.com with ESMTPSA id up6sm20016760wjc.6.2016.02.21.09.06.16 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Feb 2016 09:06:17 -0800 (PST) Message-ID: <56C9EE87.2080106@plexistor.com> Date: Sun, 21 Feb 2016 19:06:15 +0200 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Dan Williams , Ross Zwisler , linux-nvdimm , Matthew Wilcox , "Kirill A. Shutemov" , Dave Chinner Subject: [RFC 2/2] dax: Support MAP_PMEM_AWARE mmap flag References: <56C9EDCF.8010007@plexistor.com> In-Reply-To: <56C9EDCF.8010007@plexistor.com> Cc: linux-mm , Johannes Weiner , Oleg Nesterov , Arnd Bergmann , Mel Gorman X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is possible that applications like nvml is aware that it is working with pmem, and is already doing movnt instructions and cl_flushes to keep data persistent. It is not enough that these applications do not call m/fsync, in current code we already pay extra locking and resources in the radix tree on every write page-fault even before we call m/fsync. Such application can do an mmap call with the new MAP_PMEM_AWARE flag, and for these mmap pointers flushing will not be maintained. This will not hurt any other legacy applications that do regular mmap and memcpy for these applications even if working on the same file, even legacy libraries in the same process space that do mmap calls will have their pagefaults accounted for. Since this is per vma. CC: Dan Williams CC: Ross Zwisler CC: Matthew Wilcox CC: linux-nvdimm Signed-off-by: Boaz Harrosh --- fs/dax.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 64e3fc1..f8aec85 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -579,10 +579,12 @@ static int dax_insert_mapping(struct inode *inode, struct buffer_head *bh, } dax_unmap_atomic(bdev, &dax); - error = dax_radix_entry(mapping, vmf->pgoff, dax.sector, false, + if (!(vma->vm_flags & VM_PMEM_AWARE)) { + error = dax_radix_entry(mapping, vmf->pgoff, dax.sector, false, vmf->flags & FAULT_FLAG_WRITE); - if (error) - goto out; + if (error) + goto out; + } error = vm_insert_mixed_rw(vma, vaddr, dax.pfn, 0 != (vmf->flags & FAULT_FLAG_WRITE)); @@ -984,7 +986,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, * entry completely on the initial read and just wait until * the write to insert a dirty entry. */ - if (write) { + if (write && !(vma->vm_flags & VM_PMEM_AWARE)) { error = dax_radix_entry(mapping, pgoff, dax.sector, true, true); if (error) { @@ -1065,7 +1067,9 @@ int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) * saves us from having to make a call to get_block() here to look * up the sector. */ - dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false, true); + if (!(vma->vm_flags & VM_PMEM_AWARE)) + dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false, + true); return VM_FAULT_NOPAGE; } EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);