From patchwork Thu May 18 17:33:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13247151 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B29AC7EE23 for ; Thu, 18 May 2023 17:34:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBEE8900009; Thu, 18 May 2023 13:34:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C481C900003; Thu, 18 May 2023 13:34:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B110A900009; Thu, 18 May 2023 13:34:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A1AFF900003 for ; Thu, 18 May 2023 13:34:24 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6FC5380902 for ; Thu, 18 May 2023 17:34:24 +0000 (UTC) X-FDA: 80804074848.02.1613AF2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id C5628140019 for ; Thu, 18 May 2023 17:34:22 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684431262; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=35xPKuIoBzBBtPc7oLgirz1u4PdrAIKlSY99QdYwnw8=; b=BJylibUD/TFBPfgEXMkQ0zJN7b7tnZ1XbHgF7jM6kLbz5gXezz8xw4t9slrEJ0zfqYgZ56 CwSpKmTwGC96rGKteLUDIYD0/J6FchKOGYI9VYJhy7Mpko+YIWRHh9a8Pl8+21y6+qqAyl 2OEIXsz3g/taIY7GCfQzNMWmkRG7uao= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684431262; a=rsa-sha256; cv=none; b=xYGP5joLUXskYxJfNqjWXH8gaF4f1Epapm0xtDh22j8z2ZxP12Jkc+LqjWZC3Df/zdLSas /SdJbj7296RvnlgOrvAtxC3F/haPgneoQy3TFLvQE0dTn46knZrzz843OedK8qHICPNMR0 w4ckhhQ1iSfgnZUeiYvzYFxBry591Aw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D6CA3642F3; Thu, 18 May 2023 17:34:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D7A8C433D2; Thu, 18 May 2023 17:34:17 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , Greg Kroah-Hartman Cc: Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Robin Murphy , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 03/15] mm/slab: Simplify create_kmalloc_cache() args and make it static Date: Thu, 18 May 2023 18:33:51 +0100 Message-Id: <20230518173403.1150549-4-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518173403.1150549-1-catalin.marinas@arm.com> References: <20230518173403.1150549-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C5628140019 X-Rspam-User: X-Stat-Signature: shhyro89xe633k9p1bwt3h3hqmt7pit7 X-Rspamd-Server: rspam03 X-HE-Tag: 1684431262-153188 X-HE-Meta: U2FsdGVkX19u5Xfwf/75YGxQAaS7mAITIOk1TCkK9P2Fl2oMbCNi7J+WE9Y+KlTGhHzfUAtDDwZFYkzpUx5xa7HyI2ELlmhq/O0ewe7aaItsTTENMWEztRClAyCNyTTQmBjVt245ykPodTrumiW3gH3hhs0m3rFYWMipDKyCCpuhZZr6Xj3D+6zkzi7EuAaSmipwnPArVtNFBTloC4dzY/dwCPA8vb7znc6KyWSwtvIaRaELGHdAsvdNX3ZsHKvojdncAAhaJpa+7FEY599Q841z3MwS4gwZZ2fkb//k+gyiCMLSkr5q3loMYBnttWwZE3FrvvU+V1k/oJf8G1w1sgruy9CwU2tFmm/pkb7WUsOINzijVATkUDnc6O4DgHZrJ4dOtjheM9ZC2U+wfXl3uNwUO58VLiJcMosgg27Pfv4de4rkoukvpEM024OKAgKUZus9ao2roCWES4yskJa/NrKnGkxY7T76hAhNnai4mhtxA2lG2I6Km2djncnn2Dkc0VAz50rfroF6SUQZg7qRCRdOYbkeAzW5zNQuGR3Tu/7JS+EQxYy3Iy29HKQ57EYp7Rp+/V16hBltUgkYS9gA/EPuyZZKiFotBo8PbtCSzbDM6XVTpEK9jAqRxK/KP+lkOSk4fuq4vxXAWqf8cZVkZ+KpD4thbdSFF9fj936XoO2fVbwAdixkU0njMKhpIh5W5z0C16AtSe+d375EtOoNPv6usH1hyplD3jSkKtKROuOmksNZT3KSKNQfgQRYQn4O+vconYUiAqmgYlq9W7M0NdDMwJ0Q0Bcg1uSNEPOa4nShzTa4i3ZS8tMHejovtb17BfK3Mr32WIirS9WWbdgB1QDrvKFjsnPu78X5vPpeKDKqLrwv28rUY1w83ifw7GuibXpRVOOEYpuH/kGUrJyFM0wKZd9eaOlA3k5N/Wv+6OURVeeS82gwsuY/C23Ou96mwjmhIgG5naX3iZKpVVw +jcVSvDM mSkb09CpyOX4xJr9LzJVEbUId9EfqiQPDnJDPhkBdK9UjJgyAcdv59kQcVJUm6XROCF3xwNG3TtcNydSaDBTs+ADlxvSrWrcmOowyBOEGak1I0woyj3+VotKR6t3pIzj34xxNm8GB4X0AXit5ciEnc9aVfdKeISVaKjsMvAguDf3v+5lZ9EVh1zpzYKvSG6qAcP0WMcnVU/1nUNfqXpYmMlY1qfrIGhy4wv3LRRPXv6M5gXRIyfqotx478v1rZCMhh6lJ83pt29NL9PHGZNxC1H9Horvjn6cJq3HNab+QzgGREV++ZB8+3NR+8i63zn98RDLzsMwoIdBY0sHVco83+INnA4iITCahaBNRQJ5eo/StOgaQBRwSW4zbXRkKPcXNA3nIMSnO3eIxwL+wMzdltpMS53JuztrYPHZjj91J1tgBsMqh8kk4u4DkVaFUq/EbKtHZo3j6w33NRkWLMEdX9tavgqkvBVTUQ3ZBhKzusKD36FxDrNP+lVQB5LcrmmYexwwvUXG6IxLE+nUk7c2TzVZVxktDeJbGroIrfo9hnRaFSoKaUr97wbmv2hvG1b2QCHqy 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: In the slab variant of kmem_cache_init(), call new_kmalloc_cache() instead of initialising the kmalloc_caches array directly. With this, create_kmalloc_cache() is now only called from new_kmalloc_cache() in the same file, so make it static. In addition, the useroffset argument is always 0 while usersize is the same as size. Remove them. Signed-off-by: Catalin Marinas Cc: Andrew Morton --- mm/slab.c | 6 +----- mm/slab.h | 5 ++--- mm/slab_common.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index bb57f7fdbae1..b7817dcba63e 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1240,11 +1240,7 @@ void __init kmem_cache_init(void) * Initialize the caches that provide memory for the kmem_cache_node * structures first. Without this, further allocations will bug. */ - kmalloc_caches[KMALLOC_NORMAL][INDEX_NODE] = create_kmalloc_cache( - kmalloc_info[INDEX_NODE].name[KMALLOC_NORMAL], - kmalloc_info[INDEX_NODE].size, - ARCH_KMALLOC_FLAGS, 0, - kmalloc_info[INDEX_NODE].size); + new_kmalloc_cache(INDEX_NODE, KMALLOC_NORMAL, ARCH_KMALLOC_FLAGS); slab_state = PARTIAL_NODE; setup_kmalloc_cache_index_table(); diff --git a/mm/slab.h b/mm/slab.h index f01ac256a8f5..592590fcddae 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -255,9 +255,8 @@ gfp_t kmalloc_fix_flags(gfp_t flags); /* Functions provided by the slab allocators */ int __kmem_cache_create(struct kmem_cache *, slab_flags_t flags); -struct kmem_cache *create_kmalloc_cache(const char *name, unsigned int size, - slab_flags_t flags, unsigned int useroffset, - unsigned int usersize); +void __init new_kmalloc_cache(int idx, enum kmalloc_cache_type type, + slab_flags_t flags); extern void create_boot_cache(struct kmem_cache *, const char *name, unsigned int size, slab_flags_t flags, unsigned int useroffset, unsigned int usersize); diff --git a/mm/slab_common.c b/mm/slab_common.c index 607249785c07..7f069159aee2 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -658,17 +658,16 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, s->refcount = -1; /* Exempt from merging for now */ } -struct kmem_cache *__init create_kmalloc_cache(const char *name, - unsigned int size, slab_flags_t flags, - unsigned int useroffset, unsigned int usersize) +static struct kmem_cache *__init create_kmalloc_cache(const char *name, + unsigned int size, + slab_flags_t flags) { struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT); if (!s) panic("Out of memory when creating slab %s\n", name); - create_boot_cache(s, name, size, flags | SLAB_KMALLOC, useroffset, - usersize); + create_boot_cache(s, name, size, flags | SLAB_KMALLOC, 0, size); list_add(&s->list, &slab_caches); s->refcount = 1; return s; @@ -863,7 +862,7 @@ void __init setup_kmalloc_cache_index_table(void) } } -static void __init +void __init new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) { if ((KMALLOC_RECLAIM != KMALLOC_NORMAL) && (type == KMALLOC_RECLAIM)) { @@ -880,8 +879,7 @@ new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) kmalloc_caches[type][idx] = create_kmalloc_cache( kmalloc_info[idx].name[type], - kmalloc_info[idx].size, flags, 0, - kmalloc_info[idx].size); + kmalloc_info[idx].size, flags); /* * If CONFIG_MEMCG_KMEM is enabled, disable cache merging for