Skip to content

Commit ea4702b

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
slab: Remove folio references in memcg_slab_post_charge()
This allows us to skip the compound_head() call for large kmalloc objects as the virt_to_page() call will always give us the head page for the large kmalloc case. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Harry Yoo <harry.yoo@oracle.com> Link: https://patch.msgid.link/20251113000932.1589073-4-willy@infradead.org Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent ee1ee8a commit ea4702b

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

mm/slub.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,33 +2369,34 @@ bool memcg_slab_post_charge(void *p, gfp_t flags)
23692369
{
23702370
struct slabobj_ext *slab_exts;
23712371
struct kmem_cache *s;
2372-
struct folio *folio;
2372+
struct page *page;
23732373
struct slab *slab;
23742374
unsigned long off;
23752375

2376-
folio = virt_to_folio(p);
2377-
if (!folio_test_slab(folio)) {
2376+
page = virt_to_page(p);
2377+
if (PageLargeKmalloc(page)) {
2378+
unsigned int order;
23782379
int size;
23792380

2380-
if (folio_memcg_kmem(folio))
2381+
if (PageMemcgKmem(page))
23812382
return true;
23822383

2383-
if (__memcg_kmem_charge_page(folio_page(folio, 0), flags,
2384-
folio_order(folio)))
2384+
order = large_kmalloc_order(page);
2385+
if (__memcg_kmem_charge_page(page, flags, order))
23852386
return false;
23862387

23872388
/*
2388-
* This folio has already been accounted in the global stats but
2389+
* This page has already been accounted in the global stats but
23892390
* not in the memcg stats. So, subtract from the global and use
23902391
* the interface which adds to both global and memcg stats.
23912392
*/
2392-
size = folio_size(folio);
2393-
node_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, -size);
2394-
lruvec_stat_mod_folio(folio, NR_SLAB_UNRECLAIMABLE_B, size);
2393+
size = PAGE_SIZE << order;
2394+
mod_node_page_state(page_pgdat(page), NR_SLAB_UNRECLAIMABLE_B, -size);
2395+
mod_lruvec_page_state(page, NR_SLAB_UNRECLAIMABLE_B, size);
23952396
return true;
23962397
}
23972398

2398-
slab = folio_slab(folio);
2399+
slab = page_slab(page);
23992400
s = slab->slab_cache;
24002401

24012402
/*

0 commit comments

Comments
 (0)