Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6424956rdb; Tue, 2 Jan 2024 01:00:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnOU42L7nAIrtWyjreWUrF6YSdxEjnoVd/hkQS8pULTP5qSeamUA9SQqHsqv/cPmjc0dpk X-Received: by 2002:a05:620a:81d:b0:781:5a40:3f42 with SMTP id s29-20020a05620a081d00b007815a403f42mr12061435qks.51.1704186027212; Tue, 02 Jan 2024 01:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704186027; cv=none; d=google.com; s=arc-20160816; b=FlmcFkogj9UTfXbIPTmf6XFBd7EVojxGmqa2Bg0pIMLjBr+en/Wfyx1+LrRNvmweck F2pVaMSe1i9A0eTYkC0Zsj1L1eWWnoZxQUpL1ffPB2WLK782uW4+Dvn6PGTxWk6dzibg WSAvyakhh9Ox2k+Yj7js0m4NHqbKlY+xlpe/OqwGQCUcwbuIzU4W8YXI21OZU07YVGqW CpYJ6jdNpewNwoGpA9I0SPGcIZAirCoF7UpNv2CbzeBbjXRRliwNnZZKLaTX2gSHDX8J 4sVgfVvUcerPcLoGFbkLpn64jsivqCBnPZBJie+s2my8ItD/5cX8wy6v8ujiIf7jh35R Yiug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7hTQmZh5y3zaYz7umyfdjLpp6zXbUTP3L2zYpMTvo6c=; fh=TSdGmPMDkbsKMbjITigntLXI+lIi8On1qG9dW4vVC8c=; b=CIYeaSTglKf9kcAzQeQ9gMepPRGZl6tLa+k9PuF89HC1ca22KOqN70wVgOQXDHV7yQ jJkp7sUIyFpZ+JAvoNHg1S641LDgnJQCb+YccC9VDT4gUfWFLMNzWCSaSf9c9RBq/QHc K6FjtUp0p11f8/RwobGWyud/Je6zFhnu91319G9e0/BH1eGb0KAwcKh66+jxBaZXyyTn D38iUZt2ucFm6V8/1SDLxCLvVCzV8sOMTfINpiSzvweOmYDBDSHCcaDIDR3Y6DNe8I6W B8Q38A/3igsRlhF86IqSipTfuws/wG26u2US42Z9dR9kZ82d6HFY8S6cZjIAhmdK7ECL mFRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7juPMa4; spf=pass (google.com: domain of linux-kernel+bounces-14166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14166-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e3-20020a05620a014300b007815612003dsi15234181qkn.282.2024.01.02.01.00.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 01:00:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7juPMa4; spf=pass (google.com: domain of linux-kernel+bounces-14166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14166-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F2F961C215BF for ; Tue, 2 Jan 2024 09:00:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC3E163A6; Tue, 2 Jan 2024 09:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O7juPMa4" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97F5D5672 for ; Tue, 2 Jan 2024 09:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704186017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7hTQmZh5y3zaYz7umyfdjLpp6zXbUTP3L2zYpMTvo6c=; b=O7juPMa4XvRpglj4WLzcKDeuM5sNSAmfOnwR+iL+zU5WyArwC02KO1T32Dc6VvghGVNZGq l2XK+ICvnr8xn/JXBVNSocrNPjxv9GIoLgMEhJIJWQxirgpvR7dQT6853RZFqf5MvdwDHJ cdwrskNCsxmiBiEdXnZb+BO3pyFGGY4= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-X3d9sFLbO0qfZB6pvGCa7g-1; Tue, 02 Jan 2024 04:00:16 -0500 X-MC-Unique: X3d9sFLbO0qfZB6pvGCa7g-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-28bd331cb57so2766249a91.1 for ; Tue, 02 Jan 2024 01:00:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704186015; x=1704790815; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7hTQmZh5y3zaYz7umyfdjLpp6zXbUTP3L2zYpMTvo6c=; b=fUkoc7hGBBzCIa7rNlRDS9BhMbIZQRypd+Bo7frk+n7h6UVj6e1ilDU94umxiPZlD/ nztDeRinY+28Y6e7e40dEJfQ22Ev/hjLL4DMmxJkqUhRUBrWFftzG3tQ+KSS8OXPfi0q /wylS3ZmzKjMlQRPD0HauUf3oPhQnx13vYwBIXUj77Y/xu4IqIlZl3HvF2FZWjSiIZge tWnkYdgDu157IkeAs+RHY14SzBQ0MbUzhTjg+tVWvC7h/3FOaKRcaWLZdIRZJ+dyS9rF 0XALnJ48sIFV8zi0rd63J4aNUHlSI6BKXOx1Lb7/77xkM0eu6X/Kz5wtEQuAuAPRaSe2 H6cg== X-Gm-Message-State: AOJu0YxfZg+WabTOMHJ/gjtOJtDQBMJdirGouvlbKvBwhRi47S8litLT y8t6HlmKHzJ8GYmDeGk0Fd3wFWOzUsb85oH4KgK1Vk1v9EWu7yYlO1Jjl9AeLjgHQqSJhG0XXe8 +XIWX7yQAyERGmVoytm99gLiWEJaRNI4E X-Received: by 2002:a17:90a:bd17:b0:28c:113a:9678 with SMTP id y23-20020a17090abd1700b0028c113a9678mr23773678pjr.4.1704186015104; Tue, 02 Jan 2024 01:00:15 -0800 (PST) X-Received: by 2002:a17:90a:bd17:b0:28c:113a:9678 with SMTP id y23-20020a17090abd1700b0028c113a9678mr23773618pjr.4.1704186013844; Tue, 02 Jan 2024 01:00:13 -0800 (PST) Received: from x1n ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id w5-20020a17090a6b8500b0028bd0a43bc9sm24391031pjj.2.2024.01.02.01.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 01:00:13 -0800 (PST) Date: Tue, 2 Jan 2024 16:59:56 +0800 From: Peter Xu To: Suren Baghdasaryan 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 Subject: Re: [PATCH 1/1] userfaultfd: fix move_pages_pte() splitting folio under RCU read lock Message-ID: References: <20231230025607.2476912-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231230025607.2476912-1-surenb@google.com> 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 = dst_pte = NULL; > err = 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? -- Peter Xu