Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17936730rwd; Tue, 27 Jun 2023 09:19:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MMI6D91mniWL3dK9IjSlq8v9TE9VlIYq1uNUxUqwgJrqtbwe1U39IZ/yTRaVtDy0jrt+Z X-Received: by 2002:a17:907:7e9c:b0:991:37d2:c9f0 with SMTP id qb28-20020a1709077e9c00b0099137d2c9f0mr6495732ejc.68.1687882776005; Tue, 27 Jun 2023 09:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882775; cv=none; d=google.com; s=arc-20160816; b=r63pmLJtPusYm96m1B4op8zIzbjeUv6Z7zqrmwInGt2KJVv4lIWrMr3QvqH943jKo4 0SybgPVxO2y6K/VwbxNlSLYfqPpZCJDO5RHhqGc+sCjzhk2TPDrUoD/7fcFyArAIfUyv ++1fViZZv0B99KerxrnDUiG9+sXkxiH1ApQjtXm7jygBqVOfWd3j5+BJglesYDTDRuBI mc+gwas4+GMApIzqJD7dDmfYno7jo6P1rZxnwz9IdQ5b/TlATkH0PLcdOSbkK7KBmJ8K zUrOP6sdJCB3559Ue2kce8lT3psuHaJwTwbHm+06D6DINy8f6l6Sa0dcxh9EnPCdorJO KNdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oZ/aZnCB2+YlDU+Ga0O4oZcR0sxHQ0xYMLAmmJhI0Q4=; fh=+Tea9ic1zqrBn3tnWdPPm9z5IiP3UfC1/DZXVVskHTc=; b=Exo7dh6xFKvQ/YEDLJ5m3fidk+q3uH1XV5oxlFJ5nM7QPoBFtsu286vMh+873VUZ/O 9XANR8FyhcdQcc28fHcs0gFNg3CRo90L3EWyyE3r2s3sMVWX1JQNYaL9e/CLTzZMIAsC yZa47NCyWeixDhhz7d7h8Cb2FDXusXyRuGrx2gHSHMvRuxTJhTD53L41sySPU8BGjVVo uFuv6BBZgQ4aRFewAJPt1+ubIsjBDO35YDmZU5oMOTARswLUtTjqmo9NAk+JYoTBV2q3 qK/ffWGzEhmmLJ6D9LEHwVMvNfC8I1yxhJdXSsChS9ZWtJ6e6TsC5uC3aE6qr25FgQnu 8tQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=XjG+cMnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br16-20020a170906d15000b009876382477csi4138940ejb.265.2023.06.27.09.19.10; Tue, 27 Jun 2023 09:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=XjG+cMnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbjF0QB0 (ORCPT + 99 others); Tue, 27 Jun 2023 12:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbjF0QBV (ORCPT ); Tue, 27 Jun 2023 12:01:21 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080472D68 for ; Tue, 27 Jun 2023 09:01:20 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-c2cf29195f8so1458865276.1 for ; Tue, 27 Jun 2023 09:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687881679; x=1690473679; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oZ/aZnCB2+YlDU+Ga0O4oZcR0sxHQ0xYMLAmmJhI0Q4=; b=XjG+cMncQkL546mb3ZvTLEPSRSb5MAObCihNdAofp7Nk4A0b9YcIh5enoJRE6qc81Z Dn9+WV+fE5c4+rB1BtMdtu7bYxunG623p32EAqdGJ775l+sE3f3H2gMprP2uR8QvZ/Ic lD2uKf6ClFO9Luxh4lPthS9YegmL6EOs8bk9nLORbez2Layf/gdNc6wpp4MlxLDmqoSl fLbO+LNIlW7HBBti5U+qXyVSH0C+8qQj477UNo5z9l4/TcyXJSHU0QqwyxBy70/VovBv Lk4794ZdkPuXIqm5pSAM6VX3jOM5e2W3j2wpJqY+DK7WM0cBWznroTSUdjqoqiBaCkvd 2X5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687881679; x=1690473679; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oZ/aZnCB2+YlDU+Ga0O4oZcR0sxHQ0xYMLAmmJhI0Q4=; b=gdsSAuJULWUqJpYV+WmXH2/w5YYmg8R2f8E2dUsXK9WlPAYmKzHW5mIw8VZ357JyDH nWLZ/6Mg3/L8atllBlnE+cp3KsMcTQ/+SQ+xOAhlEMcPK3owClSKn4vglYYiUwREtu5s ZUk4KB7Rr/XPl83GH/LZg4ZGQr9JSvAwyGUm5/MewKTMa9p+HLk7dua/UJNcYckIsBlO YxSGc+DF1xkJ2b5KQ8QhTiI2J2qMnu0Ds7ieUqWsBHI3l9j/Ntv7t8Uavr4QfusEGNx0 CWEebRl7asLwICCDzsKB+Tl++UaoiTio4S/E2pK+Vz6WAd89OUtU2Ehh+jgegYqO5Vnm 3DZg== X-Gm-Message-State: AC+VfDwLCkHLn+HWzylFxjXxfACoowobfW14HLTRhScV0VrtN2fBLH// 5QWHhqzcC/YAhirS1TwtRLGtuKkD4TX36YoeuxgvAg== X-Received: by 2002:a25:ac27:0:b0:ba6:b486:84ed with SMTP id w39-20020a25ac27000000b00ba6b48684edmr27217909ybi.20.1687881677605; Tue, 27 Jun 2023 09:01:17 -0700 (PDT) MIME-Version: 1.0 References: <20230627042321.1763765-1-surenb@google.com> <20230627042321.1763765-6-surenb@google.com> <871qhx2uot.fsf@nvdebian.thelocal> In-Reply-To: <871qhx2uot.fsf@nvdebian.thelocal> From: Suren Baghdasaryan Date: Tue, 27 Jun 2023 09:01:06 -0700 Message-ID: Subject: Re: [PATCH v3 5/8] mm: make folio_lock_fault indicate the state of mmap_lock upon return To: Alistair Popple Cc: akpm@linux-foundation.org, willy@infradead.org, hannes@cmpxchg.org, mhocko@suse.com, josef@toxicpanda.com, jack@suse.cz, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, michel@lespinasse.org, liam.howlett@oracle.com, jglisse@google.com, vbabka@suse.cz, minchan@google.com, dave@stgolabs.net, punit.agrawal@bytedance.com, lstoakes@gmail.com, hdanton@sina.com, peterx@redhat.com, ying.huang@intel.com, david@redhat.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 27, 2023 at 1:09=E2=80=AFAM Alistair Popple wrote: > > > Suren Baghdasaryan writes: > > > folio_lock_fault might drop mmap_lock before returning and to extend it > > to work with per-VMA locks, the callers will need to know whether the > > lock was dropped or is still held. Introduce new fault_flag to indicate > > whether the lock got dropped and store it inside vm_fault flags. > > > > Signed-off-by: Suren Baghdasaryan > > --- > > include/linux/mm_types.h | 1 + > > mm/filemap.c | 2 ++ > > 2 files changed, 3 insertions(+) > > > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 79765e3dd8f3..6f0dbef7aa1f 100644 > > --- a/include/linux/mm_types.h > > +++ b/include/linux/mm_types.h > > @@ -1169,6 +1169,7 @@ enum fault_flag { > > FAULT_FLAG_UNSHARE =3D 1 << 10, > > FAULT_FLAG_ORIG_PTE_VALID =3D 1 << 11, > > FAULT_FLAG_VMA_LOCK =3D 1 << 12, > > + FAULT_FLAG_LOCK_DROPPED =3D 1 << 13, > > Minor nit but this should also be added to the enum documentation > comment above this. Thanks! Sounds like we will be dripping the new flag, so hopefully I won't need to document it :) > > > }; > > > > typedef unsigned int __bitwise zap_flags_t; > > diff --git a/mm/filemap.c b/mm/filemap.c > > index 87b335a93530..8ad06d69895b 100644 > > --- a/mm/filemap.c > > +++ b/mm/filemap.c > > @@ -1723,6 +1723,7 @@ vm_fault_t __folio_lock_fault(struct folio *folio= , struct vm_fault *vmf) > > return VM_FAULT_RETRY; > > > > mmap_read_unlock(mm); > > + vmf->flags |=3D FAULT_FLAG_LOCK_DROPPED; > > if (vmf->flags & FAULT_FLAG_KILLABLE) > > folio_wait_locked_killable(folio); > > else > > @@ -1735,6 +1736,7 @@ vm_fault_t __folio_lock_fault(struct folio *folio= , struct vm_fault *vmf) > > ret =3D __folio_lock_killable(folio); > > if (ret) { > > mmap_read_unlock(mm); > > + vmf->flags |=3D FAULT_FLAG_LOCK_DROPPED; > > return VM_FAULT_RETRY; > > } > > } else { >