From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4E92ECAAD5 for ; Wed, 7 Sep 2022 01:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GZPdjU9WVlaDLR3/JSCm0vQxu+Is/7AAtAyC5tNLwNg=; b=yNI4pIzOiynZCG U4t9P2q4mmJGh/L6FyvRE9fyR9PSYqi2yuYATyq7rSxenlWTbVXFKRS1EUsrCUGbGec3j7YFzuuCK I8rxyJfv4ajlXqJwKZyvvyCBnGuYfLos7Onu7gIRUSSE7E12+GfIGXIg+ZgiO1RFSjU52KLeW7yt9 oz/vZ1fP4jjorxNfX8EZ302XPHJSHTuJgTLF5F0jOSBNluqkJ6rzesqGKhP4hPgy8vxzaN1+knsft iw6MW/Vmg65g+g70g6P7yFSeS2LzvaYFSw/itjHIqLNpaOd3w3BRA4qGe8fVZYPy3wcf/z2Jla5Ge cqjnK+oSs/TGoeNevmlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVjOk-0016sp-Cj; Wed, 07 Sep 2022 00:58:34 +0000 Received: from mail-yb1-xb2c.google.com ([2607:f8b0:4864:20::b2c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVjOh-0016q8-SJ for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 00:58:33 +0000 Received: by mail-yb1-xb2c.google.com with SMTP id 130so13751542ybz.9 for ; Tue, 06 Sep 2022 17:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=UjaiWINnbTXgT+URtVXx1fGemLW7KAjAuDjBEcKQcpw=; b=EAkdAoJF93b/9wVcZWS/8Z33Wh8Eq7xG8wCxKPHNm0Lldc4C5bChxoQDfIHIPRDYax E+7oO+L2O6scu7V+5fNLALkC2gSW3KtuP3tfNpYEXGlOWDD2sTiTX6OWgeeJAcpYfcqc A7KFsvQIqZJC3pSoupGeVX3b2h2lXfNqXDDwmhewWl9SZYpSIQb+K3ijuHEHBKnlI5iN 5YTs4xJNgeAVeEvcjs3kD0qLdfQNKm1QP8zoW0R448XpFNwDG9J12DbqDl3vZ1zKXm72 +HSPLoCsmPAhUhpPj99b2yJIbwOsGllYC7rvCmcvKG+KcIcU1HoAeaosy/7TBlwl5auu e43Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=UjaiWINnbTXgT+URtVXx1fGemLW7KAjAuDjBEcKQcpw=; b=PPdjcutmFi/AhKHqr3nVoQkgGuwA++w+KPSbd716+XfkcoomjA9G957vRlpUJK+1tL +ONxDUcyp1O/DERcywR0gt4j2quzKOSX8L68f+di329HRXAc23oBTX9PXpsM00wX8bn7 nlseibW/lhuaPt74IrrmARDLMxi/XUr3Q74/65Ffoy5yIGwl+G8NfYrVyckrG8ciUIEj 14nsDjB+yg3CtMJph+3SmnzIb7uCwZU3D/TYmKnJsmHwT7PTwpex+4kAhpcUu3y1afw/ 0/TVhXOnvcYCu3PQ7sE7ysGM2rNfSlbskKQICxG1mOC6sUxstTLwQbbV4vx72G4Bw81a rPNg== X-Gm-Message-State: ACgBeo3kVfNCy2CYEP3Rj/zEQ+xi+RvubQZCSNAD+EZ+jBywr+ECpr0Z 0yrflJhuBKi61xPFvrrkYAz1TuyvLVLIG4jNUykCDw== X-Google-Smtp-Source: AA6agR7/aESfD9/NDPsDFtQ7YKYMRNuKLSwT1FUjw+G1bf9VJ00olfdLIYvwBbmvvuSYroc7vvTiDT6ZBY0OsHmp1Qc= X-Received: by 2002:a25:9781:0:b0:6a9:561a:c143 with SMTP id i1-20020a259781000000b006a9561ac143mr995480ybo.59.1662512309570; Tue, 06 Sep 2022 17:58:29 -0700 (PDT) MIME-Version: 1.0 References: <20220901173516.702122-1-surenb@google.com> <20220901173516.702122-20-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 6 Sep 2022 17:58:18 -0700 Message-ID: Subject: Re: [RFC PATCH RESEND 19/28] mm: disallow do_swap_page to handle page faults under VMA lock To: Peter Xu Cc: Andrew Morton , Michel Lespinasse , Jerome Glisse , Michal Hocko , Vlastimil Babka , Johannes Weiner , Mel Gorman , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , Peter Zijlstra , Laurent Dufour , Laurent Dufour , "Paul E . McKenney" , Andy Lutomirski , Song Liu , David Hildenbrand , dhowells@redhat.com, Hugh Dickins , Sebastian Andrzej Siewior , Kent Overstreet , David Rientjes , Axel Rasmussen , Joel Fernandes , Minchan Kim , kernel-team , linux-mm , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, LKML X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_175831_943961_47AE85E0 X-CRM114-Status: GOOD ( 26.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 6, 2022 at 1:22 PM Peter Xu wrote: > > On Tue, Sep 06, 2022 at 01:08:10PM -0700, Suren Baghdasaryan wrote: > > On Tue, Sep 6, 2022 at 12:39 PM Peter Xu wrote: > > > > > > On Thu, Sep 01, 2022 at 10:35:07AM -0700, Suren Baghdasaryan wrote: > > > > Due to the possibility of do_swap_page dropping mmap_lock, abort fault > > > > handling under VMA lock and retry holding mmap_lock. This can be handled > > > > more gracefully in the future. > > > > > > > > Signed-off-by: Suren Baghdasaryan > > > > --- > > > > mm/memory.c | 5 +++++ > > > > 1 file changed, 5 insertions(+) > > > > > > > > diff --git a/mm/memory.c b/mm/memory.c > > > > index 9ac9944e8c62..29d2f49f922a 100644 > > > > --- a/mm/memory.c > > > > +++ b/mm/memory.c > > > > @@ -3738,6 +3738,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > > > vm_fault_t ret = 0; > > > > void *shadow = NULL; > > > > > > > > + if (vmf->flags & FAULT_FLAG_VMA_LOCK) { > > > > + ret = VM_FAULT_RETRY; > > > > + goto out; > > > > + } > > > > + > > > > > > May want to fail early similarly for handle_userfault() too for similar > > > reason. Thanks, > > > > I wasn't aware of a similar issue there. Will have a closer look. Thanks! > > Sure. > > Just in case this would be anything helpful - handle_userfault() will both > assert at the entry (mmap_assert_locked) and will in most cases release > read lock along the way when waiting for page fault resolutions. > > And userfaultfd should work on anonymous memory for either missing mode or > write protect mode. Got it. Thanks for the explanation. It definitely helps! > > Thanks, > > -- > Peter Xu > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel