Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6659612rdb; Tue, 2 Jan 2024 08:59:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IF97nIFNa5XqXOHpQfRXaUFWPRtwpWyiF29FdLFQd1Kad5l3pyKPHtKRZI3tQACxyB5jdUV X-Received: by 2002:a05:6358:50ca:b0:175:5f:7976 with SMTP id m10-20020a05635850ca00b00175005f7976mr13995280rwm.24.1704214747677; Tue, 02 Jan 2024 08:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704214747; cv=none; d=google.com; s=arc-20160816; b=KG/AcLjmsKFNpBEY/nRKCVvX/NVq/GXgmNfqtKSEr0xY2am93ygEflDT08AVN6y6Ue 1EayGSvde8EyTHLZ/q5kMv1cdk87pcOHNgkfxznp1f9KlYMXJfHttorklT70RDXEJ9AP 9geX0VDGY//bII3vUT9M3BebEDCZctFxIUnwsPjmF5tfWNBTK2HMlj2rxMMeZ6DBFA4d NI9o5Lp/i0NpW7LZtlKnPFswiYsSMvK9DeZ3j4LpZjvox2ezCzeidELP1jeYE8ktZmt8 KUUdmyhqUscf3rMjca+2rRVXmnuqxMeNT4inzATvFvd9m3OfisZ+JRXJS8Qz+UJg37ex cmFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/kfSvqUQhDDQeZ7w9vi8u82O1MW4zk5hhfYcLpsRKrM=; fh=FwWBjM+xWJi7arR2ekAOUWY0Uxliwfm0q+bxzjcmt3o=; b=dErH+N2K/GWV1muFpFnwdHHTRe4S5UjL3uojpDeQKp+seO/RZdPnXa+ABw4zs9rFMC Lnp3CLSL0pcMfnh1wGitCFMWG2RpsB3FsoyDUvKMD8a6Z1xoUPmbjRnXJSIQFtm1njOp wyDcyYUBs7uqtYZk0ELmljGG9y+qxhtnWmtvSXRMyKzVUAXqkMhhdMqok/o+TU+Vg3Uj nK7sHMcivVp5z7vfQvyLSYEPG4NsnTNBcOvKekS5Riye3IKCMTfeDVxlGwsKNN0y7lUW 8YnqTTq7TZLSxpAbM0cu7oZtCMubiErYZpXt8QGrDqWsykVvJngm5MQ2K4E0apxXkbVf os7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IjW4QxnT; spf=pass (google.com: domain of linux-kernel+bounces-14625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d1-20020a656b81000000b005cd88c7204dsi20716974pgw.893.2024.01.02.08.59.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 08:59:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IjW4QxnT; spf=pass (google.com: domain of linux-kernel+bounces-14625-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 558A0283C78 for ; Tue, 2 Jan 2024 16:59:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFFAA1548E; Tue, 2 Jan 2024 16:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IjW4QxnT" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB45114F93 for ; Tue, 2 Jan 2024 16:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-5f07f9d57b9so22344447b3.1 for ; Tue, 02 Jan 2024 08:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704214726; x=1704819526; darn=vger.kernel.org; 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=/kfSvqUQhDDQeZ7w9vi8u82O1MW4zk5hhfYcLpsRKrM=; b=IjW4QxnTXys2dTHJsWz38eoLZWSaTE6apxTe+eRi13iJVSEIpVTfydtj6hFTLJQWk9 hKhWJ1i5+qzO2M6z78Mzpbcugv6JUEw/jgsggi/7zhARANmBS77lJj0qXZuquQCuziKk fa8uy3t65HJs8x7QkOWfra5YfWOW5A3YJi36R1JWFJNKLrNSfX9SNikxKyFwtmWIomHA BXbxTyx0Pe7+hAur9pIVN2EKygtbHh1G/zdgXvveQb5sxW8tp17fYMl/PtLN7kiKgn/u YsTl7QNjZwME/8YRVEVWJ2mt4pI1NHwWqOVzfshJoKE7GhTwQ7HpXZ8ggVVqY9bea06T LK0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704214726; x=1704819526; 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=/kfSvqUQhDDQeZ7w9vi8u82O1MW4zk5hhfYcLpsRKrM=; b=UT+7aZasBtsU38h7kX0Fh1YUJ4aS9hnqM0gRUGTw96rggSkwvKzDKbXemT+QfrjHFb JP30AoGbtILI1whog1tOOnlUEh9b04h37/fT3xhCMSAYIfvKyFvhmEbiqo1kIZrunuBQ FhTAwxfzX+tHH25zzf1eSeGnM9cQRRHOdYTvm8gt8Acw1hYSIUNjDXdnCXv5kdgLdejI v7swOX5fiUAJTheeNCSYudCgInkxOmhmY+snyg+RDoS4cjtsnbkOIiGXG5mipfucLmIH hLctTbLSe6QjdGCTVFannyBeRo0mVm2zHobCg51ekzdCD5KgAxL8a8nKFJSpe5oPXEE0 xkIQ== X-Gm-Message-State: AOJu0YwystjEOsDRpRfznj1NulUhEViiN4Xgw0uAw/k43zR0tuJUWrlK jMET5vAwF3kUYL/86Y3nmcfUU77QhL7nOcxTdAo2BPnSpYfT X-Received: by 2002:a0d:d2c6:0:b0:5e7:cd6d:b6da with SMTP id u189-20020a0dd2c6000000b005e7cd6db6damr11272113ywd.47.1704214725685; Tue, 02 Jan 2024 08:58:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231230025607.2476912-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 2 Jan 2024 08:58:33 -0800 Message-ID: Subject: Re: [PATCH 1/1] userfaultfd: fix move_pages_pte() splitting folio under RCU read lock To: Peter Xu Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, lokeshgidra@google.com, david@redhat.com, ryan.roberts@arm.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com, jannh@google.com, zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 1:00=E2=80=AFAM Peter Xu wrote: > > On Fri, Dec 29, 2023 at 06:56:07PM -0800, Suren Baghdasaryan wrote: > > @@ -1078,9 +1078,14 @@ static int move_pages_pte(struct mm_struct *mm, = pmd_t *dst_pmd, pmd_t *src_pmd, > > > > /* at this point we have src_folio locked */ > > if (folio_test_large(src_folio)) { > > + /* split_folio() can block */ > > + pte_unmap(&orig_src_pte); > > + pte_unmap(&orig_dst_pte); > > + src_pte =3D dst_pte =3D NULL; > > err =3D split_folio(src_folio); > > if (err) > > goto out; > > + goto retry; > > } > > Do we also need to clear src_folio and src_folio_pte? If the folio is a > thp, I think it means it's pte mapped here. Then after the split we may > want to fetch the small folio after the split, not the head one? I think we need to re-fetch the src_folio only if the src_addr falls into a non-head page. Looking at the __split_huge_page(), the head page is skipped in the last loop, so I think it should stay valid. That said, maybe it's just an implementation detail of the __split_huge_page() and I should not rely on that and refetch anyway? > > -- > Peter Xu >