From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 E37791FCFEF for ; Thu, 26 Feb 2026 06:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772088361; cv=none; b=B6pikyWl+JUGV5j9sEn88N8ELZf0L2z1bhgbNL9RAwVynhqV9EsCBdJ0sspAaP5E/YjwqcegTgOOhQFZF1oj3sleoe/0zrUpIE98g3rPPZShrR0YAT68SDQ8O5SDgcxLqoNzpiixlIwOB2u6Ww65VF9UCqZbXDKctc1cvjmU26U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772088361; c=relaxed/simple; bh=Z9zAntrzHWUhSlDvu8b0Zll5d7a7+jL8Xz+SY71Kr8s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=F+/jZ/WKUZ2bawlaVHvbH5uZGLVlPJv8ZsFx1mVf2DO70sxc9Odkad/r6kIiUXCZZYzv4pdfUszswXxDC8tOSNm75gsodgHAvJlvR7MaW2YBQK85ZoYvxPplU+eM0QNwLV0Pxuoq7mtFvZqwZm57DSVJ+7n/1MBR1hDYMqiyF2A= 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=fqwCC+zh; arc=none smtp.client-ip=91.218.175.189 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="fqwCC+zh" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772088357; 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=C4rL/wwllg6CU5AzOZho/BUjc41JirXfRLVAIZITAog=; b=fqwCC+zho2n+4/p9/dwF/Zeky6wKhrtDbuYw1zzSrKqzghBSWcypfO12waZoixPntWyd45 WYrm3j6GECj3OS1oxAzopUY1P1+JNiN5ZEXDRr/Oa1k/Ir5/biWrClmwF7xAkvmnc6nRP6 nZ/FW3jXXhmkxVqNOAPdkrxYdwl9SBk= Date: Thu, 26 Feb 2026 14:45:46 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v5 29/32] mm: memcontrol: prepare for reparenting non-hierarchical stats To: Shakeel Butt Cc: hannes@cmpxchg.org, 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, yosry.ahmed@linux.dev, 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, bhe@redhat.com, usamaarif642@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Qi Zheng References: 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 2/26/26 9:41 AM, Shakeel Butt wrote: > On Wed, Feb 25, 2026 at 03:53:12PM +0800, Qi Zheng wrote: >> From: Qi Zheng >> >> To resolve the dying memcg issue, we need to reparent LRU folios of child >> memcg to its parent memcg. This could cause problems for non-hierarchical >> stats. >> >> As Yosry Ahmed pointed out: >> >> ``` >> In short, if memory is charged to a dying cgroup at the time of >> reparenting, when the memory gets uncharged the stats updates will occur >> at the parent. This will update both hierarchical and non-hierarchical >> stats of the parent, which would corrupt the parent's non-hierarchical >> stats (because those counters were never incremented when the memory was >> charged). >> ``` >> >> Now we have the following two types of non-hierarchical stats, and they >> are only used in CONFIG_MEMCG_V1: >> >> a. memcg->vmstats->state_local[i] >> b. pn->lruvec_stats->state_local[i] >> >> To ensure that these non-hierarchical stats work properly, we need to >> reparent these non-hierarchical stats after reparenting LRU folios. To >> this end, this commit makes the following preparations: >> >> 1. implement reparent_state_local() to reparent non-hierarchical stats >> 2. make css_killed_work_fn() to be called in rcu work, and implement >> get_non_dying_memcg_start() and get_non_dying_memcg_end() to avoid race >> between mod_memcg_state()/mod_memcg_lruvec_state() >> and reparent_state_local() >> 3. change these non-hierarchical stats to atomic_long_t type to avoid race >> between mem_cgroup_stat_aggregate() and reparent_state_local() >> >> Signed-off-by: Qi Zheng > > [...] > >> --- a/mm/memcontrol-v1.h >> +++ b/mm/memcontrol-v1.h >> @@ -45,6 +45,7 @@ static inline bool do_memsw_account(void) >> >> unsigned long memcg_events_local(struct mem_cgroup *memcg, int event); >> unsigned long memcg_page_state_local(struct mem_cgroup *memcg, int idx); >> +void mod_memcg_page_state_local(struct mem_cgroup *memcg, int idx, unsigned long val); > > The above seems like addition by mistake. Yes, my mistake, need to be deleted directly. ;) > > After fixing this, you can add: > > Acked-by: Shakeel Butt Thanks! >