Skip to content

Commit

Permalink
Merge tag 'slab-for-6.13-rc3' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/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
  • Loading branch information
torvalds committed Dec 13, 2024
2 parents f932fb9 + b7ffecb commit 266facd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 266facd

Please sign in to comment.