diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-12-13 18:43:50 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-12-13 18:43:50 +0100 |
commit | 266facde8367cac71d748f04dfb4f72a76bfe51e (patch) | |
tree | 94d2ffc36ddf53db9e4a1fa34e877e9c601102af /mm | |
parent | Merge tag 'v6.13-rc2-ksmbd-server-fixes' of git://git.samba.org/ksmbd (diff) | |
parent | memcg: slub: fix SUnreclaim for post charged objects (diff) | |
download | linux-266facde8367cac71d748f04dfb4f72a76bfe51e.tar.xz linux-266facde8367cac71d748f04dfb4f72a76bfe51e.zip |
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
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slub.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/mm/slub.c b/mm/slub.c index 19980419b176..c2151c9fee22 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2189,9 +2189,24 @@ bool memcg_slab_post_charge(void *p, gfp_t flags) folio = virt_to_folio(p); if (!folio_test_slab(folio)) { - return folio_memcg_kmem(folio) || - (__memcg_kmem_charge_page(folio_page(folio, 0), flags, - folio_order(folio)) == 0); + int size; + + if (folio_memcg_kmem(folio)) + return true; + + if (__memcg_kmem_charge_page(folio_page(folio, 0), flags, + folio_order(folio))) + return false; + + /* + * This folio has already been accounted in the global stats but + * not in the memcg stats. So, subtract from the global and use + * the interface which adds to both global and memcg stats. + */ + size = folio_size(folio); + node_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, -size); + lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, size); + return true; } slab = folio_slab(folio); |