From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6451C02198 for ; Tue, 18 Feb 2025 07:24:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53AB92800E9; Tue, 18 Feb 2025 02:24:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E9DD2800E4; Tue, 18 Feb 2025 02:24:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38A2A2800E9; Tue, 18 Feb 2025 02:24:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 169A32800E4 for ; Tue, 18 Feb 2025 02:24:14 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8102B807C1 for ; Tue, 18 Feb 2025 07:24:13 +0000 (UTC) X-FDA: 83132226786.28.40ADF51 Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.6]) by imf20.hostedemail.com (Postfix) with ESMTP id A43461C0005 for ; Tue, 18 Feb 2025 07:24:10 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=DlmEPedK; spf=pass (imf20.hostedemail.com: domain of yangge1116@126.com designates 117.135.210.6 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739863451; h=from:from:sender: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:dkim-signature; bh=ZJscg99EXRdekigVGw2UnRJFfVqZBq30pvvZtMt7gLg=; b=KlCEyBCj/zYYgkyBrKK/JcMgKlGaBhhohdwmxVphzVDqWhnkS6LmEWtVAFuzTKll++O33x 1uzEqJTWLQkPlgquNu/z4s1r4m1qD8iEYTlH1DnQlGg+de0urrXtJRbggLDnBDtOe29z6x b5ekWxDdTn53Uu0tlFFEJVsz1igWSB8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=DlmEPedK; spf=pass (imf20.hostedemail.com: domain of yangge1116@126.com designates 117.135.210.6 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739863451; a=rsa-sha256; cv=none; b=6TJgbbhf8JZvf27/ugh7Kq39jurYpaX2zhxQYdOSD3GwMRdTsbLFAwpBcjj05TWNNoHFjF v1QIzClqgLobZ7Crr5XoreJ1CaQfuBVgXpNIbdJI2zMp0i3fwNALmcbLK3BsNf+zuL49Om 1XqfoOHC3OEXv+swUvcuM43uJqvJHFM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From: Content-Type; bh=ZJscg99EXRdekigVGw2UnRJFfVqZBq30pvvZtMt7gLg=; b=DlmEPedKd1MgySe1dQhnY1hyC8nAYKX/Haiu/nGNY+nkDGsrjZ1dZe7iYVGMaT qMm5oT9Bz4npiZjA9JwCTy132xPlw8Xcin82DQR0SsYLdCHehSSU9N6GrzH8A6jW etZxIC5V+NeZCovSPHLLFWyle2nmtd6Af5uoD7adnRRWM= Received: from [172.19.20.199] (unknown []) by gzga-smtp-mtada-g1-4 (Coremail) with SMTP id _____wD3twWSNbRnMZhbBA--.38403S2; Tue, 18 Feb 2025 15:24:03 +0800 (CST) Message-ID: <1ea2c7b0-790c-4f60-a713-9029252a0837@126.com> Date: Tue, 18 Feb 2025 15:24:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2] mm/hugetlb: wait for hugepage folios to be freed To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 21cnbao@gmail.com, david@redhat.com, baolin.wang@linux.alibaba.com, muchun.song@linux.dev, osalvador@suse.de, liuzixing@hygon.cn References: <1739604026-2258-1-git-send-email-yangge1116@126.com> <20250217203417.9689a271f792a4e23da322aa@linux-foundation.org> From: Ge Yang In-Reply-To: <20250217203417.9689a271f792a4e23da322aa@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3twWSNbRnMZhbBA--.38403S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar48uF4UCrWUArWDWrW3Jrb_yoW8tr1rpF WUKr47GFWDJr9akrnrXwnY9r10krZ8ZrW5Gr1Iqw13uan8Jr1xKFyIywn0qay5Cr10krWI qrWjvw1DZF1UA37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjOJ5UUUUU= X-Originating-IP: [112.64.138.194] X-CM-SenderInfo: 51dqwwjhrrila6rslhhfrp/1tbifhn3G2e0I135pQACs4 X-Rspam-User: X-Stat-Signature: 685t65mmfctjtf9n6xk3c51iaockoxzx X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A43461C0005 X-HE-Tag: 1739863450-303900 X-HE-Meta: U2FsdGVkX18/BUcPxaosx0A5BYntroDbT8xlXO4plMMPeADMvuPS5cgwxOSv+jo83TWiZ534D/wlU9QB+TtJZ+jEnQ4Ies0dcQz2jTbzWVjAi0NhQgTsIQz1C5w+prB1R0Q2biHEGHOhNbtogFnJ0+fp9sZ7H/fEsNIa/4hVjnGEqSte37TYRQ/yO6XdWGnuhEDUlXFziaZCwNDHg/7y+Y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IIO64w2/Le0GX5OkRKjAykaDHKy8bvKbToNMk3DxdpWU0LRUTC1214DyUPSBod3mOoHKOsfMJtjSWzCQIn6782pXLQSJ23QuU8qfzprFx1vvuhw9KvL5MF9QQ8MI X-Bogosity: Ham, tests=bogofilter, spamicity=0.005113, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 2025/2/18 12:34, Andrew Morton 写道: > On Sat, 15 Feb 2025 15:20:26 +0800 yangge1116@126.com wrote: > >> From: Ge Yang >> >> Since the introduction of commit b65d4adbc0f0 ("mm: hugetlb: defer freeing >> of HugeTLB pages"), which supports deferring the freeing of HugeTLB pages, >> the allocation of contiguous memory through cma_alloc() may fail >> probabilistically. >> >> In the CMA allocation process, if it is found that the CMA area is occupied >> by in-use hugepage folios, these in-use hugepage folios need to be migrated >> to another location. When there are no available hugepage folios in the >> free HugeTLB pool during the migration of in-use HugeTLB pages, new folios >> are allocated from the buddy system. A temporary state is set on the newly >> allocated folio. Upon completion of the hugepage folio migration, the >> temporary state is transferred from the new folios to the old folios. >> Normally, when the old folios with the temporary state are freed, it is >> directly released back to the buddy system. However, due to the deferred >> freeing of HugeTLB pages, the PageBuddy() check fails, ultimately leading >> to the failure of cma_alloc(). >> >> Here is a simplified call trace illustrating the process: >> cma_alloc() >> ->__alloc_contig_migrate_range() // Migrate in-use hugepage >> ->unmap_and_move_huge_page() >> ->folio_putback_hugetlb() // Free old folios >> ->test_pages_isolated() >> ->__test_page_isolated_in_pageblock() >> ->PageBuddy(page) // Check if the page is in buddy >> >> To resolve this issue, we have implemented a function named >> wait_for_hugepage_folios_freed(). This function ensures that the hugepage >> folios are properly released back to the buddy system after their migration >> is completed. By invoking wait_for_hugepage_folios_freed() before calling >> PageBuddy(), we ensure that PageBuddy() will succeed. >> >> Fixes: b65d4adbc0f0 ("mm: hugetlb: defer freeing of HugeTLB pages") > > Do you feel that this issue is serious enough to justify a -stable > backport of the fix? Yes, I will add 'CC: stable@vger.kernel.org' in the next patch, thanks.