Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5986608ybe; Tue, 10 Sep 2019 11:46:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyH6b3RwtbhMAav7AytcRAD9Hp9n1m9sNyy36vmN3h3VJUKXavO2zODzVPKrfnZhPGJ7bz X-Received: by 2002:a17:906:7e44:: with SMTP id z4mr26000514ejr.290.1568141196718; Tue, 10 Sep 2019 11:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141196; cv=none; d=google.com; s=arc-20160816; b=w3oJDj0C6aTddEfei60JYMWqvz0sM5FKwQcSkOLt+3RrdYYbqwMZ1Y5gzynlieBXFv +aOO+cbGZlsrMq/yplCg+P79/87wmOclRYvO4GGMx16X1cAkDPiYIo89Fnss+WGm/ygt jX/HD68kvsl/0EpaPORyXDvAlspqinuSM1lrKT5zEbG3zEeClVtTN3KxHdoRcRBFzCgc MXUI9EEm4EjU6aTo+1vAIhbGUB2TA7dfd8SmBG+P8XTiV+UIqOIZKnzTgsrk7w/2gCDQ pF9P5Si2/NOt4PPS/hOjehUejLhcmbo+F1+cbsk72rEWpFPkZnm/xKbO3lhXa20WnQEy oxvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zr0c07NjDmSH5Cw3kJRhGheNFiNUbd4oIPE+u9OeCKU=; b=cWoR1Y9gfEiUpj4mFgnGbPcA4UJe4UkMbNuR2LB/e/RdxZ9yo4gGMg1H+EYJksWEpE tnyDGhpXv9uNvTTjKHZre9sjJX+guU6m9ORH7rx87EkcEGC1wPUVOWn0DqgUG110S+oF IERfniZXkR9m7HB3zeHjGZtn97PPGFesYSg6lJXnYFn6O59uxOfGM41NrEWGxiXlZ8jn UNsDRdac48dp1IAuzuIZa87vZoj6dSxWjFGEHPVnd6WEC9yc9qMNgc+GoJyu25owcRun aWJMqQqEstavUZ7YQFyGQdtY8xA3AQ5uVcexG+I7XvSLSkQtAYLvARzG/36q08Hq5NPs AfRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i+2JgqiH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si9989860ejs.227.2019.09.10.11.46.12; Tue, 10 Sep 2019 11:46:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i+2JgqiH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392253AbfIJB1b (ORCPT + 99 others); Mon, 9 Sep 2019 21:27:31 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37189 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729327AbfIJB1a (ORCPT ); Mon, 9 Sep 2019 21:27:30 -0400 Received: by mail-pf1-f195.google.com with SMTP id y5so7767330pfo.4 for ; Mon, 09 Sep 2019 18:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zr0c07NjDmSH5Cw3kJRhGheNFiNUbd4oIPE+u9OeCKU=; b=i+2JgqiHkfJqcmzDqkcs4qfcvNvhNPQ3REVa3oPc44GAf/7bIImiNi23ef48RY0uXG uKU+2tPJ52bKlMa7MrKaA0tnzTftXyCCwmfi5EBQIRusrsDX/fPM75jVUx7X1X3+4ouG /c4cPU+TGRKtyKS23awFLVBrWcU/RoWn3iKWtkUo7eSzgrM6pKnmxzMPXlbfO2Wk+pXV 7tAamR30FgWwmyX5Rva5xni34jf1N+kq2QJstiyGbb6zdH4GDPlxuh+co+QD3A5mvhTD HBQFUNGbiWjKCRLU0n98d6+RnJ/n025w3S5UPUNOEstnpJzxEoyGoha9fLmkJ4YEpz/+ G4qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zr0c07NjDmSH5Cw3kJRhGheNFiNUbd4oIPE+u9OeCKU=; b=tSCzmNbu0C3RnYQJ1c7EWTZoU2zfyDwPkr5e4A8rPTtR3bcFQFgqn4k9Uag9/VJUxx GM70NM277czVdxDbBgpucp2x92AotrRHTDMy4JQYq2Qs1vmnBVJ8vGQNnAPSNrUXrk59 VHgd4KglH1+qwtDJDu3RmaBSNl9WBoyJIIereiG+fvivm/Ntkn6Zz1TspPIGKKvpkETj 55XQZVKGYzmGvR1SiO0M/mSoVfLXHkAhkeby84YgDJzmqo1xDRh0HjigwW7b/wpr50jg +e/LheXehG6X+UWTNDbAzKAlGOBz3Dkc+SfC1+o0FZIrIQHFmUb2dWPcJHQTLeXsz0DI 4cfw== X-Gm-Message-State: APjAAAW24s5ANOcKxSRXj4Qr2H5XZdKMEOovNTcuiw4YmL/IP5FBvNTg xIKZndnEk3418asv6VoZ4ZQ= X-Received: by 2002:a63:c118:: with SMTP id w24mr25202712pgf.347.1568078850216; Mon, 09 Sep 2019 18:27:30 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id b20sm19558629pff.158.2019.09.09.18.27.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 18:27:29 -0700 (PDT) From: Pengfei Li To: akpm@linux-foundation.org Cc: vbabka@suse.cz, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, guro@fb.com, Pengfei Li Subject: [PATCH v3 2/4] mm, slab: Remove unused kmalloc_size() Date: Tue, 10 Sep 2019 09:26:50 +0800 Message-Id: <20190910012652.3723-3-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190910012652.3723-1-lpf.vector@gmail.com> References: <20190910012652.3723-1-lpf.vector@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The size of kmalloc can be obtained from kmalloc_info[], so remove kmalloc_size() that will not be used anymore. Signed-off-by: Pengfei Li Acked-by: Vlastimil Babka Acked-by: Roman Gushchin --- include/linux/slab.h | 20 -------------------- mm/slab.c | 5 +++-- mm/slab_common.c | 5 ++--- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index 56c9c7eed34e..e773e5764b7b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -557,26 +557,6 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) return __kmalloc(size, flags); } -/* - * Determine size used for the nth kmalloc cache. - * return size or 0 if a kmalloc cache for that - * size does not exist - */ -static __always_inline unsigned int kmalloc_size(unsigned int n) -{ -#ifndef CONFIG_SLOB - if (n > 2) - return 1U << n; - - if (n == 1 && KMALLOC_MIN_SIZE <= 32) - return 96; - - if (n == 2 && KMALLOC_MIN_SIZE <= 64) - return 192; -#endif - return 0; -} - static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) { #ifndef CONFIG_SLOB diff --git a/mm/slab.c b/mm/slab.c index c42b6211f42e..7bc4e90e1147 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1248,8 +1248,9 @@ void __init kmem_cache_init(void) */ kmalloc_caches[KMALLOC_NORMAL][INDEX_NODE] = create_kmalloc_cache( kmalloc_info[INDEX_NODE].name[KMALLOC_NORMAL], - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS, - 0, kmalloc_size(INDEX_NODE)); + kmalloc_info[INDEX_NODE].size, + ARCH_KMALLOC_FLAGS, 0, + kmalloc_info[INDEX_NODE].size); slab_state = PARTIAL_NODE; setup_kmalloc_cache_index_table(); diff --git a/mm/slab_common.c b/mm/slab_common.c index 002e16673581..8b542cfcc4f2 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1239,11 +1239,10 @@ void __init create_kmalloc_caches(slab_flags_t flags) struct kmem_cache *s = kmalloc_caches[KMALLOC_NORMAL][i]; if (s) { - unsigned int size = kmalloc_size(i); - kmalloc_caches[KMALLOC_DMA][i] = create_kmalloc_cache( kmalloc_info[i].name[KMALLOC_DMA], - size, SLAB_CACHE_DMA | flags, 0, 0); + kmalloc_info[i].size, + SLAB_CACHE_DMA | flags, 0, 0); } } #endif -- 2.21.0