From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.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 571FB36EAB7 for ; Thu, 26 Feb 2026 01:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772070129; cv=none; b=f3AdO4yzZATcAAtol0KmDaG/eIwoWAQgZBbGNg9yeKchOq4HPuG33/eWpUbX8+WhD2Q9x1mwYA2pr9S1Q6tUq5caP3m4sf4/8ruUKf7Il46bgOYaxv+i4NrJdWjzeomcunUGxElnkZ3MMGX3sCx5niEmDV6bBd4Yd8H6q3gnwSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772070129; c=relaxed/simple; bh=/LKqdjFoiQ04/XIA87m3i7gEF0FyoRJDwONhXGMRjXM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q0n+Z/fBsrsVbh5r/OG6lsHC63Aw/WBhAHLK1m2pnzk/83nsfZV1HumMAySemeEdXDwZwkf3q1og9OSBO1O3UD3gTrsuDRT+dbbCcLypX8E4r7hO4GbIyghsivnM+blJOIqbUhcyJRpWFHJgW/plHUPlNHPrDMPtSRtjqCcDu+w= 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=DBpR2vEH; arc=none smtp.client-ip=95.215.58.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="DBpR2vEH" Date: Wed, 25 Feb 2026 17:41:46 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772070116; 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: in-reply-to:in-reply-to:references:references; bh=FCvGmCmilt3Iav7ktXIbGgvFCADiAsVJLuTgICHbbvU=; b=DBpR2vEHIC7mO2TzWh+tPoXu1M0seTK3lc9QNrkr4WCCR0KRQGf/X0U8dUG6eoOfO/W5Eo QoZ6Lz1NfN4dRNNpPK000BXyGzhaRdY9c2l3lawHKeoxcAk42kCxcc5L15Bmf2X39OjXIS Ufk8H2HzfJmRbO1VmozjxmiaJ7e4so4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Qi Zheng 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 Subject: Re: [PATCH v5 29/32] mm: memcontrol: prepare for reparenting non-hierarchical stats Message-ID: References: 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-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT 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. After fixing this, you can add: Acked-by: Shakeel Butt