From patchwork Wed Sep 26 21:08:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10616865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 322BB15A6 for ; Wed, 26 Sep 2018 21:09:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21B312B7F2 for ; Wed, 26 Sep 2018 21:09:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 152A22B7F9; Wed, 26 Sep 2018 21:09:30 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7B952B7F2 for ; Wed, 26 Sep 2018 21:09:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF48C8E000A; Wed, 26 Sep 2018 17:09:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D7EE68E0008; Wed, 26 Sep 2018 17:09:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1F3B8E000A; Wed, 26 Sep 2018 17:09:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 8CCF88E0008 for ; Wed, 26 Sep 2018 17:09:14 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id d205-v6so434876qkg.16 for ; Wed, 26 Sep 2018 14:09:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id :in-reply-to:references; bh=uNw1SEfuNh5muyIlKMjO8zXN2XjQ0Df1a1ZQWi9S3hE=; b=YfMC5r8olRMqAPosYAjaLVFMAeVR4fu8XwU4TvsBBzjENYEaS0yTuq+TXiMh1ZIpKq NRG1WXWiJxXDSKLjO744WZFvgzMT6q8kODLp87J2ZHaqFebt/rWThS+xO7s0Ck/cYuH9 RGewJQnYon3OfG7zLdUqpKkcQoQMw9tvvyIqOfBadXfQzdRKOU3XFeOyhY1uVQs74mU/ JDY4XdiXQfrPO1u6gqVo97UND8Cf2UijaTSL+T7tJloUe6VfoB1vc1m3K4EJyQVspNYe y85pypeU42mKFyootk5x7B63FfTN5fhkSlXc5/FMuybyPKodA6ZboZPestkJr4AYFJ8a AmaA== X-Gm-Message-State: ABuFfoi1GNOOsyEOGq6+BCAyCtPDufUARHVbi1ymGyigQmG+1DvCJZbw vhRdtlRa3NWALyqO4gkktnNEbFH3Rz0re2cqFyGxsL52SiC9oYyj5R0hO4HPtmzcXWrphdCbBKy At3UAqU4TRHx3wq2aJH+d+EdZwPudDF6tAlhzxSOn5mzToLlO3OeMXv10HcQLbDziLW/jp0gkQl HrLDj7bqgjYYMqYNF4BSNqDnU0XKxVDEveESvNmmxF3EaGCeDfm6ueH5f11dEDhA5aecWURQ5sA 0n/v4da7+Z/waNXZTYD8X+g9dRdY+BqFn54NoLuxptxNAt726ZbJ9hHU4P70oZH0iUbc5RWhC9b PwuWa3cadgiMNtHGAssRCu5finay1ik4N74otHqCZ1qdpSo5aReyq4Uv8fmAJjeejRQ63hNgGDB 6 X-Received: by 2002:aed:3fce:: with SMTP id w14-v6mr6001962qth.226.1537996154371; Wed, 26 Sep 2018 14:09:14 -0700 (PDT) X-Received: by 2002:aed:3fce:: with SMTP id w14-v6mr6001934qth.226.1537996153864; Wed, 26 Sep 2018 14:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537996153; cv=none; d=google.com; s=arc-20160816; b=0X+SxUq827c24EOIyIK7oSx8E3ZrsWhd2407Rat+Nm42EQu7N0V3f4P/MclNaH7epo Pva3wotwTq6HhY5uZv20qI6mA1nIj9Tbb20fPDj9jH1+3547dy33gtbI6nEXIu2P0tms tmfL9OF+hem2O45fJ1JXG4TJh3221FxEhl292SO1FEJuLle+dYrVzUe56phYKsipNgaZ eOZ46SU2hSBj331hVTE2AI7bEiWZ2kbOwhPxmqvVR4VGWvziZq1hMAmWi9Ab2U8U1GT2 uD0PmS3uSa/mYN08rbrarBE2rtcdpq9z6fN9um9pAug9p4kRSPyxbPI3GSP0/V5b03g4 gCGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uNw1SEfuNh5muyIlKMjO8zXN2XjQ0Df1a1ZQWi9S3hE=; b=yEG8qgOlbtIxsByp+JQgyfRkhX0IP4CnWTmMcgXcDDXXbB5KHgAymq/VhtPprp3pwj UCMlh/0fzdEWqD4oF7S3EOjzdhkezGzT++7nsyV0Ez0gdQAzCrkU+gx/1zMa/C0G3cPQ XdjyxGn2dIXAqCl0Ravn8e1TOQdca4RVr3PomZvQkJgahxH9ofhRam2ObE0bglM+zZyJ c62zKJfiWPIJpNODdSxsS2BhQ8VIaFm3GHiRNCP30x58Lifg6+1no3+ZK2mJ6g9hDVFv xXFgmCCaE9Jg6RTiAxvKgZFO5L93Umjz3q7Saws7dQOy9wtUfZJHn+4Z7hO27OS6EZgN tPbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=E+IkZtxW; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b54-v6sor54187qtk.74.2018.09.26.14.09.13 for (Google Transport Security); Wed, 26 Sep 2018 14:09:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=E+IkZtxW; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=uNw1SEfuNh5muyIlKMjO8zXN2XjQ0Df1a1ZQWi9S3hE=; b=E+IkZtxWnldcnfnVAFchZ1hWE504qBGKdX2eijVXxr7G+Yns/Lw/m0dK3zwPRS5BR7 NPhHdsbYsqv7Rk+GL8cmQXek2L9S55HKsJVPA0JzSGx8F5+cBMI0QQ9EHQtfNLwA7i4t sC3pLwKemV+y20kKGmmL7K6hBp6n0IfS+xlPMNJ1jxbDFLwniUzBbzgyaLZ1K5mkWh7P eg9pTRdVcxR0Iz8T8p0VWPa/8okeH8kK+cdMZva7oNTlzpExw4ukGzcJj8CVcUfue3GZ UYlI0UuSGIZmFrnbVaBQ6nzmTHAXCMDv3kggv8aYdCPINTF/+3uSSqUkA/HIfFou9+kA XliA== X-Google-Smtp-Source: ACcGV62nU0p/SpQCuwEhccw6FtSj8cKf4zvclsHPNrLrKJb3VdwuIBbYKgcnnrv2S2qANr8nkWYi+g== X-Received: by 2002:ac8:39a1:: with SMTP id v30-v6mr5494082qte.58.1537996153608; Wed, 26 Sep 2018 14:09:13 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id r9-v6sm37064qta.87.2018.09.26.14.09.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 14:09:12 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, tj@kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, riel@redhat.com, linux-mm@kvack.org, linux-btrfs@vger.kernel.org Subject: [PATCH 8/9] mm: allow ->page_mkwrite to do retries Date: Wed, 26 Sep 2018 17:08:55 -0400 Message-Id: <20180926210856.7895-9-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180926210856.7895-1-josef@toxicpanda.com> References: <20180926210856.7895-1-josef@toxicpanda.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Before we didn't set the retry flag on our vm_fault. We want to allow file systems to drop the mmap_sem if they so choose, so set this flag and deal with VM_FAULT_RETRY appropriately. Signed-off-by: Josef Bacik --- mm/memory.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 6f8abde84986..821435855177 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2384,11 +2384,13 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf) unsigned int old_flags = vmf->flags; vmf->flags = FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE; + vmf->flags |= old_flags & FAULT_FLAG_ALLOW_RETRY; ret = vmf->vma->vm_ops->page_mkwrite(vmf); /* Restore original flags so that caller is not surprised */ vmf->flags = old_flags; - if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) + if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY))) return ret; if (unlikely(!(ret & VM_FAULT_LOCKED))) { lock_page(page); @@ -2683,7 +2685,8 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || (tmp & - (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; } @@ -3716,7 +3719,8 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) unlock_page(vmf->page); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || - (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; }