From patchwork Mon Oct 4 13:46:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12534045 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 1B3A3C433EF for ; Mon, 4 Oct 2021 14:13:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C5C5C61216 for ; Mon, 4 Oct 2021 14:13:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C5C5C61216 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 5A2D794002B; Mon, 4 Oct 2021 10:13:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5526C94000B; Mon, 4 Oct 2021 10:13:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41B0394002B; Mon, 4 Oct 2021 10:13:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 32F9D94000B for ; Mon, 4 Oct 2021 10:13:06 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EFA5F2BC02 for ; Mon, 4 Oct 2021 14:13:05 +0000 (UTC) X-FDA: 78658946730.27.91C73AC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id A2BEA70021F8 for ; Mon, 4 Oct 2021 14:13:05 +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=TAxo61k4BjUZoubEyus1/GNA+hXfkFB7KfhsvaZqgpY=; b=BBQ6oBM9hxylEt6ce95DvoJS/o fQv7vwACFUtoMsF9p9lsUWTsABIIMaWyVzcHJG1vIxgTr8c+rCHYcBxIiVbr+vCHjqVFz/vu1r9WK tVg3NH+m7k7C8SupqxCdDvy6eXbcXLsrCJh1DLHA0nRrz60/MbTBgWs4uxmUXhHntzzVb+Q/upOLd I+SnSVQ+b+j454Jll1sDN5nQ/2UTvS7fBi+vBTioRHIB6U4Mf/r6hIVyeUug9pCJBfpVd8wCMpyTR sX4ITjtlVi3W4HrUSZNUM7kO3reJXXlNV8mjXnhvUDEKyZQKXeGMHkQahtD3x1Qjc8Cd2XC5mnGlz s7+a9NMw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXOfl-00GxiN-9t; Mon, 04 Oct 2021 14:10:49 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 20/62] mm/slub: Convert __kmem_cache_do_shrink() to struct slab Date: Mon, 4 Oct 2021 14:46:08 +0100 Message-Id: <20211004134650.4031813-21-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: A2BEA70021F8 X-Stat-Signature: 6rydgjjeuxuwhzo6t3jyx65x5tcak3qe Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BBQ6oBM9; spf=none (imf02.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: 1633356785-590481 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: Adds a little type safety. Signed-off-by: Matthew Wilcox (Oracle) --- mm/slub.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f760accb0feb..ea7f8d9716e0 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -4560,8 +4560,7 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s) int node; int i; struct kmem_cache_node *n; - struct page *page; - struct page *t; + struct slab *slab, *t; struct list_head discard; struct list_head promote[SHRINK_PROMOTE_MAX]; unsigned long flags; @@ -4578,22 +4577,22 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s) * Build lists of slabs to discard or promote. * * Note that concurrent frees may occur while we hold the - * list_lock. page->inuse here is the upper limit. + * list_lock. slab->inuse here is the upper limit. */ - list_for_each_entry_safe(page, t, &n->partial, slab_list) { - int free = page->objects - page->inuse; + list_for_each_entry_safe(slab, t, &n->partial, slab_list) { + int free = slab->objects - slab->inuse; - /* Do not reread page->inuse */ + /* Do not reread slab->inuse */ barrier(); /* We do not keep full slabs on the list */ BUG_ON(free <= 0); - if (free == page->objects) { - list_move(&page->slab_list, &discard); + if (free == slab->objects) { + list_move(&slab->slab_list, &discard); n->nr_partial--; } else if (free <= SHRINK_PROMOTE_MAX) - list_move(&page->slab_list, promote + free - 1); + list_move(&slab->slab_list, promote + free - 1); } /* @@ -4606,8 +4605,8 @@ static int __kmem_cache_do_shrink(struct kmem_cache *s) spin_unlock_irqrestore(&n->list_lock, flags); /* Release empty slabs */ - list_for_each_entry_safe(page, t, &discard, slab_list) - discard_slab(s, page); + list_for_each_entry_safe(slab, t, &discard, slab_list) + discard_slab(s, slab_page(slab)); if (slabs_node(s, node)) ret = 1;