]> www.infradead.org Git - users/willy/linux.git/commitdiff
mm/slub: Convert shuffle_freelist to struct slab
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 1 Oct 2021 21:54:24 +0000 (17:54 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 4 Oct 2021 13:17:59 +0000 (09:17 -0400)
Improve type safety.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/slub.c

index 75a411d6b76e62115a6c47fba7033281fd85b256..9a67dda37951b46ec4b91bdbfaa0d15bc2caed52 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1831,32 +1831,32 @@ static void *next_freelist_entry(struct kmem_cache *s, struct page *page,
 }
 
 /* Shuffle the single linked freelist based on a random pre-computed sequence */
-static bool shuffle_freelist(struct kmem_cache *s, struct page *page)
+static bool shuffle_freelist(struct kmem_cache *s, struct slab *slab)
 {
        void *start;
        void *cur;
        void *next;
-       unsigned long idx, pos, page_limit, freelist_count;
+       unsigned long idx, pos, slab_limit, freelist_count;
 
-       if (page->objects < 2 || !s->random_seq)
+       if (slab->objects < 2 || !s->random_seq)
                return false;
 
        freelist_count = oo_objects(s->oo);
        pos = get_random_int() % freelist_count;
 
-       page_limit = page->objects * s->size;
-       start = fixup_red_left(s, page_address(page));
+       slab_limit = slab->objects * s->size;
+       start = fixup_red_left(s, slab_address(slab));
 
        /* First entry is used as the base of the freelist */
-       cur = next_freelist_entry(s, page, &pos, start, page_limit,
+       cur = next_freelist_entry(s, slab_page(slab), &pos, start, slab_limit,
                                freelist_count);
-       cur = setup_object(s, page, cur);
-       page->freelist = cur;
+       cur = setup_object(s, slab_page(slab), cur);
+       slab->freelist = cur;
 
-       for (idx = 1; idx < page->objects; idx++) {
-               next = next_freelist_entry(s, page, &pos, start, page_limit,
+       for (idx = 1; idx < slab->objects; idx++) {
+               next = next_freelist_entry(s, slab_page(slab), &pos, start, slab_limit,
                        freelist_count);
-               next = setup_object(s, page, next);
+               next = setup_object(s, slab_page(slab), next);
                set_freepointer(s, cur, next);
                cur = next;
        }
@@ -1870,7 +1870,7 @@ static inline int init_cache_random_seq(struct kmem_cache *s)
        return 0;
 }
 static inline void init_freelist_randomization(void) { }
-static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page)
+static inline bool shuffle_freelist(struct kmem_cache *s, struct slab *slab)
 {
        return false;
 }
@@ -1926,7 +1926,7 @@ static struct slab *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
 
        setup_page_debug(s, slab_page(slab), start);
 
-       shuffle = shuffle_freelist(s, slab_page(slab));
+       shuffle = shuffle_freelist(s, slab);
 
        if (!shuffle) {
                start = fixup_red_left(s, start);