From patchwork Mon Jun 12 15:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13276859 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 DE236C88CB6 for ; Mon, 12 Jun 2023 15:32:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81DEE8E0007; Mon, 12 Jun 2023 11:32:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77E418E0002; Mon, 12 Jun 2023 11:32:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F8448E0007; Mon, 12 Jun 2023 11:32:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 523ED8E0002 for ; Mon, 12 Jun 2023 11:32:25 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2806114026B for ; Mon, 12 Jun 2023 15:32:25 +0000 (UTC) X-FDA: 80894487450.03.FF487A5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 9182418002B for ; Mon, 12 Jun 2023 15:32:22 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.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=1686583942; 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=3Jj4EF+XtrFLmw7b5wkN2F+9P7xlNswk5uVqJStOCqw=; b=TpMxknr8NBXLYZEWA45Cupos9zta2Pa8C4hWKt/gsGsuHQ4+WEqU4OTp4POa283bzCr2Wg iINJwjtLaczFVYZn2nP+wpUJCQP5+519PeQoiZo5ZM8fjfg+j40rqDqo0ZzTglkzEU1yDt I7DX6n6TczbGTpfOn8ihPv2BshOvP9Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686583942; a=rsa-sha256; cv=none; b=oQa1BZb/KSRbWJ98rZmGdl0ADXbXvBd3EIP9nx54CJDXJGyYBYXdl/t2FEehfCBXsTUWsm ZZIYrrY6cjRUAiLBoY274wy20EpT05FD/hhDt7vNNYzvZwmLclZKOdpuYXFmwWw8WH12oY edulX0VfmU3jApj0PKPZJfYr3AguZVU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.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 A2A6E617E7; Mon, 12 Jun 2023 15:32:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 259A9C433EF; Mon, 12 Jun 2023 15:32:17 +0000 (UTC) From: Catalin Marinas To: Andrew Morton , Linus Torvalds Cc: Christoph Hellwig , Robin Murphy , Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , Vlastimil Babka , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 03/17] mm/slab: Simplify create_kmalloc_cache() args and make it static Date: Mon, 12 Jun 2023 16:31:47 +0100 Message-Id: <20230612153201.554742-4-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612153201.554742-1-catalin.marinas@arm.com> References: <20230612153201.554742-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9182418002B X-Rspam-User: X-Stat-Signature: jwoia7jfgrpuifb3z7foykyfqzopydwn X-Rspamd-Server: rspam03 X-HE-Tag: 1686583942-466310 X-HE-Meta: U2FsdGVkX1/twk1KHBM2bPf2NxoZS6qJxCs8XxMlevmuuZKFKFcNgyziwBVDOUg/QxTG7IvaHwo5PdqcWCM56/WqLtLVmx3czIjhwnYMh0OATbOmbV7U+IgPct6eGPWqi2fnLmAAGv9amvO/MYajuRPWJq/VzUkF5jOwNz+2qGMVKvja2mUWobzTzel00y7v8pmCU3074BH2ZkGzpWqqBLUEbF3tlEiEUv+b0JHDs1BQ3+D5DdsU2ALSSthlSoStunhhP7gxfejQKgbwgQhx4dbW54mDNOaZifq1qMjIk8NyOqybiDXEuMRQOCrBz79XzuJLQmmUw1qn2bAD4U3rlROSaUrVSKo+VK4uurWsjSNzpqFV0iQFAmdoJPKYleotOeE4HvLia12JTtpQB/SPrlpN60/q0VFeGtSy2wWNjvGWhx7x/cVz5vlEG8jfhjeAfBFZzy3iAuOOG/GkfiZJxuaL8TNFF1Sg594nMoZWTBEfL8udNLLDadyoMEw/yOFeFtynVWRcz2t5Ic/Xgackrj619rE7jQfVZZfHBZ5mhhgdCVIpjQpEHWJc9RquSVa9hPuWCGsTQIi10EYakDaAFZouSBMRRLweUo6bWZcIrDPw4dpowHY2c8ysLxySpqVCVQl8+D2usOpMGkPmNLqz8V5fevAZZ92Ae+7Qp+/Hio961ZSI3Zb+1sienLLcXCQRbYs6q1mp2xGPPXtVv7bKlzFXyxYX/UElXhAk5q6CWjnrXD+JBr7ECIDMCWO/kDfTP207FIr1XGsROmlfRW+cVlcg2a3E5LZhU8ohyqhvyw0gjod9NeUliOkfKro91Xke5izxw1O0XOScVpghs9cBFveGthXLOoLBDeJU2VVFCJzgU5brTbn9lDKLi5JjFK4onSuHuO+N5QUtvcMknIP5cm+e8K9A61dpiY/b901Og84bcCCxOyHMyoXv5cGR8WzaEvBEXfZLACAckHU9QBb +ls7q652 S6XUu5U/eNhGoILYSXPi6FDr/9YMqkqtvgsUc5QleR1kbNoXZre1dXom1TFT6t9vp3UpuvXUPCr6X2opeplclDMJZ9NJ1xC6k0lxnWRYJHs8IQYTbvYfume+krCSlE74eZSkZeXJBjIvCqA7wZb0NZ9JC4Xr7LZNaqrzyjV2iosutMwurYFc0uoCe8tjIBMa4d9KZIM6OE5jIKWzOmMWnLh1dqmrFnR0u/LrOEFiKU+FwzWwOdAZ+xj3Y0hxxpa3yP7Ijra1YHCPl9iLPDzbjRcXurefRmjN/jImDuAX9yd0rtgY7QtPY2Nmslebjj0PqKWMs6AdN9tKcF3K5VvlwSxbbNkmhvCSTY9v4MCM1uy32a3Gzeh3cK23ddPX8JVISgr8hpBVqYTV0dVJPntf1SQDbEmLVwmo9BC6eYXh3fXswC7HzCrkqYYq+n2KBQszOG7VhKnerTPQwgtfWCjN/7bmCLmBUr3juzEzCk9Wj0mk0CmbTrQhR8plmMDPIF8i0WRsovBrdZ9uk2l/3GhAPunAesg7tyJDcXwh+93i5eR1Eyz7/pgLEocnEyc84zjXsvZyWcTr48afYaCoWJZHQjdPVSA== 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 Reviewed-by: Vlastimil Babka Cc: Andrew Morton Tested-by: Isaac J. Manjarres --- 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