From patchwork Tue Apr 11 17:42:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 9675871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 54A9460231 for ; Tue, 11 Apr 2017 17:43:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D4F028538 for ; Tue, 11 Apr 2017 17:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 423FB28598; Tue, 11 Apr 2017 17:43:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 01CD228538 for ; Tue, 11 Apr 2017 17:43:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E38D320D7648C; Tue, 11 Apr 2017 10:42:59 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (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 E23BD20D7648C for ; Tue, 11 Apr 2017 10:42:58 -0700 (PDT) Received: by mail-pg0-x241.google.com with SMTP id o123so688037pga.1 for ; Tue, 11 Apr 2017 10:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rTheuhE9mx8Z1OSTebjJScY3ajr+iEvY+0zH/HX+7V0=; b=bxl7oiC7iMcZKy52TjW7cxplUTb8h3nRpdJFUavYwHd6WMfoMTdNlxZRwiDTp3oCO5 q+WMuqAPdJDMzR2a/9uSDvQ/JsKwtyExkXkeUQPhkPYy1jRnd3JtzaHU/m0MAf0bfGKc sjdr+/jSVpiSGz8hYO8VZQC0EoBaPYyjKcaJS2K+Iezq1E2axO+RqHPAUOgb4pZuyJSn ExcpVjKvuwrOs8YULRgIrUUPySa5eNt+Ys3UgidQtw6PHsPeGwBNlov4Amgjykb35Cyh Zr3Tn5CHVBuuW9u6GD/CpcCOHmNZzku1kg8ktcb0G1prB5NSl2Ep1ONGVJAj5OizmXNv lSWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rTheuhE9mx8Z1OSTebjJScY3ajr+iEvY+0zH/HX+7V0=; b=HrY7aje8QfVtp6yarKKJ5djxhyAvEXHOoIMPOs+rIqFhJACoUURkhRQLbJkQdP62NU D7kX4vOAJrdikERMnGyTdTcuc+GtofDvOcRouYrxnKQXvUcQXMIW9nykekOaVUJi9L8o 2I1jqiOtzbcNARkLInlyewHdTf+9rsGqjqcCpG0dLeawU89KFDaawiq/lwfG9yjqGncU TD5aDHnbY/ZJM/uEtEgpkGKPkJIBXXh0+kNIs3r5nn4RegNTYCKzlj18/TsRs1qxnEMP V2Z8cAvhOmUCpjrP3rPJqCn8fYkCfvFwi5e2j4dvDSJKxmvfdLXsqqxzw8mfEX1z6Nyu VLag== X-Gm-Message-State: AN3rC/7PiisA0Tupp7RPN3BEcs9PmrgVcftkAEAMv+8KPdUiOufX8bcsnJ8Cca7qEBULVQ== X-Received: by 10.84.254.4 with SMTP id b4mr1308945plm.64.1491932578634; Tue, 11 Apr 2017 10:42:58 -0700 (PDT) Received: from localhost.localdomain ([103.57.0.128]) by smtp.gmail.com with ESMTPSA id r185sm20182582pfr.72.2017.04.11.10.42.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 10:42:58 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/9] mm/huge_memory: Deposit a pgtable for DAX PMD faults when required Date: Wed, 12 Apr 2017 03:42:26 +1000 Message-Id: <20170411174233.21902-3-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170411174233.21902-1-oohall@gmail.com> References: <20170411174233.21902-1-oohall@gmail.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org, bsingharora@gmail.com, arbab@linux.vnet.ibm.com, linux-mm@kvack.org, "Aneesh Kumar K.V" MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Although all architectures use a deposited page table for THP on anonymous VMAs some architectures (s390 and powerpc) require the deposited storage even for file backed VMAs due to quirks of their MMUs. This patch adds support for depositing a table in DAX PMD fault handling path for archs that require it. Other architectures should see no functional changes. Cc: "Aneesh Kumar K.V" Cc: linux-mm@kvack.org Signed-off-by: Oliver O'Halloran Reviewed-by: Aneesh Kumar K.V --- mm/huge_memory.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index aa01dd47cc65..a84909cf20d3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -715,7 +715,8 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf) } static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, - pmd_t *pmd, pfn_t pfn, pgprot_t prot, bool write) + pmd_t *pmd, pfn_t pfn, pgprot_t prot, bool write, + pgtable_t pgtable) { struct mm_struct *mm = vma->vm_mm; pmd_t entry; @@ -729,6 +730,12 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, entry = pmd_mkyoung(pmd_mkdirty(entry)); entry = maybe_pmd_mkwrite(entry, vma); } + + if (pgtable) { + pgtable_trans_huge_deposit(mm, pmd, pgtable); + atomic_long_inc(&mm->nr_ptes); + } + set_pmd_at(mm, addr, pmd, entry); update_mmu_cache_pmd(vma, addr, pmd); spin_unlock(ptl); @@ -738,6 +745,7 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, pfn_t pfn, bool write) { pgprot_t pgprot = vma->vm_page_prot; + pgtable_t pgtable = NULL; /* * If we had pmd_special, we could avoid all these restrictions, * but we need to be consistent with PTEs and architectures that @@ -752,9 +760,15 @@ int vmf_insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, if (addr < vma->vm_start || addr >= vma->vm_end) return VM_FAULT_SIGBUS; + if (arch_needs_pgtable_deposit()) { + pgtable = pte_alloc_one(vma->vm_mm, addr); + if (!pgtable) + return VM_FAULT_OOM; + } + track_pfn_insert(vma, &pgprot, pfn); - insert_pfn_pmd(vma, addr, pmd, pfn, pgprot, write); + insert_pfn_pmd(vma, addr, pmd, pfn, pgprot, write, pgtable); return VM_FAULT_NOPAGE; } EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd); @@ -1611,6 +1625,8 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, tlb->fullmm); tlb_remove_pmd_tlb_entry(tlb, pmd, addr); if (vma_is_dax(vma)) { + if (arch_needs_pgtable_deposit()) + zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); if (is_huge_zero_pmd(orig_pmd)) tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE);