Skip to content

Commit 82c1775

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
mm: Convert virt_to_cache() to use struct slab
This function is entirely self-contained, so can be converted from page to slab. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]> Acked-by: Johannes Weiner <[email protected]> Reviewed-by: Roman Gushchin <[email protected]> Reviewed-by: Hyeonggon Yoo <[email protected]>
1 parent b918653 commit 82c1775

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/slab.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,13 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s,
574574

575575
static inline struct kmem_cache *virt_to_cache(const void *obj)
576576
{
577-
struct page *page;
577+
struct slab *slab;
578578

579-
page = virt_to_head_page(obj);
580-
if (WARN_ONCE(!PageSlab(page), "%s: Object is not a Slab page!\n",
579+
slab = virt_to_slab(obj);
580+
if (WARN_ONCE(!slab, "%s: Object is not a Slab page!\n",
581581
__func__))
582582
return NULL;
583-
return page->slab_cache;
583+
return slab->slab_cache;
584584
}
585585

586586
static __always_inline void account_slab(struct slab *slab, int order,

0 commit comments

Comments
 (0)