From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 7FD553EFFAC for ; Wed, 8 Jul 2026 06:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783494005; cv=none; b=kma3BZOQhQdqoexbpzSysYuUQ5/c3NkCUbgVCwbeE0U9Kf59XY+qio7iojhcP3T7vNVrqzy8Xevc4HbWjo5DlNomDgxJQleCMnG6ykB+eVmLHZpgoX9tjG9DZaQbFeZFu8KW3t/bxwMmKruTxTQTXCRs+JGsqmhT4l02oU0gDJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783494005; c=relaxed/simple; bh=V8g5jqgLjD951EWfoRZb50fh2tBQHpkiuCaoVDllV64=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=GVmxNSQgmZEBsp6XsF54xoFhh/TWt4lbfxtamcbdV+6Z48KY7iBKKdLuGQQSi725HIpCuaT7cEpyNC3zKXN3RI4TQ0RkH4Ql0wR7G4+dtt7oahf0+d5LeX5+UEnwaawsimw8EKu1+6kvYz7P54/semEquCajob0180UVkF+uxp8= 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=kfb6BHsM; arc=none smtp.client-ip=91.218.175.173 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="kfb6BHsM" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783493987; 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=V8g5jqgLjD951EWfoRZb50fh2tBQHpkiuCaoVDllV64=; b=kfb6BHsMikwfRWrebJWraHz6m6y89IWGuNsz42BIRXCT5N2yrGBijRhl7tUhMWC3BipA5Z G9gJuHy30GUIk3YNlr0PlJL+2iuzFI4Y1fCu5jkibUvd8Cmv6Dsj8VJ8Z7P2kcgzTO3yFc AYYyw2HzdkSm0oU5UEWLQDyV9PAEPLg= 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 2/4] mm: hugetlb: Fix folio refcount mismatch 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-2-5bbd3a4b836d@google.com> Date: Wed, 8 Jul 2026 14:59:10 +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-2-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(folio, gfp) returns -ENOMEM, the folio = has > its refcount set to 1 via folio_ref_unfreeze(folio, 1). >=20 > The error path calls free_huge_folio(folio) directly, which expects a > refcount of 0. Hence, VM_BUG_ON_FOLIO(folio_ref_count(folio), folio) = is > triggered. >=20 > Even with CONFIG_DEBUG_VM disabled, returning a folio with refcount 1 = to > the freelist can corrupt allocator state later. >=20 > Use folio_put(folio) instead of free_huge_folio(folio) to properly = drop the > reference before freeing it. >=20 > Fixes: 991135774c0e0 ("memcg/hugetlb: introduce = mem_cgroup_charge_hugetlb") > Signed-off-by: Ackerley Tng Yes, a real issue, I think we should cc stable as well. Reviewed-by: Muchun Song Thanks.