Skip to content

Commit

Permalink
slab: allocate frozen pages
Browse files Browse the repository at this point in the history
Since slab does not use the page refcount, it can allocate and free frozen
pages, saving one atomic operation per free.

Link: https://lkml.kernel.org/r/20241125210149.2976098-16-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Matthew Wilcox (Oracle) authored and Andrew Morton committed Jan 14, 2025
1 parent 6429752 commit 9aec2fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2420,9 +2420,9 @@ static inline struct slab *alloc_slab_page(gfp_t flags, int node,
unsigned int order = oo_order(oo);

if (node == NUMA_NO_NODE)
folio = (struct folio *)alloc_pages(flags, order);
folio = (struct folio *)alloc_frozen_pages(flags, order);
else
folio = (struct folio *)__alloc_pages_node(node, flags, order);
folio = (struct folio *)__alloc_frozen_pages(flags, order, node, NULL);

if (!folio)
return NULL;
Expand Down Expand Up @@ -2656,7 +2656,7 @@ static void __free_slab(struct kmem_cache *s, struct slab *slab)
__folio_clear_slab(folio);
mm_account_reclaimed_pages(pages);
unaccount_slab(slab, order, s);
__free_pages(&folio->page, order);
free_frozen_pages(&folio->page, order);
}

static void rcu_free_slab(struct rcu_head *h)
Expand Down

0 comments on commit 9aec2fb

Please sign in to comment.