]> www.infradead.org Git - users/willy/xarray.git/commitdiff
mm: Convert virt_to_cache() to use struct slab
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 4 Oct 2021 13:45:53 +0000 (14:45 +0100)
committerVlastimil Babka <vbabka@suse.cz>
Thu, 6 Jan 2022 11:25:41 +0000 (12:25 +0100)
This function is entirely self-contained, so can be converted from page
to slab.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
mm/slab.h

index dd3f72fddff6d85c4784771d267b6174cade0345..1408ada9ff7295aae17c2d8bb9fdfdfb9c23ec86 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -574,13 +574,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(!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(struct slab *slab, int order,