Skip to content

Commit a52c633

Browse files
Alex Shi (Tencent)tehcaster
authored andcommitted
mm/memcg: alignment memcg_data define condition
commit 21c690a ("mm: introduce slabobj_ext to support slab object extensions") changed the folio/page->memcg_data define condition from MEMCG to SLAB_OBJ_EXT. This action make memcg_data exposed while !MEMCG. As Vlastimil Babka suggested, let's add _unused_slab_obj_exts for SLAB_MATCH for slab.obj_exts while !MEMCG. That could resolve the match issue, clean up the feature logical. Signed-off-by: Alex Shi (Tencent) <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Yoann Congal <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 7b1fdf2 commit a52c633

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

include/linux/mm_types.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ struct page {
169169
/* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */
170170
atomic_t _refcount;
171171

172-
#ifdef CONFIG_SLAB_OBJ_EXT
172+
#ifdef CONFIG_MEMCG
173173
unsigned long memcg_data;
174+
#elif defined(CONFIG_SLAB_OBJ_EXT)
175+
unsigned long _unused_slab_obj_exts;
174176
#endif
175177

176178
/*
@@ -298,6 +300,7 @@ typedef struct {
298300
* @_hugetlb_cgroup_rsvd: Do not use directly, use accessor in hugetlb_cgroup.h.
299301
* @_hugetlb_hwpoison: Do not use directly, call raw_hwp_list_head().
300302
* @_deferred_list: Folios to be split under memory pressure.
303+
* @_unused_slab_obj_exts: Placeholder to match obj_exts in struct slab.
301304
*
302305
* A folio is a physically, virtually and logically contiguous set
303306
* of bytes. It is a power-of-two in size, and it is aligned to that
@@ -332,8 +335,10 @@ struct folio {
332335
};
333336
atomic_t _mapcount;
334337
atomic_t _refcount;
335-
#ifdef CONFIG_SLAB_OBJ_EXT
338+
#ifdef CONFIG_MEMCG
336339
unsigned long memcg_data;
340+
#elif defined(CONFIG_SLAB_OBJ_EXT)
341+
unsigned long _unused_slab_obj_exts;
337342
#endif
338343
#if defined(WANT_PAGE_VIRTUAL)
339344
void *virtual;

mm/slab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ struct slab {
9797
SLAB_MATCH(flags, __page_flags);
9898
SLAB_MATCH(compound_head, slab_cache); /* Ensure bit 0 is clear */
9999
SLAB_MATCH(_refcount, __page_refcount);
100-
#ifdef CONFIG_SLAB_OBJ_EXT
100+
#ifdef CONFIG_MEMCG
101101
SLAB_MATCH(memcg_data, obj_exts);
102+
#elif defined(CONFIG_SLAB_OBJ_EXT)
103+
SLAB_MATCH(_unused_slab_obj_exts, obj_exts);
102104
#endif
103105
#undef SLAB_MATCH
104106
static_assert(sizeof(struct slab) <= sizeof(struct page));

0 commit comments

Comments
 (0)