From mboxrd@z Thu Jan 1 00:00:00 1970 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 4C6D6350D5E; Wed, 21 Jan 2026 17:47:55 +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=1769017676; cv=none; b=i2c7kLB1B+w+YdWBFn10X/c56+eEUwT+i4hOMbgILe1jTN2y8D9EImWKWkLh+jUmyEetMtDL56+v0sAfYz3WlOxz4JPapx1LIkSzjN3sHfpMGMsR6VgWmxdvAlfW0tpmeWDSG45LhSMaNzUnkx8QeXbFMzgv3KOCOb82dFB/laY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769017676; c=relaxed/simple; bh=rap4vjdO701PMJ0MSSHR1FJS63P4Y/x0kEK7INx+cP8=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Fsm7Z9O3QyImQZdWY7XppnbRmIyUVBZrFn+qgf1wLD1EJbbvEFJm3CrBPt15UwucpkJCtUQt9B4kWFOPN9k4EiQSW3g4blz73MWcuoe5ObCYeKC5YcFm4vk4Fpj2Y4jRrH+aTX/B5lVkLx6GKR4o31g9FFpl0NxOgw1Mw4gcH0I= 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=qNVl0Pce; 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="qNVl0Pce" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FB6DC16AAE; Wed, 21 Jan 2026 17:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1769017675; bh=rap4vjdO701PMJ0MSSHR1FJS63P4Y/x0kEK7INx+cP8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qNVl0PceI+avxBpsPvq7rcWBKYDLkrenJNoyNu/jSoKgkPWd7mU0nmGUhQFfaOF4Q 2jeMghqGIxLJDjJGlwlLg5/tHWYIUbrvoA/9FS2tXMgH9zffiK+Ntnq3NjtKARcA+u XB0TAbDZgOKFuOM7uj6DyX6Cr37dIRS8C39rcUTA= Date: Wed, 21 Jan 2026 09:47:54 -0800 From: Andrew Morton To: Joshua Hahn Cc: David Hildenbrand , Muchun Song , Oscar Salvador , Wupeng Ma , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2] mm/hugetlb: Restore failed global reservations to subpool Message-Id: <20260121094754.8a30b7f7fcff34f579883e40@linux-foundation.org> In-Reply-To: <20260116204037.2270096-1-joshua.hahnjy@gmail.com> References: <20260116204037.2270096-1-joshua.hahnjy@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@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 Fri, 16 Jan 2026 15:40:36 -0500 Joshua Hahn wrote: > Commit a833a693a490 ("mm: hugetlb: fix incorrect fallback for subpool") > fixed an underflow error for hstate->resv_huge_pages caused by > incorrectly attributing globally requested pages to the subpool's > reservation. > > Unfortunately, this fix also introduced the opposite problem, which would > leave spool->used_hpages elevated if the globally requested pages could > not be acquired. This is because while a subpool's reserve pages only > accounts for what is requested and allocated from the subpool, its > "used" counter keeps track of what is consumed in total, both from the > subpool and globally. Thus, we need to adjust spool->used_hpages in the > other direction, and make sure that globally requested pages are > uncharged from the subpool's used counter. > > ... > > Fixes: a833a693a490 ("mm: hugetlb: fix incorrect fallback for subpool") > Signed-off-by: Joshua Hahn > Cc: stable@vger.kernel.org This (simple, cc:stable) patch presently has no reviews, if someone could please be so kind. > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6713,6 +6713,15 @@ long hugetlb_reserve_pages(struct inode *inode, > */ > hugetlb_acct_memory(h, -gbl_resv); > } > + /* Restore used_hpages for pages that failed global reservation */ > + if (gbl_reserve && spool) { > + unsigned long flags; > + > + spin_lock_irqsave(&spool->lock, flags); > + if (spool->max_hpages != -1) > + spool->used_hpages -= gbl_reserve; > + unlock_or_release_subpool(spool, flags); > + } > out_uncharge_cgroup: > hugetlb_cgroup_uncharge_cgroup_rsvd(hstate_index(h), > chg * pages_per_huge_page(h), h_cg); >