From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793606866; b=GhRZ8iVlIwMC5JTzvpCXSf8ElzIZoyhEKC7XZ6UrKAPcJ9bajt9Mg7SMwLhowlYWSIQ6 /JaKyKSCigSxnXR2nvAvCkzNfWRXXvpWczsPeq9tbjT5LaVFbu8BuihiH2FlaCOrz+79e 65wv9WacMJJQ5U315aP6BfggDnGST3AmISPtOtICwG09ddx0bgOqLdjCYJa9ILRzmWPCB FFfQ73iIJ7iknrACeYbIYxUX2RF6o1NnT2x5IR+GJym6iSskaKoHxC7iOamqcwUVcMnUX PMqqn9S79XlWxlKsnVACCOTedbsm50Doz2HBCL6/uyhyEzRYGETerxB/Vg5vzzPVy4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793606866; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=RmW9W+b2NUCMbTNqn6LeM8cKiTUqHkz3gaeuB+SxxjQ=; b=uqv17UACnoLhSXxz+UlXLtN6ZQHnLMVuqIE950KvVbTfmR3IV00wapqDKY69zkQrRonm TnHQFKkqUejWn5C7Yn9bI4ivzyMwlR+e1lgvOEVWJeaW60+NGWe8kQ4wn7OuCKgpnq9Je ssV6R3xp5ovPzkIY/01LnSkjBj2Eh0tfC1lcbL1OL6kCPf68plh/m53bzcabyVD5LY6Zj H2ajRvaalU2ZsfZJNBAu64kiwDth43p8RuzXdBnc8xktkCSiMn0mV67Iwi+mgnMgrfPSt B24we/J6MaHv0UI8BaY4f4El/v1/dKvfWG5UCHsg24TEDwXRVuCLLb6is2vBUy5dP7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tnmzTSqr; arc=none smtp.remote-ip=95.215.58.45 Received: from mta1.migadu.com (out-45.mta1.migadu.com [95.215.58.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6CE9606A33D for ; Mon, 2 Nov 2026 08:07:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E6CE9606A33D 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tnmzTSqr X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=VFK7vMxbPR50n7fFLwXWLZ6ZPyv6K4TCi+2Re4RLgtA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793606862; v=1; x=1794211662; b=tnmzTSqrsxUQkb2Ygb/cunZg4/OUqK6lMcAvJ0bQ7Es69dTB9ZtIaSWepDAbbVg70L7cpC6f V1JdH5YEhU0YdyJOo/OdoN6Kk3QzYgnGNo5mWmNFybxDGnbMDNC8TevzmkvMqfTctpYJT0lpmgr g9XjIsaSGBn+f1SHLI0M2a+k= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id ab74e95e87cc3cd0; Mon, 02 Nov 2026 08:07:42 +0000 X-Mizu-Trace-ID: ab74e95e87cc3cd0 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Mon, 2 Nov 2026 16:07:33 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] mm/hugetlb: Preserve persistent flags when returning folios to the pool To: Kaitao Cheng , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Mike Rapoport , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt Cc: Mani Tofigh , Zi Yan , Mike Kravetz , Baolin Wang , Miaohe Lin , Naoya Horiguchi , Frank van der Linden , Chris Down , Joshua Hahn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Kaitao Cheng References: <20261102024910.31486-1-kaitao.cheng@linux.dev> <20261102024910.31486-3-kaitao.cheng@linux.dev> From: Qi Zheng In-Reply-To: <20261102024910.31486-3-kaitao.cheng@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/2/26 10:49 AM, Kaitao Cheng wrote: > From: Kaitao Cheng > > add_hugetlb_folio() returns a folio to the HugeTLB pool when vmemmap > restoration fails. It clears folio->private and restores only > HPG_vmemmap_optimized, losing other flags that must survive the rollback. > > Clearing HPG_cma causes a later free to bypass the CMA release path, > leaving the CMA allocation bitmap set. Clearing HPG_raw_hwp_unreliable > loses the indication that the locations of poisoned subpages are unknown, > undermining the checks that prevent freeing or unpoisoning such folios. > > Preserve the existing flags instead of resetting folio->private. Callers > already clear HPG_restore_reserve, HPG_migratable and HPG_freed before > returning a folio to the pool. Clear HPG_temporary in free_huge_folio() > before attempting to free a temporary folio, so a failed vmemmap restore > does not leave that flag set on a folio returned as surplus. > > Add a VM_WARN_ON_ONCE_FOLIO() check for flags other than > HPG_vmemmap_optimized, HPG_raw_hwp_unreliable and HPG_cma to detect > incomplete transient flag cleanup. > > Fixes: 161df60e9e89 ("mm, hwpoison, hugetlb: support saving mechanism of raw error pages") > Fixes: d2d786714080 ("mm/hugetlb: enable bootmem allocation from CMA areas") > Closes: https://sashiko.dev/#/bug/linux-5363eb09-9c3c-4f8b-9f3c-a998a8c4b258 > Suggested-by: David Hildenbrand > Suggested-by: Muchun Song > Suggested-by: Zi Yan > Signed-off-by: Kaitao Cheng > --- > mm/hugetlb.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) Acked-by: Qi Zheng Thanks, Qi