From patchwork Mon Oct 4 13:46:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12534185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1040BC433EF for ; Mon, 4 Oct 2021 14:44:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5D8A6137D for ; Mon, 4 Oct 2021 14:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B5D8A6137D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 49397940047; Mon, 4 Oct 2021 10:44:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41D5094000B; Mon, 4 Oct 2021 10:44:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BDA5940047; Mon, 4 Oct 2021 10:44:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 185BB94000B for ; Mon, 4 Oct 2021 10:44:13 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C6AFF30C85 for ; Mon, 4 Oct 2021 14:44:12 +0000 (UTC) X-FDA: 78659025144.38.08690F4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 646FF1035DEA for ; Mon, 4 Oct 2021 14:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=rByloetF7rpW2bor0wwNhj+zZqrgq7MTCe4F+n5zJi8=; b=Pj1h9aE32FNWD6pqajXa2uOD+2 OcdKRX3wXFaRQyG3wo79a3d3H/v5VihjmWnqlsg+ua/qe4pLzabFfKVKtWN54FeACpebRtyEobtBI jeeJ5DlJ+8YzF3jPdQ6CZzHauvVNUEYTM9kOepHI6pcMb9xZQzvqr4+5WDtoEwMEFu3ip9xu2phvk 3DpPcLQvfLmIZrNkDJgLJTQLpSwjrLRqTzHcURkhsxvrsQRKT9RqGBcs2AUk7kbObgKDr0ybytWhA DY8KRcARdph4bQkObDSg1sDfY0aN65ULRmuSFufW2KfSSJAgSufxAty6FqSPBzyhC+oizrKzO8D43 RNlA+rcQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXP9z-00H0wX-Rz; Mon, 04 Oct 2021 14:41:56 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 43/62] mm/slub: Convert object_err() to take a struct slab Date: Mon, 4 Oct 2021 14:46:31 +0100 Message-Id: <20211004134650.4031813-44-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004134650.4031813-1-willy@infradead.org> References: <20211004134650.4031813-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 646FF1035DEA X-Stat-Signature: top9kgicby6ngwd36jxsgi6hy96pp5ch Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Pj1h9aE3; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1633358652-474557 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Improves type safety and removes a lot of calls to slab_page(). Also make object_err() static. Signed-off-by: Matthew Wilcox (Oracle) --- 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;