Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9D4693A900B for ; Wed, 4 Feb 2026 19:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770234138; cv=none; b=h0o08nZYUCiSh//1VcjswRs1rLZS3ns6x6nsvFyouHQZcq5n1kFsjpDOfq7epUm4boFvz+U4hV7aJrM0+nHsbXjXrpI1MC33jQgfDnJRb417Duoq2N9zrYlJ5yBsy6va0UrwGS397ntvPbUlVGru3SX6cEbmFGB2ehdyZyRE1hU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770234138; c=relaxed/simple; bh=0TzhdRBQGftv+E99NUPcByUdvUYMke8M4HMH54RM9zg=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=nU1uo2JwgXKSvefsfur+uODKNM6g+xBnr7GcnjeJOosPUCazs8pul97twtTrWuUP9PaUdThhKSQzcdIbIKWj5UxVzWyG2cHpACCJd+va9cGK8vBiN6okPb2dhbNoU2OQtsnd3RU91D2Vzv+6Fug8nTJUJDk5uksqYAaNsLhBh8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=v8BIrl7o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="v8BIrl7o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1089C4CEF7; Wed, 4 Feb 2026 19:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1770234138; bh=0TzhdRBQGftv+E99NUPcByUdvUYMke8M4HMH54RM9zg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=v8BIrl7ot6Or7V27kK7fHjxxDPkk6dg3sSHtxaj6MYNdSXzwlhiaV/WGHgRWsmD0v sW/9/7fw85Eyd4DNe0zXQmpx+WkDFqfxmgd07HVqJpyT019wqbbNIt/R3+l3Rhx8nv o+98W/XFjQP4ZFBUCXLAhHNxug4/3TZGbCzzSlC0= Date: Wed, 4 Feb 2026 11:42:17 -0800 From: Andrew Morton To: Wei Yang Cc: david@kernel.org, lorenzo.stoakes@oracle.com, riel@surriel.com, Liam.Howlett@oracle.com, vbabka@suse.cz, harry.yoo@oracle.com, jannh@google.com, ziy@nvidia.com, gavinguo@igalia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, Lance Yang , stable@vger.kernel.org Subject: Re: [Patch v2] mm/huge_memory: fix early failure try_to_migrate() when split huge pmd for shared thp Message-Id: <20260204114217.6da3e05ee5fbfac3a5f4c16a@linux-foundation.org> In-Reply-To: <20260204004219.6524-1-richard.weiyang@gmail.com> References: <20260204004219.6524-1-richard.weiyang@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 4 Feb 2026 00:42:19 +0000 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()") Cool, thanks. > Cc: Gavin Guo > Cc: "David Hildenbrand (Red Hat)" > Cc: Zi Yan > Cc: Baolin Wang > Cc: Lance Yang > Cc: Why cc:stable? In other words, what is the userspace-visible runtime effect of this bug?