From patchwork Mon Oct 4 13:45:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12533979 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 75A36C433F5 for ; Mon, 4 Oct 2021 13:55:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32CED6121F for ; Mon, 4 Oct 2021 13:55:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 32CED6121F 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 A984094001A; Mon, 4 Oct 2021 09:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A474794000B; Mon, 4 Oct 2021 09:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9361A94001A; Mon, 4 Oct 2021 09:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 80BCB94000B for ; Mon, 4 Oct 2021 09:55:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2C36A2BA83 for ; Mon, 4 Oct 2021 13:55:55 +0000 (UTC) X-FDA: 78658903470.03.3D2337C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id D5ED7F00240C for ; Mon, 4 Oct 2021 13:55:54 +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=dbX4+bcrCti9QCWaHhUTDascE/YvuKgq/0CFKLieCbY=; b=WrFLLSBx75MRY/GEyCp78JCnqK Hg9C4Eb+7/nEw+sKMCuRNeOuqlE37brDqRc7z4iaIH2BP6kALbsAwsMzmSTkDuKRk5d79GHO7Gyz3 P0EVyOjBHm3/npOoaDUIrUtPAaub8147lUlz8t0aMLgCGghOCr+EqJOumKCA66PUNJHprGQufdzWX xEir+Y2+mArg0iE4ixCWHPRRCLUQjw1wsfEUQcGzMN543O8tTVcxJSmyzaHLzl1RFPa2JXig8FdSo 5p5Mmb0Mt1t68K/jrtUFhxZsleVnQdlhHqRQH2ltKMlOvgWf9MB0zQy/Hi5iFGSCRaTlQjOZ0kWlP decBlw2Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXOPQ-00GvXQ-Vw; Mon, 04 Oct 2021 13:54:08 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 05/62] mm: Convert virt_to_cache() to use struct slab Date: Mon, 4 Oct 2021 14:45:53 +0100 Message-Id: <20211004134650.4031813-6-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: D5ED7F00240C X-Stat-Signature: 7noarfkips6fxkasn1tbw3eoies4zfr9 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WrFLLSBx; spf=none (imf11.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: 1633355754-133296 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: This function is entirely self-contained, so can be converted from page to slab. Signed-off-by: Matthew Wilcox (Oracle) --- mm/slab.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 305cc8c7fed8..3c691ef6b492 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -480,13 +480,13 @@ static inline void memcg_slab_free_hook(struct kmem_cache *s, static inline struct kmem_cache *virt_to_cache(const void *obj) { - struct page *page; + struct slab *slab; - page = virt_to_head_page(obj); - if (WARN_ONCE(!PageSlab(page), "%s: Object is not a Slab page!\n", + slab = virt_to_slab(obj); + if (WARN_ONCE(!SlabAllocation(slab), "%s: Object is not a Slab page!\n", __func__)) return NULL; - return page->slab_cache; + return slab->slab_cache; } static __always_inline void account_slab_page(struct page *page, int order,