From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384021; b=xTFeolBtSixG8ZBc7NErt4wlOBsLTrbzyUFyCPldhkExgteSP5kUdQvh7Ww1zkyFoLlo PaSoRlZT4usgPggZS7g4CkRHrlKyag2NnXNETUJr4a91Ro1VA/Wa4wMrPZBYkj3eXo7bl JxtgCpe807a2dbw+KWhEOAa2Tbt2QpRuOZJJsH2GegxF7HpIEJaA2OFPW2HaWcg9HVHcC PwcQ8dRR5XJxt4R5G6TN2Jezw51NTkUO0ub/FM9EzEzqmfjmIdR69MmI2fRgO+ZhhNdrQ fUP+QBaiYLNPxS2iIr/2ZYImSDenrnizMyzhOuKwQfk15wMuSXtepqkL5wT2s7fyW+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384021; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=2mwA2N9ujUxnQosEWrtkO8YMDxy9B2CpJn+fzJWbfiE=; b=NGQi+kdG/CjjRBBAp5hDJ4oCW6OvLFrmt1lSDT4do2arTdhNO/byNJKyulB3lXqE8aHE no4TOzP3V5VGBMWS1MZgEvryzYXNnGGdijQLmzkJaA+udtdpAUrL40FtkiGh0uvhRtwYV mbWhmTRYJY1ppp/w8t/A8PqfHyYdAl5nZjWI2RtUJMh37HuTfmKCYIan84+/IScHeaMsJ p9YhP9StJldyoql2Hziwf7beuuS2oC2UiqoCHCCJoUufarulLsShRjBqpltq2QBmysyYR pt2xlNA/Ag7npMBYDyVRPUq/4neomp+72t/PGqUTNL7ZxhWSJ/QXA9+F71jRwHq8ZbA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=pGnMJCVb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20724606A322; Fri, 4 Dec 2026 11:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=pGnMJCVb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 965C61F000C2; Fri, 4 Dec 2026 11:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384021; bh=2mwA2N9ujUxnQosEWrtkO8YMDxy9B2CpJn+fzJWbfiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pGnMJCVb5ySzTWRhT+N7MnGG9ECF1OKp7St4uqdhz30A3B0JZ7HIN941i/TG3zjDe v3Qrp5Xj9xmi40YLMrQQw+WYEgMU/ldJTZhoM69wX0GNfghDxGW4G8vkK1UwHr5BPo PdqDwD4JcIJTFzGpI1ROsQPRePO9CUrHgS7kEqwI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , "Lorenzo Stoakes (ARM)" , Hugh Dickins , Zi Yan , Zach OKeefe , SJ Park , Baolin Wang , Lance Yang , "Kiryl Shutsemau (Meta)" , Pedro Falcato , "David Hildenbrand (Arm)" Subject: [PATCH 6.12 422/555] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Date: Fri, 4 Dec 2026 19:07:45 +0900 Message-ID: <20261204100625.804188232@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Hildenbrand (Arm) commit 043a2260b96ffc13121a1dd65282e67eb2e1d8a8 upstream. madvise(MADV_COLLAPSE) can map PMD-sized pagecache folios that are not uptodate. For example, shmem fallocate() can put such folios into the page cache. collapse_file() already refuses to proceed with folios that are not uptodate. Let's just do the same in try_collapse_pte_mapped_thp() and skip such folios, leaving handling to the page faults. Note that collapse_file() effectively clears shmem folios through shmem_get_folio(); let's keep this fix simple and simply let the page fault path deal with that. Fixes: 34488399fa08 ("mm/madvise: add file and shmem support to MADV_COLLAPSE") Reported-by: Chris Mason Cc: stable@vger.kernel.org Reviewed-by: Lorenzo Stoakes (ARM) Acked-by: Hugh Dickins Acked-by: Zi Yan Reviewed-by: Zach O'Keefe Reviewed-by: SJ Park Reviewed-by: Baolin Wang Reviewed-by: Lance Yang Reviewed-by: Kiryl Shutsemau (Meta) Link: https://patch.msgid.link/20261105-set_huge_pmd_uptodate-v1-1-a78d8a1b7117@kernel.org Reviewed-by: Pedro Falcato Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Greg Kroah-Hartman --- mm/khugepaged.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1547,6 +1547,12 @@ int collapse_pte_mapped_thp(struct mm_st goto drop_folio; } + /* Leave any uninitialized folios to the page fault path. */ + if (!folio_test_uptodate(folio)) { + result = SCAN_FAIL; + goto drop_folio; + } + result = find_pmd_or_thp_or_none(mm, haddr, &pmd); switch (result) { case SCAN_SUCCEED: