From: Matthew Wilcox (Oracle) Date: Sat, 2 Oct 2021 01:41:36 +0000 (-0400) Subject: mm/slub: Convert alloc_debug_processing() to struct slab X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=54225e97bbbca573d0314134b671a924eb068efe;p=users%2Fwilly%2Flinux.git mm/slub: Convert alloc_debug_processing() to struct slab Push the slab conversion all the way down to alloc_consistency_checks(), but actually use the fact that it's a slab in alloc_debug_processing(). Signed-off-by: Matthew Wilcox (Oracle) --- diff --git a/mm/slub.c b/mm/slub.c index a8ea2779edf4..eb4286886c3e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1261,48 +1261,48 @@ void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr) } static inline int alloc_consistency_checks(struct kmem_cache *s, - struct page *page, void *object) + struct slab *slab, void *object) { - if (!check_slab(s, page)) + if (!check_slab(s, slab_page(slab))) return 0; - if (!check_valid_pointer(s, page, object)) { - object_err(s, page, object, "Freelist Pointer check fails"); + if (!check_valid_pointer(s, slab_page(slab), object)) { + object_err(s, slab_page(slab), object, "Freelist Pointer check fails"); return 0; } - if (!check_object(s, page, object, SLUB_RED_INACTIVE)) + if (!check_object(s, slab_page(slab), object, SLUB_RED_INACTIVE)) return 0; return 1; } static noinline int alloc_debug_processing(struct kmem_cache *s, - struct page *page, + struct slab *slab, void *object, unsigned long addr) { if (s->flags & SLAB_CONSISTENCY_CHECKS) { - if (!alloc_consistency_checks(s, page, object)) + if (!alloc_consistency_checks(s, slab, object)) goto bad; } /* Success perform special debug activities for allocs */ if (s->flags & SLAB_STORE_USER) set_track(s, object, TRACK_ALLOC, addr); - trace(s, page, object, 1); + trace(s, slab_page(slab), object, 1); init_object(s, object, SLUB_RED_ACTIVE); return 1; bad: - if (PageSlab(page)) { + if (slab_test_cache(slab)) { /* - * If this is a slab page then lets do the best we can + * If this is a slab then lets do the best we can * to avoid issues in the future. Marking all objects * as used avoids touching the remaining objects. */ slab_fix(s, "Marking all objects used"); - page->inuse = page->objects; - page->freelist = NULL; + slab->inuse = slab->objects; + slab->freelist = NULL; } return 0; } @@ -1604,7 +1604,7 @@ static inline void setup_page_debug(struct kmem_cache *s, struct page *page, void *addr) {} static inline int alloc_debug_processing(struct kmem_cache *s, - struct page *page, void *object, unsigned long addr) { return 0; } + struct slab *slab, void *object, unsigned long addr) { return 0; } static inline int free_debug_processing( struct kmem_cache *s, struct slab *slab, @@ -3006,7 +3006,7 @@ new_objects: check_new_slab: if (kmem_cache_debug(s)) { - if (!alloc_debug_processing(s, slab_page(slab), freelist, addr)) { + if (!alloc_debug_processing(s, slab, freelist, addr)) { /* Slab failed checks. Next slab needed */ goto new_slab; } else {