From patchwork Wed May 31 15:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13262456 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 A34F3C77B7A for ; Wed, 31 May 2023 15:48:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BC468E0007; Wed, 31 May 2023 11:48:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21CD38E0001; Wed, 31 May 2023 11:48:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 132CF8E0007; Wed, 31 May 2023 11:48:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 047DB8E0001 for ; Wed, 31 May 2023 11:48:58 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A09731402B0 for ; Wed, 31 May 2023 15:48:57 +0000 (UTC) X-FDA: 80850983514.03.FD41A23 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id DC54D120014 for ; Wed, 31 May 2023 15:48:55 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.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=1685548136; 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=ULKZrOAewXWi2dFKjyVmdgrPOP6CfMIQEtQ8GZRBMcPrnmr71D26kja1hjcl7Nrh0NWSLm F4jOoaYIHFjp1Ufiew6P93oS4Ug53JyQkrrUuCEGsPkFxmqEYKvK30UA+afBZIFW83NS9n SLAc6NQkZwo33h/9U/rQpXpyPgdNuOU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685548136; a=rsa-sha256; cv=none; b=TMVw/7bcsncG2QNXwZY/x5mazFM6AaCws4wQuZsylsiX1ZcfH77E1dNKekz0Cdy/xpKFIT 3JphQlDOzNFXMZmNSWvPVtHxE0kH8KAN7QIOGkzWh+zAx2mcp4HUTv+b4y3pmYaud30oMa fGl6o6O2cr2KjVyI1RfV34xqTucxywY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.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 DFEAE63D98; Wed, 31 May 2023 15:48:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F0FAC433EF; Wed, 31 May 2023 15:48:50 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Christoph Hellwig , Robin Murphy Cc: Arnd Bergmann , Greg Kroah-Hartman , 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" , Jonathan Cameron , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 03/17] mm/slab: Simplify create_kmalloc_cache() args and make it static Date: Wed, 31 May 2023 16:48:22 +0100 Message-Id: <20230531154836.1366225-4-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531154836.1366225-1-catalin.marinas@arm.com> References: <20230531154836.1366225-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Stat-Signature: a1djorr5n1uod9hb6yrfc4gwpnuqwt4w X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DC54D120014 X-Rspam-User: X-HE-Tag: 1685548135-14324 X-HE-Meta: U2FsdGVkX19ZiSL6h59aV29BG+T78s9RmihAzHCH9Ise7/EjYhkAGgWx5GdOlImuQUPwhMR6dDA97f/iSEfqxzk1Nm6N34l8wdj6ET9jcS9EgU3Qxo1X5oytRbx39ffE8oZzCExxkUw0qN2SYFQidLC19AO26Uyu1AlKxY1Jx68hz38e/N8+uLfSxug83mlNfY/PNTO+WLonWgGRPErpHd51//sYEhJsZRpSF1pLvm8v+NP88MWahSvJ1QU19oMPLTthpcboZaUULrEdFIYF7on8p9HI2Q/njGTTb6VAXplHALnwVQj/min7HvhIqbgb+K8XPJeO/KcHSLA+UdEZdBgei38ZtH6t01j4k8mhqs470FdhvuhARJVqEDnaP7RMVT2vuXeMxaekZvhilGl88JoQAl8c1wpj5LmXRmC81jDww9YtxrpPdQtaPRVIQz9m+BHGZsX81toevhhRDB+UKIZw+6cwPlT6pScEv2RZt6i7L0HXpX6weGXASpOFrCFu0N7H0q4+h4Bwbwvo+/lFjKHcN1mDeIq9QylGMS5NQD3ffFdBeyHM7eW9qJkDq8sIdo4/O+TFdX7KMbG6S/FAPC6Wx1TQXMwZpkFLgnYIYoPnwoer7C92zZfFSOZreykHNiCvLwDLnxXf+FFPo9h03Ey0ak97IHVlBkpcBT5k2tG7ZEsuj5GmQO3g6uXUY8celLE4t++ITR3xNdN3AwkwG1KiOTc09Xq5wU5+cyNkI+pbeq257Zg4tVO9XjsZLEROOGycDrEHPUH+/4P/AZ7ARCH1dmCO+ctFwXEpabxXanFQKjREdlESp9yV2bmoFWdgw/v39xG6CIq7Rj5sz8/VEJcdd1NLAyagw0YYDV/ipeKA6RBEGpIX2pZNJjDrSoF4NT6yddh1fcKzOaidRl573ylBDnAnpNLUr61Kaj9FsDbsaTIzKvYQ64T/4lFniCh/t34omJoBrNfbMkyvbEP NGzr67Mn 9bEduY6aWWuuSY4AR0uz/8a8R9/wKVnoBHt7kjk0ZWLlHvtPlm8w3ou4R2SKOLrFbcqhTS6q3VQrrn3atlRixGt1xZWrlB9Fc1CIkTMCUQiJsk++Ekjhe+k9OEBOw4CpeViHlHpop+sqY8A44QL5L25Hlhjt7jg3C2XemUnGrDKv/Bm3Bysi4rFhq/lSJ8JNB+I4MpOkmUjJ1dfd1xH3miwuihFSrU/igzm9ufJB0Xt8d0vimXaM0L7aV9O3ERKDTLpn7x+UKw0/wKuClE2TDMZnea0gSWIdsldtnuf343ZKZAEXlTDkmgnHlZ2OwJS327jGnz9h3yqwsBqetxeoi+xt938ABpLbiPeW1fCVBxqZscZiBEidDssMdFH1kvQY7ULl0BACwu70Ye3ARIM365ct6lVlkpymbjiBbnyVRE46vnYQWUPdFDaAzX0qKqXLDz1u6GudtQWnhzsQYGHWXNYHoDMAhIrNBI0e+qFYTsG9vhsbjGXyC7UIdYHIaARc7sRlsKBA5Wv8m+zJb4Vcly9R69fzpTHCYzNcXP+ZblVlC8lSG3F3UNz6enr7Nbb6toCn6 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 Reviewed-by: Vlastimil Babka --- 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