From patchwork Wed May 24 17:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13254342 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 2F059C77B73 for ; Wed, 24 May 2023 17:19:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2B4D900006; Wed, 24 May 2023 13:19:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDCC2900002; Wed, 24 May 2023 13:19:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA448900006; Wed, 24 May 2023 13:19:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9C5D9900002 for ; Wed, 24 May 2023 13:19:27 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4C7D11C7862 for ; Wed, 24 May 2023 17:19:27 +0000 (UTC) X-FDA: 80825809974.08.3EB1F6D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 796B240022 for ; Wed, 24 May 2023 17:19:25 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684948765; a=rsa-sha256; cv=none; b=uHXZ5ZmlH5Wynqmlie3D4kXCnf3svAA234sMMpCdrjhvhAjCA+EPS3OHpZ5K5lx/WssS3/ rt6Zdf7Q2TWNCJAj22QZ7I9xV7bciiVQbdOykURkZ8Mer0F7bxZGvTfa9nuqfskc6+e5/r xRlTxtEGANjcAOCk1CbmIgQ3N6VY24M= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.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=1684948765; 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=PuiOaOhWjsTfmEJ1Zh5PyIRurfoSE5Z2UQWmOnFmFO0IM+GvyGrFqYcWrp+ljRqgQMeZKv sqjgo17zNvOedw5PBEXZZuFnLLCvdOhpQTFaWBzdiH45KdlcnoL8lWfiNekrnzoo9MOcLr w+gy3NvhyHkMmkjUq8dkS60J6bDXO3A= 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 E6D3E63F94; Wed, 24 May 2023 17:19:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7145C4339B; Wed, 24 May 2023 17:19:18 +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" , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 03/15] mm/slab: Simplify create_kmalloc_cache() args and make it static Date: Wed, 24 May 2023 18:18:52 +0100 Message-Id: <20230524171904.3967031-4-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230524171904.3967031-1-catalin.marinas@arm.com> References: <20230524171904.3967031-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 796B240022 X-Stat-Signature: bkibafccnqbhu1oizp395ycj4gfxfz4u X-HE-Tag: 1684948765-743468 X-HE-Meta: U2FsdGVkX1/B3O59GHtwLav8SWVxks3zVsD2N+18EdikBJgxfacuGN9ATe18Agd6odWnXG3XJF0R7tJeAnN2kwnDwTZXZkbPuA5QHUUWq2/C0DVcqrcS84OCTdgqUeWR49wJHv24kbZNKMolqncjX5bLdZ3OARmcUaoaCNmQYSqpcAVtMxAk3rgWFXW738km43Cii6lL66MGKbeDs/rL1l4af/9BPaSiT+B2HbS4/S4Sg+2hPx6BRGQXuJkeevoO6CIwvcqiTRZ8uVCB8lPWckP130kUStLPd8v3qSfXCmKFpCjhixR+RZejHyfH2SuytpvkWzJf2Kgx9UFmQq3wUKCsCC2lopT9jZKls/mf+h0nPJGXQBZNogSY8lhPms9dOZZ1cgLq4a7htcVvFlAFGL1vhfa5zz22oAWeTvr5u7YT8tlm2f+G8dtVlOEBn9L0zyqknbgoKnx7bvc+Tu1gMpD6F/75uqAi/uVzgQ0m31zxWLNZie0EaOXIrzW4Dql7QCKMDyMUrHm/1pTM+llyVdQfFe0I51RPkSDXHpgs17c/UEc7/z5+rgookeLiArciSr5MifVcsHaFB31tzLg/Ib2pAvasdupjxGXbiWXG8hTKZqakYBK4qHgzFPcZZzeItLaQF4Ep8BNeF2H23A5dzV6bMSZZl+AaY49NnsZLaCjoCyzqLHcE+GUw4Ma7Sg6Tz1ERy5M7GrfYOYxvtVN/LcQMxhHQZolxZg+Pk4Te57oOBzQ0RU1hWPltz5n23ugZrcAG/xjcPrE7RoBdRATg2TpnyikLG7jihuG9oZ1sygBwLpYyfsdPG+ZAq9Rzh5EPa653M/tceL0HdpGuIOM3tBRE2lLc+WwDMUhRIfk26kasdYaG6PYN4gjmh67WKTfNyOyPLr68SU+oy0G/r72oXSljDZkVhbESMLo07oRAIBAjwevgJsHS6phYokDVat7uGWflcSWWqVUhdipe0HZ pzRL6ehM O4pw2Vu68mb2x2g5nFzW0hIbM40eViXo3bv5I9ZAkNdUpFYaQl/DrNvkrKJq6y5FCpUiRIG8V6fEJ1S0uVMJzH/eQPMBAzIFg0C4OFaSwAvrfq50xEbO4ouWTiKzMfFcjFzb2zMycm5l+TGsSRgYaQOow/R+Pdmqrh/P96F20CzeycYsq9kcQCBUOjJvRgfWuAfXXBDthiWcZpQ8Io/OosGfmFXZFBKKCtJmKtw1ZuKKvCVHl2utLQiPMc2H+r9hRTDpBhv2K4Y1DVSsGlVdZ5DGF+9yB5iO356L1JhyqzcZCgDX4FQ6RMZLz89sXLQMdsYiW8g62Er3JpvrV9kFvEY6OaGckjn8WRosq2WGZ80ltic5jH3LxCe4tsg6q9mkHHxYL3wSZlZRJlNDmkQPQwZ6GwLJTbodi6liuK12cgkkWPYPDqpgw7EAr01PAyRYuaEsfbw12wpvDFxN8Hc/71JOEhD0G3w9PMfPGKlmPZ1CQNgxOazCxVBQmbpfCioCfOKRTU4U79UgsUFXx5eEvGbc/+/+wMPmoQQdov3FmhbRn0frUBT9/CDDBItPCokatVN9d 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