]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm: Convert virt_to_cache() to use struct slab
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 30 Sep 2021 03:09:23 +0000 (23:09 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 4 Oct 2021 03:06:36 +0000 (23:06 -0400)
This function is entirely self-contained, so can be converted from
page to slab.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/slab.h

index 305cc8c7fed8287198b9bfdc2d5cf0e8fb49eab3..3c691ef6b492e8755631afd2328904e209693fa6 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -480,13 +480,13 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s,
 
 static inline struct kmem_cache *virt_to_cache(const void *obj)
 {
-       struct page *page;
+       struct slab *slab;
 
-       page = virt_to_head_page(obj);
-       if (WARN_ONCE(!PageSlab(page), "%s: Object is not a Slab page!\n",
+       slab = virt_to_slab(obj);
+       if (WARN_ONCE(!SlabAllocation(slab), "%s: Object is not a Slab page!\n",
                                        __func__))
                return NULL;
-       return page->slab_cache;
+       return slab->slab_cache;
 }
 
 static __always_inline void account_slab_page(struct page *page, int order,