From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (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 DCDFB3E6DC8 for ; Wed, 8 Jul 2026 07:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783494310; cv=none; b=PR/9k18A/3XYQdXjmKYAASJxHAT3Ggog+F9TzIqJ8IQ+psIu0lGX+7Q/P4qVZFHNlooDB//4J5sIgOK4OCDeNzawKleIp/DF+dNaTD3zsXBlAGkrI4580KFlNp7iW3cJTqnRLjZn4u8jW2s1f0FY4OdbTPzvgQyQL+tGz+w95Hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783494310; c=relaxed/simple; bh=CCF/5VMVj+s7tTG8SCjJp4FwBQLOszh3xeD8+sBaRHQ=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=CbQxpJNeUvoyahqdrVpiElz+9fJv/nEUlxhDnQDISttT2wv2blSFGi0HnRZHDirQ3GYQPHPmupHLy7q5ynyeCEtyIJ2Wg5Uu7wZChE/Us5EO7hgQgfFI3FWI7cRp/z0taE5QRScxDKujkLQdNdH/hChQFxxa8DATez76HFO3rzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=s6S5bdq9; arc=none smtp.client-ip=91.218.175.182 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) header.d=linux.dev header.i=@linux.dev header.b="s6S5bdq9" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783494289; h=from:from: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=CCF/5VMVj+s7tTG8SCjJp4FwBQLOszh3xeD8+sBaRHQ=; b=s6S5bdq9f/5x6Scinw0CfVE2GRbo6L9ITyYX55Ckui9HtVBiEpSF2FqE+lqc5ltUwzhMuC 5OnLMsYTSuRf5LJyf9TGvOkViKB0ssb8a41Nr0SX9YQ7xQhUee/kAbHrqgR3vnyG5u7MdA ttoCcF2Zhb9fYNIGGlREeO7XFRk5Ai0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH 3/4] mm: hugetlb: Return -ENOSPC on memcg charge failure X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260707-hugetlb-alloc-failure-fixes-v1-3-5bbd3a4b836d@google.com> Date: Wed, 8 Jul 2026 15:04:13 +0800 Cc: Oscar Salvador , David Hildenbrand , Joshua Hahn , Shakeel Butt , Nhat Pham , Andrew Morton , Peter Xu , Wupeng Ma , fvdl@google.com, rientjes@google.com, vannapurve@google.com, erdemaktas@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20260707-hugetlb-alloc-failure-fixes-v1-0-5bbd3a4b836d@google.com> <20260707-hugetlb-alloc-failure-fixes-v1-3-5bbd3a4b836d@google.com> To: ackerleytng@google.com X-Migadu-Flow: FLOW_OUT > On Jul 8, 2026, at 04:46, Ackerley Tng via B4 Relay = wrote: >=20 > From: Ackerley Tng >=20 > When mem_cgroup_charge_hugetlb() fails with -ENOMEM, = alloc_hugetlb_folio() > currently propagates this error. This results in the page fault = handler > returning VM_FAULT_OOM. >=20 > Because HugeTLB allocations are high-order and use = __GFP_RETRY_MAYFAIL, > they bypass the OOM killer. Returning VM_FAULT_OOM to the #PF handler > without triggering the OOM killer (or having it make progress) leads = to > an infinite loop of retrying the fault. >=20 > Avoid this loop by returning -ENOSPC when charging fails, which maps = to > VM_FAULT_SIGBUS, terminating the process cleanly. >=20 > Make mem_cgroup_charge_hugetlb() fault handling use a common error = handling > path, the same handling used for = hugetlb_cgroup_uncharge_cgroup{,_rsvd}(), > which also don't trigger the OOM killer and hence opt to terminate the > process with a SIGBUS. >=20 > Fixes: 991135774c0e0 ("memcg/hugetlb: introduce = mem_cgroup_charge_hugetlb") > Signed-off-by: Ackerley Tng Please cc stable as well. Reviewed-by: Muchun Song Thanks.