public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix kmem over-charging for embedded obj_exts array
@ 2026-03-10 11:38 ranxiaokai627
  2026-03-10 11:38 ` [PATCH 1/2] mm/slab: move obj_exts_in_slab() definition to slab.h ranxiaokai627
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ranxiaokai627 @ 2026-03-10 11:38 UTC (permalink / raw)
  To: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm,
	vbabka, harry.yoo, hao.li, cl, rientjes
  Cc: cgroups, linux-mm, linux-kernel, ran.xiaokai, ranxiaokai627

From: Ran Xiaokai <ran.xiaokai@zte.com.cn>

Since commit a77d6d338685 ("mm/slab: place slabobj_ext metadata
in unused space within s->size"), the struct slabobj_ext array can
use slab leftover space or be embedded into the slub object to save
memory. In these cases, no extra kmalloc space is allocated for the
obj_exts array.

However, obj_full_size() always returns extra sizeof(struct obj_cgroup *)
bytes for every object, which leads to over-charging for slabs with
embedded obj_exts.

This series optimizes obj_full_size() to check whether obj_exts uses
slab leftover space or is embedded in the object. If so, only the object
size is charged. Otherwise, the extra obj_cgroup pointer space is also
charged.

Patch1 moves obj_exts_in_slab() definition to slab.h so it can be
       called from memcontrol.c.
Patch2 updates obj_full_size() to avoid over-charging.

Ran Xiaokai (2):
  mm/slab: move obj_exts_in_slab() definition to slab.h
  memcg: fix kmem over-charging for embedded obj_exts array

 mm/memcontrol.c | 19 ++++++++++++++-----
 mm/slab.h       | 19 +++++++++++++++++++
 mm/slub.c       | 19 -------------------
 3 files changed, 33 insertions(+), 24 deletions(-)

-- 
2.25.1




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-11  7:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 11:38 [PATCH 0/2] fix kmem over-charging for embedded obj_exts array ranxiaokai627
2026-03-10 11:38 ` [PATCH 1/2] mm/slab: move obj_exts_in_slab() definition to slab.h ranxiaokai627
2026-03-10 11:38 ` [PATCH 2/2] memcg: fix kmem over-charging for embedded obj_exts array ranxiaokai627
2026-03-11  2:13 ` [PATCH 0/2] " Harry Yoo
2026-03-11  3:06   ` Hao Li
2026-03-11  7:38     ` vbabka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox