Skip to content

Commit 266facd

Browse files
committed
Merge tag 'slab-for-6.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab
Pull slab fix from Vlastimil Babka: - Fix for memcg unreclaimable slab stats drift when post-charging large kmalloc allocations (Shakeel Butt) * tag 'slab-for-6.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab: memcg: slub: fix SUnreclaim for post charged objects
2 parents f932fb9 + b7ffecb commit 266facd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

mm/slub.c

+18-3
Original file line numberDiff line numberDiff line change
@@ -2189,9 +2189,24 @@ bool memcg_slab_post_charge(void *p, gfp_t flags)
21892189

21902190
folio = virt_to_folio(p);
21912191
if (!folio_test_slab(folio)) {
2192-
return folio_memcg_kmem(folio) ||
2193-
(__memcg_kmem_charge_page(folio_page(folio, 0), flags,
2194-
folio_order(folio)) == 0);
2192+
int size;
2193+
2194+
if (folio_memcg_kmem(folio))
2195+
return true;
2196+
2197+
if (__memcg_kmem_charge_page(folio_page(folio, 0), flags,
2198+
folio_order(folio)))
2199+
return false;
2200+
2201+
/*
2202+
* This folio has already been accounted in the global stats but
2203+
* not in the memcg stats. So, subtract from the global and use
2204+
* the interface which adds to both global and memcg stats.
2205+
*/
2206+
size = folio_size(folio);
2207+
node_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, -size);
2208+
lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, size);
2209+
return true;
21952210
}
21962211

21972212
slab = folio_slab(folio);

0 commit comments

Comments
 (0)