Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp2761310qtf; Mon, 12 Jun 2023 09:35:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6L659u9GRyJ+nUZ77MlbtSqc+s6B6W1MriWLOppiLmUnkoYyWF7E9Wv83pxc587iAV/Chd X-Received: by 2002:a19:6703:0:b0:4ea:f526:5bef with SMTP id b3-20020a196703000000b004eaf5265befmr4790401lfc.28.1686587702411; Mon, 12 Jun 2023 09:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686587702; cv=none; d=google.com; s=arc-20160816; b=UO5rqenyXdNK6z7PsY6/p6T8w71vB2Jl8G2b1Ak59ZhUzuq2vxp18prvIJKB9ZU4eT sdObD4+D/peqrdXK4B1jz9SW+DXexrJeElfkKH8dec4wFzrAnZBPgaUlSxCsaVmt0D58 HTGHQ+c9Hy46s5Wrbp0UZn619T36bYKepMCDGG6vZ5cemLuo6UhYN25+MJ6Dadim8JLk nL3STczF9qjrLJona/tBIDaDrOUy+YCvatiJSE1ieuf36hwzQAslNOl9kezA5vv7sZSF 9JYSRVQcUuQKmKamBm6vBOi/xOpQIiEtmNzgIJJASkO5z5B4hsoe32bIPxUK6tbipk/o UlKg== 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=kbcWWy6lgJlv49u77NIuToLcJ7w9+T3qZB5UWslqyxQ=; b=vFAopoCLYXoX+02i48scLxtx3z7hKl3DCv5bc6JQKjnK/JKIu43SdB3HQ9IIkDBuiu tgeENXr4jUl5HJleBZuTo73jFyJeqWSHj54Yg/h7TmzyS/GIeEf5KB80Zsq1QZXl22ch qrDa2WJOVx+bAFRwDiwcp/w41Mu5c60iZu8y/UqDzNtcYKtAczieKzf0Wc83iY/WIjnZ WBd8rwLFGPo8TCY2wZCeAy0PiRkDJ2Q2cD8Zk3y8vqiSV4AmPDIMLUiIXnTKezK3m5Ez iLvnATT/+pA2aG5+U0EmNVRxUyhafiHclQv+VYK2Ebtfh4mZrbEtWTFAKLPTLsYOW0H1 brTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=A41ks5sF; 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 b20-20020aa7c914000000b00510aed0c7acsi6352495edt.77.2023.06.12.09.34.37; Mon, 12 Jun 2023 09:35:02 -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=A41ks5sF; 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 S238243AbjFLPlv (ORCPT + 99 others); Mon, 12 Jun 2023 11:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238148AbjFLPlu (ORCPT ); Mon, 12 Jun 2023 11:41:50 -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 1F8B510E2 for ; Mon, 12 Jun 2023 08:41:49 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-bc4ed01b5d4so1303362276.1 for ; Mon, 12 Jun 2023 08:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686584508; x=1689176508; 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=kbcWWy6lgJlv49u77NIuToLcJ7w9+T3qZB5UWslqyxQ=; b=A41ks5sFHka57K4fqfE86JUZi8sVGCoTPYI5ynNaLuhHWaVD5wnyI5E/THeG9ezv9h hFUN9NeXdSmdLTfV6cU6RhW6ixeXdJmtNq2y0OhafeE0g900sSc3BM37utl2iCvyu3pS xxfgQmQbYso5DjWghSSS8E/l89+tAaOV68U9KiGP2g9j1jE4hB6T8R6++UPP4RumZMV8 LAmAF8KoJr8GavbZrW2RE1zZc3QKRPJhjcCzs5R0EgwiMcU56m0L3HM4XYn+eViUJpyI 8vqYxeegj//ny6HzAJhC8KTZYUOxcFLk2OUJoaoVW3wydskZ3x20ve8D1Xwk+AB12dwu q0mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686584508; x=1689176508; 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=kbcWWy6lgJlv49u77NIuToLcJ7w9+T3qZB5UWslqyxQ=; b=EuQXlApWE91T0ItUl0PC3EzdUSh7C//F4uecmIw4J4uY64+tXmgcdXqVKmEhWhtcav TYL14Z3PyyQ2joR8rir99AVxW9slE5eCakOcMAP7a08Miz7nCMOUzZ1NUtFBuD/8MSu7 XeJoS8eUJLuEsUwg/UhxoHfnlVxA1kTAfVzxp2p23j2jS1KbiLYUMnNv6HRmPWW5z65k n3i3e6IJ/p1ER66UI/xxFNqETmilTfr4oTSVBEyFOkkeGchqpr8P9ldjzjnoYue0nFbK 5spte3vLCx7VitxJXfNGhUXDiwMRUYDqU11pl1/xzI3fhz3yvCmKYyT00rU6o86mDNch 8zHQ== X-Gm-Message-State: AC+VfDyXpDat20vVnIl/r0W/QexsubSXHu0BpLjXTYwrUxDU97HOVWQ6 m/AMHPFd9hbiLL9KsIlerpgpoOHCnPVGy1uLsERAkQ== X-Received: by 2002:a25:c744:0:b0:bc4:3e4e:12 with SMTP id w65-20020a25c744000000b00bc43e4e0012mr4781374ybe.36.1686584508078; Mon, 12 Jun 2023 08:41:48 -0700 (PDT) MIME-Version: 1.0 References: <20230609005158.2421285-1-surenb@google.com> <20230609005158.2421285-5-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 12 Jun 2023 08:41:37 -0700 Message-ID: Subject: Re: [PATCH v2 4/6] mm: drop VMA lock before waiting for migration To: Peter Xu 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, apopple@nvidia.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 Mon, Jun 12, 2023 at 6:28=E2=80=AFAM Peter Xu wrote: > > On Fri, Jun 09, 2023 at 03:30:10PM -0700, Suren Baghdasaryan wrote: > > On Fri, Jun 9, 2023 at 1:42=E2=80=AFPM Peter Xu wro= te: > > > > > > On Thu, Jun 08, 2023 at 05:51:56PM -0700, Suren Baghdasaryan wrote: > > > > migration_entry_wait does not need VMA lock, therefore it can be dr= opped > > > > before waiting. Introduce VM_FAULT_VMA_UNLOCKED to indicate that VM= A > > > > lock was dropped while in handle_mm_fault(). > > > > Note that once VMA lock is dropped, the VMA reference can't be used= as > > > > there are no guarantees it was not freed. > > > > > > Then vma lock behaves differently from mmap read lock, am I right? C= an we > > > still make them match on behaviors, or there's reason not to do so? > > > > I think we could match their behavior by also dropping mmap_lock here > > when fault is handled under mmap_lock (!(fault->flags & > > FAULT_FLAG_VMA_LOCK)). > > I missed the fact that VM_FAULT_COMPLETED can be used to skip dropping > > mmap_lock in do_page_fault(), so indeed, I might be able to use > > VM_FAULT_COMPLETED to skip vma_end_read(vma) for per-vma locks as well > > instead of introducing FAULT_FLAG_VMA_LOCK. I think that was your idea > > of reusing existing flags? > > Yes. > > I'd suggest we move this patch out of the series as it's not really part = of > it on enabling swap + uffd. It can be a separate patch and hopefully it'= ll > always change both vma+mmap lock cases, and with proper reasonings. Ok, I can move it out with mmap_lock support only and then add per-vma lock support in my patchset (because this path is still part of do_swap_page and my patchset enables swap support for per-vma locks). > > Thanks, > > -- > Peter Xu >