From patchwork Mon Oct 4 13:46:05 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: 12534019 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 AF33EC433F5 for ; Mon, 4 Oct 2021 14:08:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 58E5C61251 for ; Mon, 4 Oct 2021 14:08:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 58E5C61251 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 02958940028; Mon, 4 Oct 2021 10:08:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1B2794000B; Mon, 4 Oct 2021 10:08:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3216940028; Mon, 4 Oct 2021 10:08:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D40C594000B for ; Mon, 4 Oct 2021 10:08:00 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8D9791827E8F5 for ; Mon, 4 Oct 2021 14:08:00 +0000 (UTC) X-FDA: 78658933920.19.5629CE8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 44071500151C for ; Mon, 4 Oct 2021 14:08:00 +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=XgmwUKIS46s2UOAO4nXRxiUqvAtUpV6qEuc4BH2qxP4=; b=I8jikpASYwPXoFk1GB45fmboAU IX0xB1OgTZaTfOQg/lngO5zduiu3JKCvbL3dUt/3im/Mz6LlycYpbn4eQf4quiGBAuogUc3XKE+v6 oOFNYNp4bFxi16PQpMXo5VBbp4KnCI9i73im0NoynA+UpaljMfIC1z9jMLvPsasozptLpEN8XTB2i Lni6eBUe+cdTVuMexs2b7+4bZUCCemd/DbfWgtv69j6y+a2MaLPMkZ3u/ca277riMio74F6x0jlVz aKCvRX0gTQYWYTgd4h/mISP7rBtIolwjA7dOVRvUPRjXLfcN9yNqoNf1vXEiqIvvevJ1IBrSB36BL 9o+lbeDQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXObI-00Gx5T-MU; Mon, 04 Oct 2021 14:06:17 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 17/62] mm/slub: Convert validate_slab() to take a struct slab Date: Mon, 4 Oct 2021 14:46:05 +0100 Message-Id: <20211004134650.4031813-18-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 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=I8jikpAS; spf=none (imf04.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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 44071500151C X-Stat-Signature: bkkt4o8ds7mps9y867st7r76r9ejuj6y X-HE-Tag: 1633356480-430684 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: Also convert validate_slab_node to use a struct slab. Adds a little typesafety. Signed-off-by: Matthew Wilcox (Oracle) --- mm/slub.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index fdf3dbd4665f..5e10a9cc6939 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4956,42 +4956,42 @@ static int count_total(struct page *page) #endif #ifdef CONFIG_SLUB_DEBUG -static void validate_slab(struct kmem_cache *s, struct page *page, +static void validate_slab(struct kmem_cache *s, struct slab *slab, unsigned long *obj_map) { void *p; - void *addr = page_address(page); + void *addr = slab_address(slab); unsigned long flags; - slab_lock(page, &flags); + slab_lock(slab_page(slab), &flags); - if (!check_slab(s, page) || !on_freelist(s, page, NULL)) + if (!check_slab(s, slab_page(slab)) || !on_freelist(s, slab_page(slab), NULL)) goto unlock; /* Now we know that a valid freelist exists */ - __fill_map(obj_map, s, page); - for_each_object(p, s, addr, page->objects) { + __fill_map(obj_map, s, slab_page(slab)); + for_each_object(p, s, addr, slab->objects) { u8 val = test_bit(__obj_to_index(s, addr, p), obj_map) ? SLUB_RED_INACTIVE : SLUB_RED_ACTIVE; - if (!check_object(s, page, p, val)) + if (!check_object(s, slab_page(slab), p, val)) break; } unlock: - slab_unlock(page, &flags); + slab_unlock(slab_page(slab), &flags); } static int validate_slab_node(struct kmem_cache *s, struct kmem_cache_node *n, unsigned long *obj_map) { unsigned long count = 0; - struct page *page; + struct slab *slab; unsigned long flags; spin_lock_irqsave(&n->list_lock, flags); - list_for_each_entry(page, &n->partial, slab_list) { - validate_slab(s, page, obj_map); + list_for_each_entry(slab, &n->partial, slab_list) { + validate_slab(s, slab, obj_map); count++; } if (count != n->nr_partial) { @@ -5003,8 +5003,8 @@ static int validate_slab_node(struct kmem_cache *s, if (!(s->flags & SLAB_STORE_USER)) goto out; - list_for_each_entry(page, &n->full, slab_list) { - validate_slab(s, page, obj_map); + list_for_each_entry(slab, &n->full, slab_list) { + validate_slab(s, slab, obj_map); count++; } if (count != atomic_long_read(&n->nr_slabs)) {