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 5A0F5C369A2 for ; Thu, 10 Apr 2025 00:51:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5AAF2800BB; Wed, 9 Apr 2025 20:51:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D097D2800BA; Wed, 9 Apr 2025 20:51:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF81A2800BB; Wed, 9 Apr 2025 20:51:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A31342800BA for ; Wed, 9 Apr 2025 20:51:08 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BBEC4C14D7 for ; Thu, 10 Apr 2025 00:51:08 +0000 (UTC) X-FDA: 83316305016.29.098BA5E Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf19.hostedemail.com (Postfix) with ESMTP id CA19A1A0005 for ; Thu, 10 Apr 2025 00:51:05 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744246267; 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; bh=NTO5PniWFflrvX7vlGin1FbtPQAkwyy5kqmrQjD3r8A=; b=bRVKPdXkt0fTfEI7IsERqf6+MNRE6fdEfAJsmFx3h1VSU52RT05aW8K4+IGw3um8D4NWCN //UGxodM2yv0dHbEU70VhpvFeL9UDMCbZi1M0QPvdU4pG0GDNfg8Mn43JSunbEL3oRQaHx kTFdlsmMUuL6goa9XSAOX5IJvTd1o/o= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of mawupeng1@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=mawupeng1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744246267; a=rsa-sha256; cv=none; b=o4W+i30LFOsM+VpsyIqIPOzLRI9dxrEGCBV7W8HiMDeBdWEpFComxJqZXPLoCfUaWnTtPT 8k+ryFKwAR7l0XtJWNUxMEFyLuRFSfiGu57aL2JQfQVoHEBBAvBuLeXjMjAO/Cb/XZCRS/ Ec3VfVpWAS2+kBl5WayZ+Ue8/co8ykE= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4ZY1V63086z27hRG; Thu, 10 Apr 2025 08:51:42 +0800 (CST) Received: from kwepemg100017.china.huawei.com (unknown [7.202.181.58]) by mail.maildlp.com (Postfix) with ESMTPS id CD8A91400CB; Thu, 10 Apr 2025 08:51:01 +0800 (CST) Received: from [10.174.178.114] (10.174.178.114) by kwepemg100017.china.huawei.com (7.202.181.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 10 Apr 2025 08:51:00 +0800 Message-ID: Date: Thu, 10 Apr 2025 08:51:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , , , , , , Subject: Re: [RFC PATCH] mm: hugetlb: Fix incorrect fallback for subpool To: References: <20250409135843.2012726-1-joshua.hahnjy@gmail.com> From: mawupeng In-Reply-To: <20250409135843.2012726-1-joshua.hahnjy@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.114] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemg100017.china.huawei.com (7.202.181.58) X-Rspamd-Queue-Id: CA19A1A0005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: mwc41wbtwujrtsn8mpusumjii7anjfod X-HE-Tag: 1744246265-275974 X-HE-Meta: U2FsdGVkX18QafigRXEumLG8htPFXD4paEaf7DhCWZP+tBpmt+vhg48QPHlA/QF7I/vLa0dATIzBCoetMvZ/dN+Mkr66TDSVZzGr8J50X8seRi+MVfPw5nyphTtTIWZc4lGiUqOFPH13psbKOGwnm5Xf7FIayl9dPGzNijDfc5sqfX6PhL+yrhhBpb3G6G+BznF+TVU0ceP63OV7vnj9yi//1e+S43S2UNSNi6HjwGeH0k7+HVqJF3QsK8Zj1k3ZWmRbt0EYgxoimZLQX5yjRpDQ3lHdki0yLPBek6yUkzes+aeNgiIBLhqrVhD7xQxgU+tvKM30Uj56b+8m2EOI0L82K4ooaL6Wq2SkHUBuW6KR1vn7SDexzhqcv1nfHak2icqAz5xkJW/z7TOt6sYLuaDktgmEjePWbzHRcrptKuIOVtbQzGvjuU4Yb5cfTqVUmnyidKscUIsUHtzLVt+og1CSjdk/Genpw/nbWf13Jztb8eu0qBhWfdZuI4j7Y/Xg4O64SwyJS+xI8g3DRjeS8fiwqPUnhGGM6wmiqbuk8mqsnPL5zz0aQQPIwfc1yM08+h+4a9ZobIPJn/IXtvZzKfkJ513TSTRRURy1JV33Dzen/N5EWOzjBQj8gKR/zP9bN/YOtXREZ8Fq15ht7rBTYQXGDko35dyoqcSQM15HYMEmUmr/5V/ozlocAC2fNfPpmNfDzpHz4WNp7AVEzaJFWdIYvHwvXjDcZoI5ei8unn8bOPUhZUu8Wd3UeNnVwDr3LPhaWM0tzzfLWYloswUgFFWeomTwNK2/LLBXszH4QgaPvuNGA+MSsnwnGHxrwLTM3k5wEjjNOd6sIUo+XbQSGbnH5dpFUsfwYU44fPSeud4ArRJyUX0jTkJFzXXAh3/VeU04fL5tQ32GJ0v5EHVVRd7491gcNF5i1WUEfi9in6MJC9TX4j1vwDzj1eL8Dz5JN91dR98Hhy1uNguTX6A ko0EVi4C HHAMOTG5JmLht0dbferSUVxJ1Vf9kXIhxaHSecWFFrvYnfWCl3mKcgWOIu1lExDK9eSgOiQpbcFFM5ksiCK8DW/xmxk6AJPWc+kGR6Bs2AwQO6K0lkwFvmiLK0/WNROzWV5kixPfxdUnGIAqvLC/X/QObgsRJyZYgNYFMOBpUiQcqZjgqXMUKVUhJqSPXQJW+rF7xq5oEYcCK5s52Q6oVYysA4hJysSeaFJWjpCsS2LSMhXovLVlHTCeJkVo28RKbAZHC X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025/4/9 21:58, Joshua Hahn wrote: > On Tue, 25 Mar 2025 14:16:34 +0800 Wupeng Ma wrote: > >> During our testing with hugetlb subpool enabled, we observe that >> hstate->resv_huge_pages may underflow into negative values. Root cause >> analysis reveals a race condition in subpool reservation fallback handling >> as follow: >> >> hugetlb_reserve_pages() >> /* Attempt subpool reservation */ >> gbl_reserve = hugepage_subpool_get_pages(spool, chg); >> >> /* Global reservation may fail after subpool allocation */ >> if (hugetlb_acct_memory(h, gbl_reserve) < 0) >> goto out_put_pages; >> >> out_put_pages: >> /* This incorrectly restores reservation to subpool */ >> hugepage_subpool_put_pages(spool, chg); >> >> When hugetlb_acct_memory() fails after subpool allocation, the current >> implementation over-commits subpool reservations by returning the full >> 'chg' value instead of the actual allocated 'gbl_reserve' amount. This >> discrepancy propagates to global reservations during subsequent releases, >> eventually causing resv_huge_pages underflow. >> >> This problem can be trigger easily with the following steps: >> 1. reverse hugepage for hugeltb allocation >> 2. mount hugetlbfs with min_size to enable hugetlb subpool >> 3. alloc hugepages with two task(make sure the second will fail due to >> insufficient amount of hugepages) >> 4. with for a few seconds and repeat step 3 which will make >> hstate->resv_huge_pages to go below zero. >> >> To fix this problem, return corrent amount of pages to subpool during the >> fallback after hugepage_subpool_get_pages is called. >> >> Fixes: 1c5ecae3a93f ("hugetlbfs: add minimum size accounting to subpools") >> Signed-off-by: Wupeng Ma >> --- > > Hi Wupeng, > > I hope you are doing well! It's been a while since this fix was sent in, and > there hasn't been any comments on the test either. Would you consider sending > this patch again without the RFC tag? I think that might help in the way of > moving this patch forward : -) Ok, I'll resend it without the RFC tag. > > Thank you again for this fix! Have a great day! > Joshua