@@ -14,7 +14,7 @@ static inline bool slab_test_cache(const struct slab *slab)
return test_bit(PG_slab, &slab->flags);
}
-static inline bool slab_test_multi_page(const struct slab *slab)
+static inline bool slab_test_multipage(const struct slab *slab)
{
return test_bit(PG_head, &slab->flags);
}
@@ -67,7 +67,7 @@ static inline struct slab *virt_to_slab(const void *addr)
static inline int slab_order(const struct slab *slab)
{
- if (!slab_test_multi_page(slab))
+ if (!slab_test_multipage(slab))
return 0;
return ((struct page *)slab)[1].compound_order;
}
@@ -483,7 +483,7 @@ static inline struct kmem_cache *virt_to_cache(const void *obj)
struct slab *slab;
slab = virt_to_slab(obj);
- if (WARN_ONCE(!SlabAllocation(slab), "%s: Object is not a Slab page!\n",
+ if (WARN_ONCE(!slab_test_cache(slab), "%s: Object is not a Slab page!\n",
__func__))
return NULL;
return slab->slab_cache;
@@ -570,7 +570,7 @@ EXPORT_SYMBOL(kfree);
/* can't use ksize for kmem_cache_alloc memory, only kmalloc */
size_t __ksize(const void *block)
{
- struct page *sp;
+ struct slab *sp;
int align;
unsigned int *m;
@@ -578,9 +578,9 @@ size_t __ksize(const void *block)
if (unlikely(block == ZERO_SIZE_PTR))
return 0;
- sp = virt_to_page(block);
- if (unlikely(!PageSlab(sp)))
- return page_size(sp);
+ sp = virt_to_slab(block);
+ if (unlikely(!slab_test_cache(sp)))
+ return slab_size(sp);
align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
m = (unsigned int *)(block - align);
@@ -4509,19 +4509,19 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page,
size_t __ksize(const void *object)
{
- struct page *page;
+ struct slab *slab;
if (unlikely(object == ZERO_SIZE_PTR))
return 0;
- page = virt_to_head_page(object);
+ slab = virt_to_slab(object);
- if (unlikely(!PageSlab(page))) {
- WARN_ON(!PageCompound(page));
- return page_size(page);
+ if (unlikely(!slab_test_cache(slab))) {
+ WARN_ON(!slab_test_multipage(slab));
+ return slab_size(slab);
}
- return slab_ksize(page->slab_cache);
+ return slab_ksize(slab->slab_cache);
}
EXPORT_SYMBOL(__ksize);
slub and slob both use struct page here; convert them to struct slab. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- mm/slab.h | 6 +++--- mm/slob.c | 8 ++++---- mm/slub.c | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-)