Improves type safety and removes a lot of calls to slab_page(). Also make object_err() static. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- include/linux/slub_def.h | 3 --- mm/slub.c | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 3cc64e9f988c..63eae033d713 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h @@ -165,9 +165,6 @@ static inline void sysfs_slab_release(struct kmem_cache *s) } #endif -void object_err(struct kmem_cache *s, struct page *page, - u8 *object, char *reason); - void *fixup_red_left(struct kmem_cache *s, void *p); static inline void *nearest_obj(struct kmem_cache *cache, struct page *page, diff --git a/mm/slub.c b/mm/slub.c index 524e3c7eac30..a93a6d679de2 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -799,12 +799,15 @@ static void slab_fix(struct kmem_cache *s, char *fmt, ...) va_end(args); } +static void object_err(struct kmem_cache *s, struct slab *slab, + u8 *object, char *reason); + static bool freelist_corrupted(struct kmem_cache *s, struct slab *slab, void **freelist, void *nextfree) { if ((s->flags & SLAB_CONSISTENCY_CHECKS) && !check_valid_pointer(s, slab, nextfree) && freelist) { - object_err(s, slab_page(slab), *freelist, "Freechain corrupt"); + object_err(s, slab, *freelist, "Freechain corrupt"); *freelist = NULL; slab_fix(s, "Isolate corrupted freechain"); return true; @@ -852,14 +855,14 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) dump_stack(); } -void object_err(struct kmem_cache *s, struct page *page, +static void object_err(struct kmem_cache *s, struct slab *slab, u8 *object, char *reason) { if (slab_add_kunit_errors()) return; slab_bug(s, "%s", reason); - print_trailer(s, page, object); + print_trailer(s, slab_page(slab), object); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); } @@ -1073,7 +1076,7 @@ static int check_object(struct kmem_cache *s, struct slab *slab, /* Check free pointer validity */ if (!check_valid_pointer(s, slab, get_freepointer(s, p))) { - object_err(s, slab_page(slab), p, "Freepointer corrupt"); + object_err(s, slab, p, "Freepointer corrupt"); /* * No choice but to zap it and thus lose the remainder * of the free objects in this slab. May cause @@ -1127,7 +1130,7 @@ static int on_freelist(struct kmem_cache *s, struct slab *slab, void *search) return 1; if (!check_valid_pointer(s, slab, fp)) { if (object) { - object_err(s, slab_page(slab), object, + object_err(s, slab, object, "Freechain corrupt"); set_freepointer(s, object, NULL); } else { @@ -1267,7 +1270,7 @@ static inline int alloc_consistency_checks(struct kmem_cache *s, return 0; if (!check_valid_pointer(s, slab, object)) { - object_err(s, slab_page(slab), object, "Freelist Pointer check fails"); + object_err(s, slab, object, "Freelist Pointer check fails"); return 0; } @@ -1316,7 +1319,7 @@ static inline int free_consistency_checks(struct kmem_cache *s, } if (on_freelist(s, slab, object)) { - object_err(s, slab_page(slab), object, "Object already free"); + object_err(s, slab, object, "Object already free"); return 0; } @@ -1332,8 +1335,7 @@ static inline int free_consistency_checks(struct kmem_cache *s, object); dump_stack(); } else - object_err(s, slab_page(slab), object, - "slab pointer corrupt."); + object_err(s, slab, object, "slab pointer corrupt."); return 0; } return 1; -- 2.32.0