]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm/slub: Convert alloc_debug_processing() to struct slab
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 2 Oct 2021 01:41:36 +0000 (21:41 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 4 Oct 2021 13:18:00 +0000 (09:18 -0400)
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) <willy@infradead.org>
mm/slub.c

index a8ea2779edf4d948207a23a0780c1c991496dbb2..eb4286886c3ea36f79bbd79d0e2130e1bd7198e4 100644 (file)
--- 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 {