From patchwork Mon Sep 16 14:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Li X-Patchwork-Id: 11147185 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 72CD11708 for ; Mon, 16 Sep 2019 14:46:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FDF8206C2 for ; Mon, 16 Sep 2019 14:46: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="AcisQD+z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FDF8206C2 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 14CFF6B0007; Mon, 16 Sep 2019 10:46:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0FDE06B0008; Mon, 16 Sep 2019 10:46: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 F07566B000A; Mon, 16 Sep 2019 10:46:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id CFB576B0007 for ; Mon, 16 Sep 2019 10:46:24 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 743EE181AC9B4 for ; Mon, 16 Sep 2019 14:46:24 +0000 (UTC) X-FDA: 75941059488.26.burn00_1ac4cefaeae2b X-Spam-Summary: 2,0,0,9d1e39f549111fc9,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:guro@fb.com:lpf.vector@gmail.com,RULES_HIT:1:2:41:69:355:379:541:968:973:981:982:988:989:1260:1311:1314:1345:1437:1515:1605:1730:1747:1777:1792:1801:2198:2199:2393:2559:2562:2731:2892:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:4050:4321:4605:5007:6119:6261:6653:6671:7208:7875:7903:8603:9121:9413:10004:11026:11233:11473:11658:11914:12043:12294:12296:12297:12438:12517:12519:12555:12679:12683:12895:12986:13007:13161:13229:13548:13894:14394:14687:21080:21324:21433:21444:21451:21611:21627:21666:21740:30029:30030:30054:30069:30075,0,RBL:209.85.214.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:25,LUA_SUMMARY:non e X-HE-Tag: burn00_1ac4cefaeae2b X-Filterd-Recvd-Size: 10698 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Sep 2019 14:46:23 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id x3so16999804plr.12 for ; Mon, 16 Sep 2019 07:46:23 -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:mime-version :content-transfer-encoding; bh=IBPqXpH8lLCyhC7DITHtIHyRwcTR3vMB2CqhiOYdM8U=; b=AcisQD+zOOeU8UyX+jyrol8Xjx+euAW5bDVk5cUOLssnJTY1oLvq7UrlB9540X1B76 aaFHvxRV9+Fr1w/m76yEYaayiLd8/p3m+vxRs1NdU5hL7GXgnRw0vnV25XdeL56azWDm xxBClcrQeML9XugFIIjgwaFSvA7LdIgcIs17HmntqEtg0IPMqmE9Ev3bIAksWojSbqvX 2eMemeUiMH0DJfwClFfhkLmhjjdU0QgDCJ0s+HOCzdq36TdWxYjMKcgY0wmCIc1NmR5w j7FY50eUtilN+sVGgN0dulsdBxoa8Y4CRJYD4Z68FLubTOa1xjmzqJJ+uwwt/u4unXEK w1jw== 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:mime-version :content-transfer-encoding; bh=IBPqXpH8lLCyhC7DITHtIHyRwcTR3vMB2CqhiOYdM8U=; b=caa1nrZeBgP+ppvsSMCuN2oeZyz+9smUm8ZCDdEIoiO7/hZfdKeaOSQCX2sJ5hwJ9D Jykj8FcUjRcSO0pyAqEBrvrTisPM5I+AhVHRQpUaYrb9C2lw2VZr9Fr984aj42gZHiT2 myOZVpclMalBNZOCq74ABzkh1C+XORnrX3vWwHveHxp9ObnQUwPQ+KBKB2aR8OCR1Ovn GD0EySsHD56mHyxK9ZmT3li1yFLcUDzlvbvRTW/RrPzuv7LAvUbLHGkrdt5YUQFAPD2F OFuvQDjyDJrZkH7de49JL2EYK4C9inX8/tGkN0W1E/H6aOn/p9tSrINbNx+G2oPW6gIq eqrQ== X-Gm-Message-State: APjAAAUkbQaKajXEBSsbmUg2bJLhaqgJ73PhuOKfrdoSrlcd2kfQ1fqQ D2kWaDrKoAXbef8XMsqhYhg= X-Google-Smtp-Source: APXvYqzk3ns7VkzJvAJFufMdfzezEYwg1nDV/5EsmHw42nLSAtEt9aVoHmqANYdGDIWgOih/nAsFoA== X-Received: by 2002:a17:902:8c98:: with SMTP id t24mr158126plo.230.1568645182735; Mon, 16 Sep 2019 07:46:22 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:160:b8c3:8577:bf2f:3]) by smtp.gmail.com with ESMTPSA id d190sm15036004pgc.25.2019.09.16.07.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 07:46:21 -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 v5 0/7] mm, slab: Make kmalloc_info[] contain all types of names Date: Mon, 16 Sep 2019 22:45:51 +0800 Message-Id: <20190916144558.27282-1-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000017, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Changes in v5 --- 1. patch 1/7: - rename SET_KMALLOC_SIZE to INIT_KMALLOC_INFO 2. patch 5/7: - fix build errors (Reported-by: kbuild test robot) - make all_kmalloc_info[] static (Reported-by: kbuild test robot) 3. patch 6/7: - for robustness, determine kmalloc_cache is !NULL in new_kmalloc_cache() 4. add ack tag from David Rientjes Changes in v4 -- 1. [old] abandon patch 4/4 2. [new] patch 4/7: - return ZERO_SIZE_ALLOC instead 0 for zero sized requests 3. [new] patch 5/7: - reorder kmalloc_info[], kmalloc_caches[] (in order of size) - hard to split, so slightly larger 4. [new] patch 6/7: - initialize kmalloc_cache[] with the same size but different types 5. [new] patch 7/7: - modify kmalloc_caches[type][idx] to kmalloc_caches[idx][type] Patch 4-7 are newly added, more information can be obtained from commit messages. Changes in v3 -- 1. restore __initconst (patch 1/4) 2. rename patch 3/4 3. add more clarification for patch 4/4 4. add ack tag from Roman Gushchin Changes in v2 -- 1. remove __initconst (patch 1/5) 2. squash patch 2/5 3. add ack tag from Vlastimil Babka 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(). Patch1 predefines the names of all types of kmalloc to save the time spent dynamically generating names. These changes make sense, and the time spent by new_kmalloc_cache() has been reduced by approximately 36.3%. Time spent by new_kmalloc_cache() (CPU cycles) 5.3-rc7 66264 5.3-rc7+patch_1-3 42188 bloat-o-meter -- $ ./scripts/bloat-o-meter vmlinux_5.3 vmlinux_5.3+patch_1-7 add/remove: 1/2 grow/shrink: 6/65 up/down: 872/-1574 (-702) Function old new delta all_kmalloc_info - 832 +832 crypto_create_tfm 211 225 +14 ieee80211_key_alloc 1159 1169 +10 nl80211_parse_sched_scan 2787 2795 +8 tg3_self_test 4255 4259 +4 find_get_context.isra 634 637 +3 sd_probe 947 948 +1 nf_queue 671 670 -1 trace_parser_get_init 71 69 -2 pkcs7_verify.cold 318 316 -2 units 323 320 -3 nl80211_set_reg 642 639 -3 pkcs7_verify 1503 1495 -8 i915_sw_fence_await_dma_fence 445 437 -8 nla_strdup 143 134 -9 kmalloc_slab 102 93 -9 xhci_alloc_tt_info 349 338 -11 xhci_segment_alloc 303 289 -14 xhci_alloc_container_ctx 221 207 -14 xfrm_policy_alloc 277 263 -14 selinux_sk_alloc_security 119 105 -14 sdev_evt_send_simple 124 110 -14 sdev_evt_alloc 85 71 -14 sbitmap_queue_init_node 424 410 -14 regulatory_hint_found_beacon 400 386 -14 nf_ct_tmpl_alloc 91 77 -14 gss_create_cred 146 132 -14 drm_flip_work_allocate_task 76 62 -14 cfg80211_stop_iface 266 252 -14 cfg80211_sinfo_alloc_tid_stats 83 69 -14 cfg80211_port_authorized 218 204 -14 cfg80211_ibss_joined 341 327 -14 call_usermodehelper_setup 155 141 -14 bpf_prog_alloc_no_stats 188 174 -14 blk_alloc_flush_queue 197 183 -14 bdi_alloc_node 201 187 -14 _netlbl_catmap_getnode 253 239 -14 __igmp_group_dropped 629 615 -14 ____ip_mc_inc_group 481 467 -14 xhci_alloc_command 221 205 -16 audit_log_d_path 204 188 -16 xprt_switch_alloc 145 128 -17 xhci_ring_alloc 378 361 -17 xhci_mem_init 3673 3656 -17 xhci_alloc_virt_device 505 488 -17 xhci_alloc_stream_info 727 710 -17 tcp_sendmsg_locked 3129 3112 -17 tcp_md5_do_add 783 766 -17 tcp_fastopen_defer_connect 279 262 -17 sr_read_tochdr.isra 260 243 -17 sr_read_tocentry.isra 337 320 -17 sr_is_xa 385 368 -17 sr_get_mcn 269 252 -17 scsi_probe_and_add_lun 2947 2930 -17 ring_buffer_read_prepare 103 86 -17 request_firmware_nowait 405 388 -17 ohci_urb_enqueue 3185 3168 -17 nfs_alloc_seqid 96 79 -17 nfs4_get_state_owner 1049 1032 -17 nfs4_do_close 587 570 -17 mempool_create_node 173 156 -17 ip6_setup_cork 1030 1013 -17 ida_alloc_range 951 934 -17 gss_import_sec_context 187 170 -17 dma_pool_alloc 419 402 -17 devres_open_group 223 206 -17 cfg80211_parse_mbssid_data 2406 2389 -17 ip_setup_cork 374 354 -20 kmalloc_caches 336 312 -24 __i915_sw_fence_await_sw_fence 429 405 -24 kmalloc_cache_name 57 - -57 create_kmalloc_caches 270 195 -75 new_kmalloc_cache 112 - -112 kmalloc_info 432 8 -424 Total: Before=14789209, After=14788507, chg -0.00% Pengfei Li (7): mm, slab: Make kmalloc_info[] contain all types of names mm, slab: Remove unused kmalloc_size() mm, slab_common: Use enum kmalloc_cache_type to iterate over kmalloc caches mm, slab: Return ZERO_SIZE_ALLOC for zero sized kmalloc requests mm, slab_common: Make kmalloc_caches[] start at size KMALLOC_MIN_SIZE mm, slab_common: Initialize the same size of kmalloc_caches[] mm, slab_common: Modify kmalloc_caches[type][idx] to kmalloc_caches[idx][type] include/linux/slab.h | 136 ++++++++++++++------------ mm/slab.c | 11 ++- mm/slab.h | 10 +- mm/slab_common.c | 227 ++++++++++++++++++------------------------- mm/slub.c | 12 +-- 5 files changed, 187 insertions(+), 209 deletions(-)