Skip to content

Commit 9910aff

Browse files
committed
Merge tag 'slab-for-6.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab
Pull slab fix from Vlastimil Babka: - Stable fix to avoid bugs due to leftover obj_ext after allocation profiling is disabled at runtime (Zhenhua Huang) * tag 'slab-for-6.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab: mm, slab: clean up slab->obj_exts always
2 parents ebd297a + be82507 commit 9910aff

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

mm/slub.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,8 +2028,7 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,
20282028
return 0;
20292029
}
20302030

2031-
/* Should be called only if mem_alloc_profiling_enabled() */
2032-
static noinline void free_slab_obj_exts(struct slab *slab)
2031+
static inline void free_slab_obj_exts(struct slab *slab)
20332032
{
20342033
struct slabobj_ext *obj_exts;
20352034

@@ -2049,18 +2048,6 @@ static noinline void free_slab_obj_exts(struct slab *slab)
20492048
slab->obj_exts = 0;
20502049
}
20512050

2052-
static inline bool need_slab_obj_ext(void)
2053-
{
2054-
if (mem_alloc_profiling_enabled())
2055-
return true;
2056-
2057-
/*
2058-
* CONFIG_MEMCG creates vector of obj_cgroup objects conditionally
2059-
* inside memcg_slab_post_alloc_hook. No other users for now.
2060-
*/
2061-
return false;
2062-
}
2063-
20642051
#else /* CONFIG_SLAB_OBJ_EXT */
20652052

20662053
static inline void init_slab_obj_exts(struct slab *slab)
@@ -2077,11 +2064,6 @@ static inline void free_slab_obj_exts(struct slab *slab)
20772064
{
20782065
}
20792066

2080-
static inline bool need_slab_obj_ext(void)
2081-
{
2082-
return false;
2083-
}
2084-
20852067
#endif /* CONFIG_SLAB_OBJ_EXT */
20862068

20872069
#ifdef CONFIG_MEM_ALLOC_PROFILING
@@ -2129,7 +2111,7 @@ __alloc_tagging_slab_alloc_hook(struct kmem_cache *s, void *object, gfp_t flags)
21292111
static inline void
21302112
alloc_tagging_slab_alloc_hook(struct kmem_cache *s, void *object, gfp_t flags)
21312113
{
2132-
if (need_slab_obj_ext())
2114+
if (mem_alloc_profiling_enabled())
21332115
__alloc_tagging_slab_alloc_hook(s, object, flags);
21342116
}
21352117

@@ -2601,8 +2583,12 @@ static __always_inline void account_slab(struct slab *slab, int order,
26012583
static __always_inline void unaccount_slab(struct slab *slab, int order,
26022584
struct kmem_cache *s)
26032585
{
2604-
if (memcg_kmem_online() || need_slab_obj_ext())
2605-
free_slab_obj_exts(slab);
2586+
/*
2587+
* The slab object extensions should now be freed regardless of
2588+
* whether mem_alloc_profiling_enabled() or not because profiling
2589+
* might have been disabled after slab->obj_exts got allocated.
2590+
*/
2591+
free_slab_obj_exts(slab);
26062592

26072593
mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s),
26082594
-(PAGE_SIZE << order));

0 commit comments

Comments
 (0)