Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (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 CF27A285CA9 for ; Wed, 4 Feb 2026 03:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770174741; cv=none; b=NomCW0GA8Jp/pqax3cZPmIcLe2NrUKWZD4Tgmfh3uycQI9ym0mnk9o73Xgu2+Rqghx6FW9fhbFW5WCUGC9JiIPvma9Un+Mcu1s04haxer7AuC2Pyq6DAtwwAHsKZt0mx96SIjVQtYsDZ5rCmHZ2HXy2Pp+cj3/N3uwErZxye+T8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770174741; c=relaxed/simple; bh=3Zee9sTAl4YrKdv4kZlUL6iGNo2OnUcLLkIeWRTbuZU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DIrtA35aGK7QK2XRGNSxr6Hj1MK72Q8SB4HtC/BbEjb4ktK0M4LL8Wj9bb4FKSVF2yFDVVeTDMrfZxjwq7smWS530TcrR2YPLTuPG/kINalSRLbzozNROBdkl/ah/n4A9lFaHpMqJgkM6fszn3jphDhligQEnaR2zjHBDaejYaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=AIRLMWUu; arc=none smtp.client-ip=95.215.58.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AIRLMWUu" Message-ID: <2d4ea6ad-783a-4b0f-9cba-4f04fbefed45@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1770174736; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k9Ml/Qa1uGTXylqlpdcLLmiqL24y9FMnNekGf9gASGs=; b=AIRLMWUu7nO5IgXUHojK/xI1o7u1JdCcpt2yLPOD1aPS5q9bkd1Np4eUQRO7dXeSAbi4jw FaAAfSG1SGBdJegCvAxk4BNCJ1OV2WBvZtZuPDAkTsFS2Ip4Q2jS63ZKWNC3x7+QEb6mpv L5ze2A3NCxYmVw9ymJtbUnE/eQI07lw= Date: Wed, 4 Feb 2026 11:12:04 +0800 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [Patch v2] mm/huge_memory: fix early failure try_to_migrate() when split huge pmd for shared thp Content-Language: en-US To: Wei Yang Cc: linux-mm@kvack.org, ziy@nvidia.com, riel@surriel.com, lorenzo.stoakes@oracle.com, david@kernel.org, akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, gavinguo@igalia.com, vbabka@suse.cz, jannh@google.com, stable@vger.kernel.org, harry.yoo@oracle.com, Liam.Howlett@oracle.com References: <20260204004219.6524-1-richard.weiyang@gmail.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260204004219.6524-1-richard.weiyang@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/2/4 08:42, Wei Yang wrote: > Commit 60fbb14396d5 ("mm/huge_memory: adjust try_to_migrate_one() and > split_huge_pmd_locked()") return false unconditionally after > split_huge_pmd_locked() which may fail early during try_to_migrate() for > shared thp. This will lead to unexpected folio split failure. > > One way to reproduce: > > Create an anonymous thp range and fork 512 children, so we have a > thp shared mapped in 513 processes. Then trigger folio split with > /sys/kernel/debug/split_huge_pages debugfs to split the thp folio to > order 0. > > Without the above commit, we can successfully split to order 0. > With the above commit, the folio is still a large folio. > > The reason is the above commit return false after split pmd > unconditionally in the first process and break try_to_migrate(). > > The tricky thing in above reproduce method is current debugfs interface > leverage function split_huge_pages_pid(), which will iterate the whole > pmd range and do folio split on each base page address. This means it > will try 512 times, and each time split one pmd from pmd mapped to pte > mapped thp. If there are less than 512 shared mapped process, > the folio is still split successfully at last. But in real world, we > usually try it for once. > > This patch fixes this by restart page_vma_mapped_walk() after > split_huge_pmd_locked(). Because split_huge_pmd_locked() may fall back to > (freeze = false) if folio_try_share_anon_rmap_pmd() fails and the PMD is > just split instead of split to migration entry. Restart > page_vma_mapped_walk() and let try_to_migrate_one() try on each PTE > again and fail try_to_migrate() early if it fails. > > Signed-off-by: Wei Yang > Fixes: 60fbb14396d5 ("mm/huge_memory: adjust try_to_migrate_one() and split_huge_pmd_locked()") > Cc: Gavin Guo > Cc: "David Hildenbrand (Red Hat)" > Cc: Zi Yan > Cc: Baolin Wang > Cc: Lance Yang > Cc: > > --- Confirmed that the splitting is working now as expected with the reproducer above. Tested-by: Lance Yang Also, looks good to me: Reviewed-by: Lance Yang