From patchwork Mon Sep 23 12:27:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11156705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9601D13B1 for ; Mon, 23 Sep 2019 12:28:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5923920867 for ; Mon, 23 Sep 2019 12:28:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J7oIdsvl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5923920867 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 91ADB6B000D; Mon, 23 Sep 2019 08:28:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A3F16B000E; Mon, 23 Sep 2019 08:28:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 791CD6B0010; Mon, 23 Sep 2019 08:28:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 4F19B6B000D for ; Mon, 23 Sep 2019 08:28:01 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id E10EB824378B for ; Mon, 23 Sep 2019 12:28:00 +0000 (UTC) X-FDA: 75966112320.15.mind43_6300699309c14 X-Spam-Summary: 2,0,0,6d1ace07adaa5122,d41d8cd98f00b204,lpf.vector@gmail.com,:akpm@linux-foundation.org:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com:vbabka@suse.cz:guro@fb.com::linux-kernel@vger.kernel.org:lpf.vector@gmail.com,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3874:4321:4605:5007:6119:6261:6653:7514:7903:8603:9413:9592:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13161:13229:14181:14394:14687:14721:21080:21444:21451:21627:21666:30029:30054:30064,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:27,LUA_SUMMARY:none X-HE-Tag: mind43_6300699309c14 X-Filterd-Recvd-Size: 5296 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Sep 2019 12:28:00 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q5so9018097pfg.13 for ; Mon, 23 Sep 2019 05:28:00 -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; bh=n2eze0t6/k1b+WJqoNEASb7rlpZM6bT/9+WRw0baftU=; b=J7oIdsvlzutrmdREBj1gHTAQ7LO9uYo9GeCk+D9xVhHHaWbeBlNkfyqL6gWaP15TaM LQAooNLMKERDr0miuk/AuTxsO70X+hvCzj4YvP3I74+6j6tasxOae82GAlfduZmd6q6z hhk02rsKsUW6qd5rMjqtMG6JB/zLk9l4Y0pcMBET0J5wvMXHD6PFJazCFUD7Vj/hnJo0 Hm0d65j3AYeQuoLjJV7kdWwIrkmBGODT1FLQr9nFUI8n5ZgsbDKSeoeolau7wxlGqaLe d7f3OVVBaNFJTQyQ+SZx+Dg8NP95u8SUAJoUy9AIoIv8fJ5C9t9dIRV67UZ3NdDUDGlC qF5Q== 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; bh=n2eze0t6/k1b+WJqoNEASb7rlpZM6bT/9+WRw0baftU=; b=YteYuYdUdPq+0fiCKXgTIhN5jZ7JxSjoCXrOKfJckSYmysJW+Ua8smJYD1V5AN6bv6 HvjSCgut4mof1Dl5eJ+UdX00YbbgS/9qFU7Apxb44VYQL4u7p6NXjsZaEdOHd4x/AgJa bBRkqjXNgYGqX6hxt2EK6DTZ1wFk7KZUj5cu8QtSuN42kuOlpKpbhOQ3ikrX+o5/3n5g ScHuJtPUSBBPgSjif5aprlz1bVPzES/TuY2de4dF5ZcgXJxs5Usm+9tSECZS+dyuF8hM dQaO3P6KR68o6fmE2Ald1T3Ag/HJP2KXrYCjUzYeEjyMMqRDtkgarC6n/uNFsrcMOaxz Oakw== X-Gm-Message-State: APjAAAUCCbCFsea49Z8gs2YRIm/NQ3NIsjzV70BlS+VCe7RZjJaIYYrl VagrcEq3UqklFj+mBWkGZ20= X-Google-Smtp-Source: APXvYqyiqF6M4Qgya7ubuznNyYPZ9bu/Cm54FKJ6TLYeTzodHH+3ew2B8g6TVOob606udU8kHb+UaQ== X-Received: by 2002:aa7:8acf:: with SMTP id b15mr26182705pfd.191.1569241679471; Mon, 23 Sep 2019 05:27:59 -0700 (PDT) Received: from mi-OptiPlex-7050.mioffice.cn ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id 202sm9692016pfu.161.2019.09.23.05.27.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Sep 2019 05:27:59 -0700 (PDT) From: Pengfei Li To: akpm@linux-foundation.org Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, guro@fb.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pengfei Li Subject: [PATCH v6 2/3] mm, slab: Remove unused kmalloc_size() Date: Mon, 23 Sep 2019 20:27:27 +0800 Message-Id: <1569241648-26908-3-git-send-email-lpf.vector@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569241648-26908-1-git-send-email-lpf.vector@gmail.com> References: <1569241648-26908-1-git-send-email-lpf.vector@gmail.com> 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: 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 Acked-by: David Rientjes --- 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 56c9c7e..e773e57 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 c42b621..7bc4e90 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 4e78490..df030cf 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