mm: memcg: add cacheline padding after lruvec in mem_cgroup_per_node
Subsystems (2)
Roman Gushchin
maintainerPATCH 1/1 mm: memcg: add cacheline padding after lruvec in mem_cgroup_per_node
Oliver Sand 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.
--- include/linux/memcontrol.h | 1 + 1 file changed, 1 insertion(+)
include/linux/memcontrol.h +1 -0
@@ -109,6 +109,7 @@ struct mem_cgroup_per_node {/* Fields which get updated often at the end. */ struct lruvec lruvec; +CACHELINE_PADDING (_pad2_);unsigned long lru_zone_size[MAX_NR_ZONES ][NR_LRU_LISTS ];struct mem_cgroup_reclaim_iter iter; };
Signature · 1 line
2.45.2.1089.g2a221341d9-goog
Quoted 1 line · Roman Gushchin
Oliver Sand
Oliver Sang
Quoted 13 lines
reported a performance regression caused by
commit98c9daf5ae6b("mm: memcg: guard memcg1-specific members of structmem_cgroup_per_node"), which puts some fields of themem_cgroup_per_nodestructure under theCONFIG_MEMCG_V1config option. Apparently it causes a false cache sharing between lruvec andlru_zone_sizemembers of the structure. Fix it by adding an explicit padding after the lruvec member.Even though the padding is not required with
CONFIG_MEMCG_V1set, it seems like the introduced memory overhead is not significant enough to warrant another divergence in themem_cgroup_per_nodelayout, so the padding is added unconditionally.
Quoted 5 lines
Fixes 98c9daf5ae6b ("mm: memcg: guard memcg1-specific members of struct mem_cgroup_per_node")Reported-by kernel test robot <[email protected]>Tested-by Oliver Sang <[email protected]>Signed-off-by Roman Gushchin <[email protected]>