Re: [PATCH] mm: memcg: add cacheline padding after lruvec in mem_cgroup_per_node

Shakeel Butt
2024-07-23T17:30:46Z

On Tue, Jul 23, 2024 at 05:12:44PM GMT, Roman Gushchin wrote:
> Oliver Sand

Oliver Sang

> reported a performance regression caused by
> commit 98c9daf5ae6b ("mm: memcg: guard memcg1-specific members of struct
> mem_cgroup_per_node"), which puts some fields of the
> mem_cgroup_per_node structure under the CONFIG_MEMCG_V1 config option.
> Apparently it causes a false cache sharing between lruvec and
> lru_zone_size members of the structure. Fix it by adding an explicit
> padding after the lruvec member.
>
> Even though the padding is not required with CONFIG_MEMCG_V1 set,
> it seems like the introduced memory overhead is not significant
> enough to warrant another divergence in the mem_cgroup_per_node
> layout, so the padding is added unconditionally.
>
> Fixes: 98c9daf5ae6b ("mm: memcg: guard memcg1-specific members of struct mem_cgroup_per_node")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202407121335.31a10cb6-oliver.sang@intel.com
> Tested-by: Oliver Sang <oliver.sang@intel.com>
> Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>