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: 9243455 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 8AEEA60757 for ; Fri, 22 Jul 2016 12:20:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CAB527FA2 for ; Fri, 22 Jul 2016 12:20:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7156627FA4; Fri, 22 Jul 2016 12:20:15 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E71427FAB for ; Fri, 22 Jul 2016 12:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753994AbcGVMUE (ORCPT ); Fri, 22 Jul 2016 08:20:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:49610 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753788AbcGVMTy (ORCPT ); Fri, 22 Jul 2016 08:19:54 -0400 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 Cc: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, Dan Williams , Ross Zwisler , Jan Kara 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> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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);