From patchwork Mon Sep 9 17:07:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11138289 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 7757B1395 for ; Mon, 9 Sep 2019 17:08:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3647321A4A for ; Mon, 9 Sep 2019 17:08:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iyCNoECD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3647321A4A 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 675AE6B0008; Mon, 9 Sep 2019 13:08:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 626DB6B000A; Mon, 9 Sep 2019 13:08:05 -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 53DC66B000C; Mon, 9 Sep 2019 13:08:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 3375F6B0008 for ; Mon, 9 Sep 2019 13:08:05 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id DA0F2180AD7C3 for ; Mon, 9 Sep 2019 17:08:04 +0000 (UTC) X-FDA: 75916014888.28.order14_80b350f0b843c X-Spam-Summary: 2,0,0,9c6e54b4c4ff9fd4,d41d8cd98f00b204,lpf.vector@gmail.com,:akpm@linux-foundation.org:vbabka@suse.cz:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com::linux-kernel@vger.kernel.org:lpf.vector@gmail.com,RULES_HIT:2:41:69:355:379:421:541:800:960:968:973:981:988:989:1260:1311:1314:1345:1359:1437:1500:1515:1535:1605:1606:1730:1747:1777:1792:1801:2198:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3874:4120:4321:4605:5007:6238:6261:6653:7514:7903:8603:9413:9592:10004:11026:11232:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12683:12895:12986:13161:13229:13894:14394:14687:21080:21444:21450:21451:21627:21666:21740:30029:30030:30054,0,RBL:209.85.214.194:@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:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: order14_80b350f0b843c X-Filterd-Recvd-Size: 9007 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Sep 2019 17:08:04 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id b10so6815192plr.4 for ; Mon, 09 Sep 2019 10:08:04 -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=56EyWssaHrVJPXE31hURcuC1V8/jFVhyZHz6XUKnzv4=; b=iyCNoECDOGhglhMlMRkG/M7wbl7O38JmAXZDUDCqurGskhSuEn4XspMI6Qfu7HS8xO fECJBHJV6n/tNnXBGcNSt/1X+yT/zFefW6X9lOXu7TzZCxRr3Dik/CRsCWFuEPpr+c53 9XXQUbrPoaFuEKGKMfJoed8hZvWs0AcNLVBA3iF7TzqfklzZ3yL1HWdjnRy7uoPCeW1i 5hSJ5ZFTklONYZ9MMpambhIr/neRlZnRBjsdeaqVJw+uudcOSu9pOUOJ+eJSAXEcB2QN yiTXM5ZnzTuj/+kRn5wocADmc9t11qSrBNmr2YIHJ00zULjW5PtSwZwD2qOdhqowlYwn LOeQ== 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=56EyWssaHrVJPXE31hURcuC1V8/jFVhyZHz6XUKnzv4=; b=nPT6LVgxCd5/ttG8Z6ojcY1XB186IXlz3lJb8oMvImWtdmcX2U2aCLFdvULyMCGOIR Ji+6flKjzq2jf0f2aFK+sjqBK1Ls7wrabbldXISANuQK0kTKMzaF1ioZ9d/50RhUVxDy GJKvIfazikBvbOaxN6dIkyvsouw6sOKkeZ+dnIBRc35zJPMx+HTIczJIIAfPyukbYVC+ 0B4GYRznZxARAlc/oXW47O4Jm2lvskOBL+r2Xa2VzPCRS4VWIaQ5vlqbCH2+yc8PMJC1 XBTY75sSkpFuf0D5b1pYF9ZeAxO9RbScSMKkXX3PG6ibaaPm2kb7WGygOSDDX1XGbg23 +IrA== X-Gm-Message-State: APjAAAVuKo7L7bccjvorxy7TYcr+hOcLlhNNz2tgx6apvLXdMIID3zxl q0u7fu4hd2c7SJataoCaolo= X-Google-Smtp-Source: APXvYqwsxupkaHDNE3np35kiBbRGjbnxlo+dJddSG3pXBMatNaTwVdu3vLn2rL9/M/hjaAvSteC1qA== X-Received: by 2002:a17:902:b40c:: with SMTP id x12mr25776031plr.236.1568048883253; Mon, 09 Sep 2019 10:08:03 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id b18sm107015pju.16.2019.09.09.10.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 10:08:02 -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, Pengfei Li Subject: [PATCH v2 1/4] mm, slab: Make kmalloc_info[] contain all types of names Date: Tue, 10 Sep 2019 01:07:12 +0800 Message-Id: <20190909170715.32545-2-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909170715.32545-1-lpf.vector@gmail.com> References: <20190909170715.32545-1-lpf.vector@gmail.com> MIME-Version: 1.0 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: There are three types of kmalloc, KMALLOC_NORMAL, KMALLOC_RECLAIM and KMALLOC_DMA. The name of KMALLOC_NORMAL is contained in kmalloc_info[].name, but the names of KMALLOC_RECLAIM and KMALLOC_DMA are dynamically generated by kmalloc_cache_name(). This patch predefines the names of all types of kmalloc to save the time spent dynamically generating names. Besides, remove the kmalloc_cache_name() that is no longer used. Signed-off-by: Pengfei Li Acked-by: Vlastimil Babka --- mm/slab.c | 2 +- mm/slab.h | 2 +- mm/slab_common.c | 93 ++++++++++++++++++++++++++---------------------- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 9df370558e5d..c42b6211f42e 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1247,7 +1247,7 @@ void __init kmem_cache_init(void) * structures first. Without this, further allocations will bug. */ kmalloc_caches[KMALLOC_NORMAL][INDEX_NODE] = create_kmalloc_cache( - kmalloc_info[INDEX_NODE].name, + kmalloc_info[INDEX_NODE].name[KMALLOC_NORMAL], kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS, 0, kmalloc_size(INDEX_NODE)); slab_state = PARTIAL_NODE; diff --git a/mm/slab.h b/mm/slab.h index 9057b8056b07..2fc8f956906a 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -76,7 +76,7 @@ extern struct kmem_cache *kmem_cache; /* A table of kmalloc cache names and sizes */ extern const struct kmalloc_info_struct { - const char *name; + const char *name[NR_KMALLOC_TYPES]; unsigned int size; } kmalloc_info[]; diff --git a/mm/slab_common.c b/mm/slab_common.c index 807490fe217a..61c1e2e54263 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1092,26 +1092,56 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags) return kmalloc_caches[kmalloc_type(flags)][index]; } +#ifdef CONFIG_ZONE_DMA +#define SET_KMALLOC_SIZE(__size, __short_size) \ +{ \ + .name[KMALLOC_NORMAL] = "kmalloc-" #__short_size, \ + .name[KMALLOC_RECLAIM] = "kmalloc-rcl-" #__short_size, \ + .name[KMALLOC_DMA] = "dma-kmalloc-" #__short_size, \ + .size = __size, \ +} +#else +#define SET_KMALLOC_SIZE(__size, __short_size) \ +{ \ + .name[KMALLOC_NORMAL] = "kmalloc-" #__short_size, \ + .name[KMALLOC_RECLAIM] = "kmalloc-rcl-" #__short_size, \ + .size = __size, \ +} +#endif + /* * kmalloc_info[] is to make slub_debug=,kmalloc-xx option work at boot time. * kmalloc_index() supports up to 2^26=64MB, so the final entry of the table is * kmalloc-67108864. */ -const struct kmalloc_info_struct kmalloc_info[] __initconst = { - {NULL, 0}, {"kmalloc-96", 96}, - {"kmalloc-192", 192}, {"kmalloc-8", 8}, - {"kmalloc-16", 16}, {"kmalloc-32", 32}, - {"kmalloc-64", 64}, {"kmalloc-128", 128}, - {"kmalloc-256", 256}, {"kmalloc-512", 512}, - {"kmalloc-1k", 1024}, {"kmalloc-2k", 2048}, - {"kmalloc-4k", 4096}, {"kmalloc-8k", 8192}, - {"kmalloc-16k", 16384}, {"kmalloc-32k", 32768}, - {"kmalloc-64k", 65536}, {"kmalloc-128k", 131072}, - {"kmalloc-256k", 262144}, {"kmalloc-512k", 524288}, - {"kmalloc-1M", 1048576}, {"kmalloc-2M", 2097152}, - {"kmalloc-4M", 4194304}, {"kmalloc-8M", 8388608}, - {"kmalloc-16M", 16777216}, {"kmalloc-32M", 33554432}, - {"kmalloc-64M", 67108864} +const struct kmalloc_info_struct kmalloc_info[] = { + SET_KMALLOC_SIZE(0, 0), + SET_KMALLOC_SIZE(96, 96), + SET_KMALLOC_SIZE(192, 192), + SET_KMALLOC_SIZE(8, 8), + SET_KMALLOC_SIZE(16, 16), + SET_KMALLOC_SIZE(32, 32), + SET_KMALLOC_SIZE(64, 64), + SET_KMALLOC_SIZE(128, 128), + SET_KMALLOC_SIZE(256, 256), + SET_KMALLOC_SIZE(512, 512), + SET_KMALLOC_SIZE(1024, 1k), + SET_KMALLOC_SIZE(2048, 2k), + SET_KMALLOC_SIZE(4096, 4k), + SET_KMALLOC_SIZE(8192, 8k), + SET_KMALLOC_SIZE(16384, 16k), + SET_KMALLOC_SIZE(32768, 32k), + SET_KMALLOC_SIZE(65536, 64k), + SET_KMALLOC_SIZE(131072, 128k), + SET_KMALLOC_SIZE(262144, 256k), + SET_KMALLOC_SIZE(524288, 512k), + SET_KMALLOC_SIZE(1048576, 1M), + SET_KMALLOC_SIZE(2097152, 2M), + SET_KMALLOC_SIZE(4194304, 4M), + SET_KMALLOC_SIZE(8388608, 8M), + SET_KMALLOC_SIZE(16777216, 16M), + SET_KMALLOC_SIZE(33554432, 32M), + SET_KMALLOC_SIZE(67108864, 64M) }; /* @@ -1161,36 +1191,14 @@ void __init setup_kmalloc_cache_index_table(void) } } -static const char * -kmalloc_cache_name(const char *prefix, unsigned int size) -{ - - static const char units[3] = "\0kM"; - int idx = 0; - - while (size >= 1024 && (size % 1024 == 0)) { - size /= 1024; - idx++; - } - - return kasprintf(GFP_NOWAIT, "%s-%u%c", prefix, size, units[idx]); -} - static void __init new_kmalloc_cache(int idx, int type, slab_flags_t flags) { - const char *name; - - if (type == KMALLOC_RECLAIM) { + if (type == KMALLOC_RECLAIM) flags |= SLAB_RECLAIM_ACCOUNT; - name = kmalloc_cache_name("kmalloc-rcl", - kmalloc_info[idx].size); - BUG_ON(!name); - } else { - name = kmalloc_info[idx].name; - } - kmalloc_caches[type][idx] = create_kmalloc_cache(name, + kmalloc_caches[type][idx] = create_kmalloc_cache( + kmalloc_info[idx].name[type], kmalloc_info[idx].size, flags, 0, kmalloc_info[idx].size); } @@ -1232,11 +1240,10 @@ void __init create_kmalloc_caches(slab_flags_t flags) if (s) { unsigned int size = kmalloc_size(i); - const char *n = kmalloc_cache_name("dma-kmalloc", size); - BUG_ON(!n); kmalloc_caches[KMALLOC_DMA][i] = create_kmalloc_cache( - n, size, SLAB_CACHE_DMA | flags, 0, 0); + kmalloc_info[i].name[KMALLOC_DMA], + size, SLAB_CACHE_DMA | flags, 0, 0); } } #endif From patchwork Mon Sep 9 17:07:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11138291 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 F1DF31395 for ; Mon, 9 Sep 2019 17:08:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BED1D21924 for ; Mon, 9 Sep 2019 17:08:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UuVcZXvR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BED1D21924 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 034BF6B000A; Mon, 9 Sep 2019 13:08:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F265A6B000C; Mon, 9 Sep 2019 13:08:14 -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 E15546B000D; Mon, 9 Sep 2019 13:08:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id C24A96B000A for ; Mon, 9 Sep 2019 13:08:14 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 71B108408 for ; Mon, 9 Sep 2019 17:08:14 +0000 (UTC) X-FDA: 75916015308.19.bell51_8213b9765ca06 X-Spam-Summary: 2,0,0,c7d90e76d8ca840e,d41d8cd98f00b204,lpf.vector@gmail.com,:akpm@linux-foundation.org:vbabka@suse.cz:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com::linux-kernel@vger.kernel.org:lpf.vector@gmail.com,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1311:1314:1345:1359:1437:1515: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:12986:13161:13229:13894:14181:14394:14687:14721:21080:21444:21451:21627:21666:30029:30054,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.175.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:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: bell51_8213b9765ca06 X-Filterd-Recvd-Size: 5358 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Sep 2019 17:08:13 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id m3so8138252pgv.13 for ; Mon, 09 Sep 2019 10:08:13 -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=IAG1VLKBZpRTEI8L4+2XUQIRSxmDIwmG8l7u8lqUj7s=; b=UuVcZXvRYiGsCOXoX7QtHfrnf25gH30tm3Jr+MLFXtA0xo/UN3oUbJHtk5i1n0Ilb3 IZL9SiXjwDj+bm3AtV9wLg3n6Jswk30v2yH6HpLhfbrVl6pTWflcxilGtD/kV1H0aJ36 dB8Pr7vF+PX/NrDC4T6C40H5DtyEHkOJNskSEX+bN2SScynCsurEyZj2XeCPs2wRUr4g HXNJk6SrR5OgR+WzJaTTuH0fMzZgKMpJr1BmKVQg6/zn1jE7cWhxg4MlOklK1NkWr0Wn b8OpbRs1OD0DzyZNmS10ql7vR4FEOEGP+a/u8M9idhR2f52v15FWTrlXEQyJC8TprYCl IaNA== 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=IAG1VLKBZpRTEI8L4+2XUQIRSxmDIwmG8l7u8lqUj7s=; b=Z2R1eyQq8gwrg9kDzlrxkUYJf3DxuUZoxIVtgMISybIN9Wd2tiwylCLau4ZOvwW6G+ twbRnBoc8z5V46JT5danWitZgv/3kKT8Z9kX7COCIaSzx2lyYlMap7wCjtz/pt4Mw3Lj J/I7iU0hCc1TOfZwoFnV974PRhUVGf725c2Cwx/EKnEYkex33ho9T970O+EyzBgiZCvi un4TxF1ST4nmJ/VgT1l7QmZQMk9JKZ9NFzVrbIp30Qfa1xkZ9dSgqqLkXZwmQXlq57yD gwnYhLjSQ2kJ0JTT67LJ4j765Ob4Q59W5K9vw6k0JUObdfICLiOad++/C8hse4+MyUqO 5HjA== X-Gm-Message-State: APjAAAXk9aHMZ7hE4id+rYCTCUlqW3eYY8bTdqOdrsw4vrOBKPz2YzeN iuVeIOTaaiiTK2OaJHQ5cBU= X-Google-Smtp-Source: APXvYqwibHgZWR+jw1Ah4yMCwZtMRhATUb+KbugeO1jo6o8Yxx06YncsTn+5H5M9UI4Gh/rYQvApxA== X-Received: by 2002:a63:5823:: with SMTP id m35mr23177084pgb.329.1568048892858; Mon, 09 Sep 2019 10:08:12 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id b18sm107015pju.16.2019.09.09.10.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 10:08:12 -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, Pengfei Li Subject: [PATCH v2 2/4] mm, slab: Remove unused kmalloc_size() Date: Tue, 10 Sep 2019 01:07:13 +0800 Message-Id: <20190909170715.32545-3-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909170715.32545-1-lpf.vector@gmail.com> References: <20190909170715.32545-1-lpf.vector@gmail.com> MIME-Version: 1.0 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 --- 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 61c1e2e54263..cae27210e4c3 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 From patchwork Mon Sep 9 17:07:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11138293 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 EB0B3924 for ; Mon, 9 Sep 2019 17:08:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD3E4218DE for ; Mon, 9 Sep 2019 17:08:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NOlHweTi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD3E4218DE 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 D7ADD6B000C; Mon, 9 Sep 2019 13:08:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D2B536B000D; Mon, 9 Sep 2019 13:08:25 -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 C1AAE6B000E; Mon, 9 Sep 2019 13:08:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id A39846B000C for ; Mon, 9 Sep 2019 13:08:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 54AEBABE0 for ; Mon, 9 Sep 2019 17:08:25 +0000 (UTC) X-FDA: 75916015770.02.box24_83b0aaf65ed39 X-Spam-Summary: 2,0,0,25a300332291df5e,d41d8cd98f00b204,lpf.vector@gmail.com,:akpm@linux-foundation.org:vbabka@suse.cz:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com::linux-kernel@vger.kernel.org:lpf.vector@gmail.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3872:4321:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:13894:14096:14181:14384:14394:14687:14721:21080:21444:21450:21451:21627:21666:30054,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:neutral,Custom_rules:0:0:0,LFtime:40,LUA_SUMMARY:none X-HE-Tag: box24_83b0aaf65ed39 X-Filterd-Recvd-Size: 4146 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Sep 2019 17:08:24 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q21so9528501pfn.11 for ; Mon, 09 Sep 2019 10:08:24 -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=wPMbztDIbzkySjY7Sl5hBHJMX3nYrvhvNzUn5XH0t6c=; b=NOlHweTixtLZiLFTKY9rlqejzOTb0XI8x5pPvctE3BJcznEJZ3FxNZlQvAh9lC04jO K3R1lSqr2rke+fzifIDoT8r4nDuQV5WTHALeNkJBbCf30U9jzww5EIpkVeDJne9reP+e ytupaklu8rOWUlzxcy57xMGgVmjDdVQGJeHuRF7B2d9bgZ2desXOQmN95ADiddHL16gu Wcrt7FCsjzPDQf0KTj1xU3iAOZwxrDqBsuvPH65zCxEGjST19J2yxSJKQ1m2WkTw7AZT t4+gwRNvigjGmTxG/AwO01QqLlLKLzBJ9kSLli6ywBM2t1fYDfCJcKp3UStwBhaDQUO5 mCMA== 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=wPMbztDIbzkySjY7Sl5hBHJMX3nYrvhvNzUn5XH0t6c=; b=j5EQygpKFO2Q2WyzLqM15sTE9p7Trofb49+LzjUR+BYFxpgXYrwDKd5zFbqW0lt6de y7aS/PgBeaVjLoTq8blcK0e+Nk48oeKitlKN8m9NCI6m1eHPXA7Clb2cJDUyCE4VliDA PGdlzrPebUyYbGNBvmvXoviIvVQUStE9I+PWxMJIl1Xm9pHo96+2OpQ/yH2Ch+ceOtDS nwLGu2Lxkg8JyIOmK3MpPziDRlOz/6Zr/ObwE/ZxYBuPpruk+TsAWkZwqBXfyCp2Op2l P0aiYMkHT39ZVpNUGxqEi117oU5fWPAcWxVYcSpGknWpY9nU7rTlU2RTqCjLAD3UeRpv 5h6A== X-Gm-Message-State: APjAAAUCA5mAb76uIiUGY7rZgHHi8DAmcHkNTSRp4KbFfQ+HbzJLncws DZX5kA1zdBdJj98PwoLuB+taPHr0zAk= X-Google-Smtp-Source: APXvYqwjmYInaZx6SDG6wgi8tWtl2/JRBWAdYJG7Ff3sw8EYfzoCAJTs5qn6+Q/ejGCcW1UStRozAQ== X-Received: by 2002:a63:f907:: with SMTP id h7mr22785468pgi.418.1568048903964; Mon, 09 Sep 2019 10:08:23 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id b18sm107015pju.16.2019.09.09.10.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 10:08:23 -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, Pengfei Li Subject: [PATCH v2 3/4] mm, slab_common: Make 'type' is enum kmalloc_cache_type Date: Tue, 10 Sep 2019 01:07:14 +0800 Message-Id: <20190909170715.32545-4-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909170715.32545-1-lpf.vector@gmail.com> References: <20190909170715.32545-1-lpf.vector@gmail.com> MIME-Version: 1.0 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 'type' of the function new_kmalloc_cache should be enum kmalloc_cache_type instead of int, so correct it. Signed-off-by: Pengfei Li Acked-by: Vlastimil Babka Acked-by: Roman Gushchin --- mm/slab_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index cae27210e4c3..d64a64660f86 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1192,7 +1192,7 @@ void __init setup_kmalloc_cache_index_table(void) } static void __init -new_kmalloc_cache(int idx, int type, slab_flags_t flags) +new_kmalloc_cache(int idx, enum kmalloc_cache_type type, slab_flags_t flags) { if (type == KMALLOC_RECLAIM) flags |= SLAB_RECLAIM_ACCOUNT; @@ -1210,7 +1210,8 @@ new_kmalloc_cache(int idx, int type, slab_flags_t flags) */ void __init create_kmalloc_caches(slab_flags_t flags) { - int i, type; + int i; + enum kmalloc_cache_type type; for (type = KMALLOC_NORMAL; type <= KMALLOC_RECLAIM; type++) { for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) { From patchwork Mon Sep 9 17:07:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11138295 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 A351A924 for ; Mon, 9 Sep 2019 17:08:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6625C21D6C for ; Mon, 9 Sep 2019 17:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tEqQBjJ3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6625C21D6C 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 95C806B000D; Mon, 9 Sep 2019 13:08:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 933666B000E; Mon, 9 Sep 2019 13:08:37 -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 849666B0010; Mon, 9 Sep 2019 13:08:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 66DC06B000D for ; Mon, 9 Sep 2019 13:08:37 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 16EBE824376D for ; Mon, 9 Sep 2019 17:08:37 +0000 (UTC) X-FDA: 75916016274.26.cake18_8560777087655 X-Spam-Summary: 2,0,0,422dc56d70a9f356,d41d8cd98f00b204,lpf.vector@gmail.com,:akpm@linux-foundation.org:vbabka@suse.cz:cl@linux.com:penberg@kernel.org:rientjes@google.com:iamjoonsoo.kim@lge.com::linux-kernel@vger.kernel.org:lpf.vector@gmail.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1539:1711:1714:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3350:3865:3866:4321:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13069:13311:13357:13894:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:30054,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-62.50.175.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:neutral,Custom_rules:0:0:0,LFtime:53,LUA_SUMMARY:none X-HE-Tag: cake18_8560777087655 X-Filterd-Recvd-Size: 3734 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Sep 2019 17:08:36 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id 4so8141987pgm.12 for ; Mon, 09 Sep 2019 10:08:36 -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=po3z9vVT8yU9vPmX7PJ6RtAkWylGnCZpE16E0o8CVfM=; b=tEqQBjJ3ODXxSMvYG+vcVbfl2luxsciSY2E+CsqLqrqbVjCNyZKwHecdfEmyUpgt3I uha/ukETxtto5BMjuu0dtOR0bYwM3A1N2k9GAforKbjH3v39Y5ea/j9ZpYQ3OCBTtK2j uwwuuHbyjZlL+Bx7dXXGCY658Q/G9QSrYzDYKb3Ns/Sw9adFXQ9rX8iGQvxXsa1RsP88 g7wSH3FezbdWKoyybVGvKS9N5w3eDSsmPRcg5IznZHJC25aPpJlNTgg0dvd5BXWv71qP MdpLYxk3Aa1LfwYDJdCMXY7pgZS9dvze3XMZ/8A4hJesCTjq+iB8TYQ/DG3DsyNNxxEH CB1g== 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=po3z9vVT8yU9vPmX7PJ6RtAkWylGnCZpE16E0o8CVfM=; b=jdgIGNfHpWxt1L3mkOF4N59Ig+8SisPRyvn8Lcv+WM+QfK2EMEo+i+SE0wmfQXFHhO LGPvX/J85KbS4Sv/ADOb0pAobRxAHcTBlmOluldWk1fYDS6A3MBEhQL20bpqWfql7HmF 4DF7o0cWmmy76Qyw9PHnjMuG8Kz18FK7+O2CVGymXGlK66sk2Et4nmRzWenQaaP2pNrB XPuKXlnKWQuc4LOR3+sg2NYurksV2e1JDGEj8POEfd0F4EqKkwEL09Yph3KASPbHXjiR Kp4Xz+cijPA4Y+wlaYXlofs9nAxQv2k08GTVkXQtTexaNpgV5GYqQgYb/dfih8hY5222 LQ7A== X-Gm-Message-State: APjAAAUkE9ou/oJ9VM2cU0jv3JQ3N7HtSjPu9KpmlH1WcmoF265xhAgO 6Ehe/KUZNyVEvvpKKjn5gDc= X-Google-Smtp-Source: APXvYqw8nmtXQB0qB1NLHmAWDmBgZi64O1gEri+HPL1E/k/r0gZ67FyRjZJKK83eJQ2o5MKUrDATJA== X-Received: by 2002:aa7:8d8e:: with SMTP id i14mr3798050pfr.262.1568048915686; Mon, 09 Sep 2019 10:08:35 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id b18sm107015pju.16.2019.09.09.10.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 10:08:35 -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, Pengfei Li Subject: [PATCH v2 4/4] mm, slab_common: Make initializing KMALLOC_DMA start from 1 Date: Tue, 10 Sep 2019 01:07:15 +0800 Message-Id: <20190909170715.32545-5-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909170715.32545-1-lpf.vector@gmail.com> References: <20190909170715.32545-1-lpf.vector@gmail.com> MIME-Version: 1.0 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: kmalloc_caches[KMALLOC_NORMAL][0] will never be initialized, so the loop should start at 1 instead of 0 Signed-off-by: Pengfei Li --- mm/slab_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index d64a64660f86..6b3e526934d9 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -1236,7 +1236,7 @@ void __init create_kmalloc_caches(slab_flags_t flags) slab_state = UP; #ifdef CONFIG_ZONE_DMA - for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) { + for (i = 1; i <= KMALLOC_SHIFT_HIGH; i++) { struct kmem_cache *s = kmalloc_caches[KMALLOC_NORMAL][i]; if (s) {