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 EFFC4381B02 for ; Thu, 21 May 2026 17:28:38 +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=1779384521; cv=none; b=Lmh3bgAZ8yD7GppJCQXpIscq32cb1b3lduqYtZhFW5kWx4q6qFDFptvr+5OZo6PHyOyrDgTfosD5NHteSFetllKGYvojJMbRGWyRV7znpJsrY0fjayDe1MVCx81qBBVzxCVMMFVVs1VbvZGqYWsQy2GoN4JvfeEhlJHyZhUy/Qk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779384521; c=relaxed/simple; bh=/Y4JOjqiWrH99jRT/1kQW4MKozhFjKKnxjBVmamwLAk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H/kbzTrU6iiSf/GmUT7LHEp3U3BXoNeOjlRzpiQctgJdazMRoNtIbA2g2a7L09fn8bxTEYGCrYsOrBnfR09/LNecV4j6rZ0cWpSN/Iub07dJXnCVoCnEPbufyGeqpaUUY7ZCA8v7tup0c1jdBz29N1YOua6wd6BGxbbum8XEqXQ= 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=gtJKinXs; 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="gtJKinXs" Date: Thu, 21 May 2026 10:28:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779384516; 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=VMh0FfyEhpzP/o6+/cG0EuYR7BrwDmTdRcZFskTN7I0=; b=gtJKinXsA+PvoLRM/qYCELyTzZ8blaZkWqvMW4qMo4oYOD2Y0aCv/YPNS9HYL2paKJgsak UCJngQ0G3V1bmIDRcrnrS9n2pZzZd/MUkrgqnDwcIL9sCdEZXgRDTF0RiTkwZnvG+ZxdjK TFDeQo9NvtXo5wql6LmmFsA8m73X9Sk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Alexandre Ghiti Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Dennis Zhou , Tejun Heo , Christoph Lameter , Vlastimil Babka , Yosry Ahmed , Nhat Pham , Sergey Senozhatsky , Chengming Zhou , Suren Baghdasaryan , Qi Zheng , David Hildenbrand , Lorenzo Stoakes , Minchan Kim , Mike Rapoport , Axel Rasmussen , Barry Song , Kairui Song , Wei Xu , Yuanchu Xie , "Liam R . Howlett" , Joshua Hahn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 4/8] mm: memcontrol: track MEMCG_KMEM per NUMA node Message-ID: References: <20260511202136.330358-1-alex@ghiti.fr> <20260511202136.330358-5-alex@ghiti.fr> 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: <20260511202136.330358-5-alex@ghiti.fr> X-Migadu-Flow: FLOW_OUT On Mon, May 11, 2026 at 10:20:39PM +0200, Alexandre Ghiti wrote: > This patch gets rid of MEMCG_KMEM and wires all the "generic" functions > by introducing per-node obj_cgroup objects. > > Note that it does not convert the kmem users to proper per-memcg-per-node > accounting now, this is done in upcoming patches. > > Signed-off-by: Alexandre Ghiti > --- > include/linux/memcontrol.h | 23 ++++++++++---- > include/linux/mmzone.h | 1 + > mm/memcontrol.c | 64 ++++++++++++++++++++++++-------------- > mm/vmstat.c | 1 + > 4 files changed, 59 insertions(+), 30 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 568ab08f42af..17cf823160e4 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -35,7 +35,6 @@ enum memcg_stat_item { > MEMCG_SWAP = NR_VM_NODE_STAT_ITEMS, > MEMCG_SOCK, > MEMCG_PERCPU_B, > - MEMCG_KMEM, > MEMCG_ZSWAP_B, > MEMCG_ZSWAPPED, > MEMCG_ZSWAP_INCOMP, > @@ -126,9 +125,10 @@ struct mem_cgroup_per_node { > struct list_head objcg_list; > > #ifdef CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC > - /* slab stats for nmi context */ > + /* slab and kmem stats for nmi context */ > atomic_t slab_reclaimable; > atomic_t slab_unreclaimable; > + atomic_t kmem; > #endif > }; > > @@ -190,6 +190,7 @@ struct obj_cgroup { > struct rcu_head rcu; > }; > bool is_root; > + int nid; > }; > > /* > @@ -254,10 +255,6 @@ struct mem_cgroup { > atomic_long_t memory_events[MEMCG_NR_MEMORY_EVENTS]; > atomic_long_t memory_events_local[MEMCG_NR_MEMORY_EVENTS]; > > -#ifdef CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC > - /* MEMCG_KMEM for nmi context */ > - atomic_t kmem_stat; > -#endif > /* > * Hint of reclaim pressure for socket memroy management. Note > * that this indicator should NOT be used in legacy cgroup mode > @@ -776,6 +773,20 @@ static inline void obj_cgroup_put(struct obj_cgroup *objcg) > percpu_ref_put(&objcg->refcnt); > } > > +static inline struct obj_cgroup *obj_cgroup_get_nid(struct obj_cgroup *objcg, > + int nid) > +{ > + struct obj_cgroup *nid_objcg; > + struct mem_cgroup *memcg; > + > + rcu_read_lock(); > + memcg = obj_cgroup_memcg(objcg); > + nid_objcg = rcu_dereference(memcg->nodeinfo[nid]->objcg); > + rcu_read_unlock(); > + > + return nid_objcg; What is guarating the life of nid_objcg?