From patchwork Fri Jul 22 12:19:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9243437 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 3D256602F0 for ; Fri, 22 Jul 2016 12:20:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E111266F3 for ; Fri, 22 Jul 2016 12:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 224CE27FA4; Fri, 22 Jul 2016 12:20: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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham 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 B95AE266F3 for ; Fri, 22 Jul 2016 12:19:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E6DFB1A1E58; Fri, 22 Jul 2016 05:20:48 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D7F9D1A1E0A for ; Fri, 22 Jul 2016 05:20:45 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 13211AD44; Fri, 22 Jul 2016 12:19:51 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B1EED1E0F30; Fri, 22 Jul 2016 14:19:47 +0200 (CEST) From: Jan Kara To: linux-mm@kvack.org Subject: [PATCH 12/15] mm: Lift vm_fault structure creation from do_page_mkwrite() Date: Fri, 22 Jul 2016 14:19:38 +0200 Message-Id: <1469189981-19000-13-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1469189981-19000-1-git-send-email-jack@suse.cz> References: <1469189981-19000-1-git-send-email-jack@suse.cz> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Jan Kara , linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Move creation of struct vm_fault up from do_page_mkwrite() to avoid passing some parameters and actually safe creating it in one case. Signed-off-by: Jan Kara --- mm/memory.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index c3f639c33232..1d2916c53d43 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2033,17 +2033,12 @@ static void init_vmf(struct vm_fault *vmf, struct vm_area_struct *vma, * * We do this without the lock held, so that it can sleep if it needs to. */ -static int do_page_mkwrite(struct vm_area_struct *vma, struct page *page, - unsigned long address, pmd_t *pmd, pte_t orig_pte) +static int do_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) { - struct vm_fault vmf; int ret; + struct page *page = vmf->page; - init_vmf(&vmf, vma, address, pmd, page->index, - FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE, orig_pte); - vmf.page = page; - - ret = vma->vm_ops->page_mkwrite(vma, &vmf); + ret = vma->vm_ops->page_mkwrite(vma, vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) return ret; if (unlikely(!(ret & VM_FAULT_LOCKED))) { @@ -2311,9 +2306,14 @@ static int wp_page_shared(struct mm_struct *mm, struct vm_area_struct *vma, if (vma->vm_ops->page_mkwrite) { int tmp; + struct vm_fault vmf; pte_unmap_unlock(page_table, ptl); - tmp = do_page_mkwrite(vma, old_page, address, pmd, orig_pte); + + init_vmf(&vmf, vma, address, pmd, old_page->index, + FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE, orig_pte); + vmf.page = old_page; + tmp = do_page_mkwrite(vma, &vmf); if (unlikely(!tmp || (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { put_page(old_page); @@ -3137,7 +3137,6 @@ uncharge_out: static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_fault *vmf) { - unsigned long address = (unsigned long)vmf->virtual_address; int ret, tmp; ret = __do_fault(vma, vmf); @@ -3150,8 +3149,8 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma, */ if (vma->vm_ops->page_mkwrite) { unlock_page(vmf->page); - tmp = do_page_mkwrite(vma, vmf->page, address, vmf->pmd, - vmf->orig_pte); + vmf->flags = FAULT_FLAG_WRITE | FAULT_FLAG_MKWRITE; + tmp = do_page_mkwrite(vma, vmf); if (unlikely(!tmp || (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { put_page(vmf->page);