From patchwork Tue Nov 16 00:16:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12620685 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 B283CC433EF for ; Tue, 16 Nov 2021 00:16:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6472863238 for ; Tue, 16 Nov 2021 00:16:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6472863238 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 011A96B0081; Mon, 15 Nov 2021 19:16:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9139D6B0088; Mon, 15 Nov 2021 19:16:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 606A86B0085; Mon, 15 Nov 2021 19:16:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id CBF836B0087 for ; Mon, 15 Nov 2021 19:16:39 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8BBE1805B6 for ; Tue, 16 Nov 2021 00:16:39 +0000 (UTC) X-FDA: 78812877276.27.B88AC5A Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id 0BF229000262 for ; Tue, 16 Nov 2021 00:16:38 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C524721923; Tue, 16 Nov 2021 00:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637021797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TIChoQYP6vFQLCSpQ3KQc+tvdE1SEsYI9D9wNzzWwak=; b=TdUozy2su61l3rbPiXUrnyPVqwPBNB0URshl+98XktxZIWyqM8wC87IwBeYLHi3r9TnVmG VQWJwp0USFB0lwVEEbu9GBkCxdFdDmiZnGiwISrNwLLde2dL/eGWvHVRPl427AFCDSyNnQ C0hN2kr57PJTZq9ECEutGTQ/gpr3JjE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637021797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TIChoQYP6vFQLCSpQ3KQc+tvdE1SEsYI9D9wNzzWwak=; b=uWqYleZZ456CVWsDk4V+xuskdch5/xwSrA40P8QPAsOjfgJJ1MgZHvDxwh9johz9K+KyRF tfs7b7oM85XjgACg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A596713F72; Tue, 16 Nov 2021 00:16:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aAurJ2X4kmFjXAAAMHmgww (envelope-from ); Tue, 16 Nov 2021 00:16:37 +0000 From: Vlastimil Babka To: Matthew Wilcox , linux-mm@kvack.org, Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: Vlastimil Babka Subject: [RFC PATCH 05/32] mm: Convert virt_to_cache() to use struct slab Date: Tue, 16 Nov 2021 01:16:01 +0100 Message-Id: <20211116001628.24216-6-vbabka@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211116001628.24216-1-vbabka@suse.cz> References: <20211116001628.24216-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=971; i=vbabka@suse.cz; h=from:subject; bh=8/0Ul15tAsgzHf3fuBLfKIWbs+hMIDMrUChEVtHsD+c=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhkvgpcdvbDmxAYvcd4rwoPa7/ht3CZ3jODEMg5vQU pX0CHYWJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYZL4KQAKCRDgIcpz8YmpENoDCA CEPLu5gU6dLLZOsr8xTie9z8VcO+QMUqV1fxBXbfvdhDnh9TbkwZjj7GNPCIG5/HiEgQ2UYjmBaOYN XglX7ep2P37SlIjtG+6Y4Ya9RJFtCkLlwMjadru08Q+0Gcm1BSzqj0bGaaUJ/RfjxrqKUftOt9lEwd nN55vRzjSAV5WHlH3gfaOE9whR1imPLiKpchK5Vbk9XtX3mPH9AK2ZeHVuOLt88U8532zea+Ut3XUl MXDndztXuUziDGB9WCPourHCyrQ3YVZdxvhgB+9aZRbKpPMBtm1VHWWG/0kUlRCPtk0RaSx5xsGDTL zPwAeT1gg5DocMPaloKzDv/YGKm9Ge X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Stat-Signature: br4d4uc4gyx8gpqx5z9a4z7szo498ok5 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TdUozy2s; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=uWqYleZZ; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0BF229000262 X-HE-Tag: 1637021798-869217 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: From: "Matthew Wilcox (Oracle)" This function is entirely self-contained, so can be converted from page to slab. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Vlastimil Babka --- mm/slab.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index be42a467eeac..5203d19922b9 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -574,13 +574,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(!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(struct slab *slab, int order,