From patchwork Thu Oct 1 22:14:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7311971 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27488BEEA4 for ; Thu, 1 Oct 2015 22:14:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3234A207D7 for ; Thu, 1 Oct 2015 22:14:25 +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 3DFF1207D5 for ; Thu, 1 Oct 2015 22:14:24 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 249ED62192; Thu, 1 Oct 2015 15:14:24 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 23B1862191 for ; Thu, 1 Oct 2015 15:14:23 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 01 Oct 2015 15:14:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,619,1437462000"; d="scan'208";a="782260778" Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by orsmga001.jf.intel.com with ESMTP; 01 Oct 2015 15:14:22 -0700 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX108.amr.corp.intel.com (10.22.240.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 1 Oct 2015 15:14:22 -0700 Received: from orsmsx107.amr.corp.intel.com ([169.254.1.121]) by ORSMSX153.amr.corp.intel.com ([169.254.12.27]) with mapi id 14.03.0248.002; Thu, 1 Oct 2015 15:14:22 -0700 From: "Williams, Dan J" To: "ross.zwisler@linux.intel.com" Subject: Re: [PATCH 1/7] Revert "mm: take i_mmap_lock in unmap_mapping_range() for DAX" Thread-Topic: [PATCH 1/7] Revert "mm: take i_mmap_lock in unmap_mapping_range() for DAX" Thread-Index: AQHQ/B2CBosi9sTTmkyK3Eh23q6AQ55XjE2AgAAd2YA= Date: Thu, 1 Oct 2015 22:14:22 +0000 Message-ID: <1443737659.4886.3.camel@intel.com> References: <1443685599-4843-1-git-send-email-david@fromorbit.com> <1443685599-4843-2-git-send-email-david@fromorbit.com> <20151001202729.GA23495@linux.intel.com> In-Reply-To: <20151001202729.GA23495@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.139] Content-ID: MIME-Version: 1.0 Cc: "jack@suse.cz" , "linux-nvdimm@lists.01.org" , "dave.hansen@linux.intel.com" , "david@fromorbit.com" , "linux-kernel@vger.kernel.org" , "xfs@oss.sgi.com" , "linux-fsdevel@vger.kernel.org" , "kirill.shutemov@linux.intel.com" 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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On Thu, 2015-10-01 at 14:27 -0600, Ross Zwisler wrote: > On Thu, Oct 01, 2015 at 05:46:33PM +1000, Dave Chinner wrote: > > This reverts commit 46c043ede4711e8d598b9d63c5616c1fedb0605e. > > --- > > fs/dax.c | 36 ++++++++++++++++-------------------- > > mm/memory.c | 11 +++++++++-- > > 2 files changed, 25 insertions(+), 22 deletions(-) > > > > diff --git a/fs/dax.c b/fs/dax.c > > index 7ae6df7..400fe95 100644 > > --- a/fs/dax.c > > +++ b/fs/dax.c > > @@ -569,26 +569,6 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, > > if (!buffer_size_valid(&bh) || bh.b_size < PMD_SIZE) > > goto fallback; > > > > - if (buffer_unwritten(&bh) || buffer_new(&bh)) { > > - int i; > > - for (i = 0; i < PTRS_PER_PMD; i++) > > - clear_pmem(kaddr + i * PAGE_SIZE, PAGE_SIZE); > > - wmb_pmem(); > > The above two lines were updated to use the PMEM API with this commit: > > commit d77e92e270ed ("dax: update PMD fault handler with PMEM API") > > but they aren't updated in the reverted version here: > > > @@ -633,6 +620,15 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, > > if ((length < PMD_SIZE) || (pfn & PG_PMD_COLOUR)) > > goto fallback; > > > > + if (buffer_unwritten(&bh) || buffer_new(&bh)) { > > + int i; > > + for (i = 0; i < PTRS_PER_PMD; i++) > > + clear_page(kaddr + i * PAGE_SIZE); > > + count_vm_event(PGMAJFAULT); > > + mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); > > + result |= VM_FAULT_MAJOR; > > + } > > + > > result |= vmf_insert_pfn_pmd(vma, address, pmd, pfn, write); > > } > > This is the source of the follow-up sparse warning from the kbuild robot. > To that end Dave Hansen had also noticed that PTRS_PER_PMD should not be used in this context. Here's an incremental cleanup: 8<--- Subject: pmem, dax: clean up clear_pmem() From: Dan Williams Both, __dax_pmd_fault, and clear_pmem() were taking special steps to clear memory a page at a time to take advantage of non-temporal clear_page() implementations. However, x86_64 does not use non-temporal instructions for clear_page(), and arch_clear_pmem() was always incurring the cost of __arch_wb_cache_pmem(). Clean up the assumption that doing clear_pmem() a page at a time is more performant. Cc: Ross Zwisler Reported-by: Dave Hansen Signed-off-by: Dan Williams --- arch/x86/include/asm/pmem.h | 7 +------ fs/dax.c | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h index d8ce3ec816ab..1544fabcd7f9 100644 --- a/arch/x86/include/asm/pmem.h +++ b/arch/x86/include/asm/pmem.h @@ -132,12 +132,7 @@ static inline void arch_clear_pmem(void __pmem *addr, size_t size) { void *vaddr = (void __force *)addr; - /* TODO: implement the zeroing via non-temporal writes */ - if (size == PAGE_SIZE && ((unsigned long)vaddr & ~PAGE_MASK) == 0) - clear_page(vaddr); - else - memset(vaddr, 0, size); - + memset(vaddr, 0, size); __arch_wb_cache_pmem(vaddr, size); } diff --git a/fs/dax.c b/fs/dax.c index b36d6d2e7f87..3faff9227135 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -625,9 +625,7 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, goto fallback; if (buffer_unwritten(&bh) || buffer_new(&bh)) { - int i; - for (i = 0; i < PTRS_PER_PMD; i++) - clear_page(kaddr + i * PAGE_SIZE); + clear_pmem(kaddr, HPAGE_SIZE); count_vm_event(PGMAJFAULT); mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); result |= VM_FAULT_MAJOR;