From patchwork Mon Oct 4 13:46:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12534167 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 27DC6C433EF for ; Mon, 4 Oct 2021 14:39:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 985EA61372 for ; Mon, 4 Oct 2021 14:39:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 985EA61372 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 36183940042; Mon, 4 Oct 2021 10:39:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 311B094000B; Mon, 4 Oct 2021 10:39:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2003E940042; Mon, 4 Oct 2021 10:39:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0FEB794000B for ; Mon, 4 Oct 2021 10:39:15 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C5038181A88E4 for ; Mon, 4 Oct 2021 14:39:14 +0000 (UTC) X-FDA: 78659012628.14.80EBBA4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 8C321F000EE0 for ; Mon, 4 Oct 2021 14:39:14 +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=6WzDPlePuewKHlznd/kzbUBpVCH7kMdexvOTiAufxvY=; b=TGSSofliDqLY9q7M2DubIVtXTm ZkuaCWyG9WBWLXiIglcH+/Sf0L/Tz9YU83pK4lsTW68seennb1jE1rvtytSRCHa9ymxOcn3HvzFIj OFSkDyQdleJ4EWkHunW+3iTnKIE3QQ2AcvkqHTEXsnBKIyiinXyUojS2CeF1AHF7By6JRdBPU5d3h Nxj4rqQysE0AoAl8n3qBFckeJ95pJhRGJA0BdemZHj99sK92hOnroDMTAO0YZl/8iJwjIz/6Fbpkx zsuQza5vwINoj8TgiXnZO1LcOCDLLebX7ylha8pA8i97h3im7jhqUeAMTaHELNkV0H4sfpHL7iwnQ J1mkTfnA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXP5Z-00H0XM-0r; Mon, 04 Oct 2021 14:37:19 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 38/62] mm/slub: Convert alloc_debug_processing() to struct slab Date: Mon, 4 Oct 2021 14:46:26 +0100 Message-Id: <20211004134650.4031813-39-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: rspam02 X-Rspamd-Queue-Id: 8C321F000EE0 X-Stat-Signature: 6hdqx5siwb5ahna67x13qnc7xos5udeh Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TGSSofli; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1633358354-939061 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: 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) --- mm/slub.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, 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 {