From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 767D2262808 for ; Mon, 22 Dec 2025 03:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766374453; cv=none; b=Gk/AA7GbigwJtRwpeF7oX0OeuKE5QSoJYjTiRIYLjCvxkAxGdVZpk421yzIfO5x6E+zPFHRPdR5UupbCm+OWTM68RknQ/l602EB51DliaZqcYg3/lARrnmvF7sK/DdEjZ29owrJhwYsrehVjIYK0Ox47sZG4TfPjbEdZSpZl1XQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766374453; c=relaxed/simple; bh=oM70Tf3uuJzEpVwt8qJafyICt12TZ9lSmVsTOwXHJzk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NIVe/9y/i+GtXxmdhvngzH6gV3tSI5l4vB82fDr6j+7dlY9Z/Rdx72cTpnkz6LrpWMTYC0OkbJWgRaFDaasoHJc7OE0rCc41q/X/lm051zpizvHCGCUPMxkpRoaLB/ncwb4mcuRE3WTifQSORYWFiNKtpWfewKr4P+OjTTGj9HE= 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=VMFlsarU; arc=none smtp.client-ip=91.218.175.183 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="VMFlsarU" Message-ID: <75f31ec7-1605-4f50-9adb-6d84e9e81101@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1766374443; 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=qGqa+G9yooe1hEmvBfRcJmjA7QA8SkNJctdApIJNl98=; b=VMFlsarUjmbbIJb0UCStjyxyJrACCyd77zr3JpIq+0OrxRPujQeEJ28zq7ZaQcUjjSRK+m 45woNINIu2xTjOA9jAQGZrhluNaExT/eu5KnzscPJgAt2nP00wenDmKJuQiyJw2LbGvIUu PXSVuQFB4EVTsQET3xVVnLZC6boeT7A= Date: Mon, 22 Dec 2025 11:33:48 +0800 Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 17/28] mm: thp: prevent memory cgroup release in folio_split_queue_lock{_irqsave}() To: Shakeel Butt , Johannes Weiner Cc: hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, muchun.song@linux.dev, david@kernel.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, harry.yoo@oracle.com, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Qi Zheng References: <4cb81ea06298a3b41873b7086bfc68f64b2ba8be.1765956025.git.zhengqi.arch@bytedance.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 12/20/25 9:11 AM, Shakeel Butt wrote: > On Wed, Dec 17, 2025 at 05:27:17PM -0500, Johannes Weiner wrote: >> On Wed, Dec 17, 2025 at 03:27:41PM +0800, Qi Zheng wrote: >>> From: Qi Zheng >>> >>> In the near future, a folio will no longer pin its corresponding memory >>> cgroup. To ensure safety, it will only be appropriate to hold the rcu read >>> lock or acquire a reference to the memory cgroup returned by >>> folio_memcg(), thereby preventing it from being released. >>> >>> In the current patch, the rcu read lock is employed to safeguard against >>> the release of the memory cgroup in folio_split_queue_lock{_irqsave}(). >>> >>> Signed-off-by: Qi Zheng >>> Reviewed-by: Harry Yoo >>> --- >>> mm/huge_memory.c | 16 ++++++++++++++-- >>> 1 file changed, 14 insertions(+), 2 deletions(-) >>> >>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >>> index 12b46215b30c1..b9e6855ec0b6a 100644 >>> --- a/mm/huge_memory.c >>> +++ b/mm/huge_memory.c >>> @@ -1154,13 +1154,25 @@ split_queue_lock_irqsave(int nid, struct mem_cgroup *memcg, unsigned long *flags >>> >>> static struct deferred_split *folio_split_queue_lock(struct folio *folio) >>> { >>> - return split_queue_lock(folio_nid(folio), folio_memcg(folio)); >>> + struct deferred_split *queue; >>> + >>> + rcu_read_lock(); >>> + queue = split_queue_lock(folio_nid(folio), folio_memcg(folio)); >>> + rcu_read_unlock(); >> >> Ah, the memcg destruction path is acquiring the split queue lock for >> reparenting. Once you have it locked, it's safe to drop the rcu lock. > > Qi, please add the above explanation in a comment and with that: OK, will do. > > Acked-by: Shakeel Butt Thanks!