Re: [PATCH v5 update 30/32] mm: memcontrol: convert objcg to be per-memcg per-node type
From: Shakeel Butt
Date: Wed Feb 25 2026 - 21:28:39 EST
On Wed, Feb 25, 2026 at 05:44:56PM +0800, Qi Zheng wrote:
> From: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
>
> Convert objcg to be per-memcg per-node type, so that when reparent LRU
> folios later, we can hold the lru lock at the node level, thus avoiding
> holding too many lru locks at once.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@xxxxxxxxxxxxx>
> ---
> changlog:
> - fix a missing root_obj_cgroup conversion and completely delete
> root_obj_cgroup.
>
> include/linux/memcontrol.h | 23 +++++------
> include/linux/sched.h | 2 +-
> mm/memcontrol.c | 79 +++++++++++++++++++++++---------------
> 3 files changed, 62 insertions(+), 42 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 45d911dd903e7..6e11552a90618 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -116,6 +116,16 @@ struct mem_cgroup_per_node {
> unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
> struct mem_cgroup_reclaim_iter iter;
>
> + /*
> + * objcg is wiped out as a part of the objcg repaprenting process.
> + * orig_objcg preserves a pointer (and a reference) to the original
> + * objcg until the end of live of memcg.
> + */
> + struct obj_cgroup __rcu *objcg;
> + struct obj_cgroup *orig_objcg;
The layout of struct mem_cgroup_per_node is very performance sensitive. Please
couple of performance benchmarks after rearranging the fields particularly the
above two pointers together at the start of the struct.
Otherwise:
Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>