Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3588942ybe; Sun, 15 Sep 2019 19:32:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf3jBMpKipBGWf76j/91+RJIV6h8EAhzX7z6V51WANypgBDleKbs6RRgitdjntAfbhtOSj X-Received: by 2002:a17:906:e0c2:: with SMTP id gl2mr13602905ejb.157.1568601169501; Sun, 15 Sep 2019 19:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568601169; cv=none; d=google.com; s=arc-20160816; b=aCwC/PIPsTt6rl8hk+9mGU9+yWlDVX1wlNV50n0IhKRWxrceAiD8f/t2C90Jx2djYY ySeGQOYgpAHgmWE7C/ntzigtd5xyFfXnXUzR1nte72g10kAon5uOfCKzlTpJj7LWAaMN PoF/gMh2DEhjvdHtUJ5Vkjyuadzw6v3vJNZE5Z9qGQNuCA/ohVCQfhCrhq6vdlCS1rCg rqYqODWw0yL2Nri1NMaS2Igu2w/rv5fzb6NIIBD29ozEbd58lBgvjQfrJEES0iTGkPHm HwKrJJjI90niO3zEShMpanPGElb5f7WSI8tpybJFbsHykyzTLIPLMy3ZvwwZK7qD4icP kvRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=iqcLBM+n789oO9D4B4n7QIy38Iivlg6PKsWpya+em6A=; b=FEEGVAb3dyzPPR3/fv6juRWGg7bfVCQK7sjGCNYgh+vQZe2e93NvMj/jKfTqFUBa+J OZ75+2G02UhXu1Ox51bOno7WgPPEANP9GuFcbt/mweTvPjyLpT5oOAcdNHgDaq9EBxJr oeG3bLi+hXuzN8I8qj1dD9xobaBBZK5XEoDGGcU4N2dMg0eScbghtrO7syCiy2MHeWYA +oAmPNwTZL3rojAnpv/Wiu6MtsW2eU9p8iRXHEpZRizW+T423tijQr4UZ21d21SzRZwt PIXAWoB7IFWOch0EfiI6/Z+Ba6J2cwFb8p6srSbs+WXry1uQq9EyV1TsnGYPnIDxP5Np 0lpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kM7G97jx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si22486378edb.238.2019.09.15.19.32.25; Sun, 15 Sep 2019 19:32:49 -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=@google.com header.s=20161025 header.b=kM7G97jx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728670AbfIOVil (ORCPT + 99 others); Sun, 15 Sep 2019 17:38:41 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41280 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728384AbfIOVih (ORCPT ); Sun, 15 Sep 2019 17:38:37 -0400 Received: by mail-pf1-f196.google.com with SMTP id q7so22507pfh.8 for ; Sun, 15 Sep 2019 14:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=iqcLBM+n789oO9D4B4n7QIy38Iivlg6PKsWpya+em6A=; b=kM7G97jxdHw8YVzdyyaHeQYLaPoKqJFxCB3Og1jctbDSOqF/U5eyF/dDAAEnz3Qvko GsFj7yyGpriBpbxWDbnJRo74hVLWMnOl18nGYE23szfaWTnL3kxNgQck36BxjJGV014/ lymowmIpR9a+tv/A3e4AUZTWHedab6fgqulHsbFrbgIp9qGqYLguBeMVuhTA55O2WOOp zEnqGaFwxCsorhzjcpzSYvhnhz8D7mjWFLWRcbHS4Yp60gT3HarRlTQsOtS0nGThnlrO cU0EM7d8QVy5dMVZ4sxegL9kl5iY3Wi/ZiGaU9dFDgofJuGG9W9+5WUQalziTFX183+Q 9kfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=iqcLBM+n789oO9D4B4n7QIy38Iivlg6PKsWpya+em6A=; b=okdi4Ns10RwgEAEdbdS50iRe7iJYABpn4V4VGi4ZEy/QeOz/6ZqwXjQeiE90qYDq1a aUvN12mpGBQI6p9A9Lsg4ar9cTx89fgBip7jEIEh/YXxPxLEsgXIAv2YBJ89q8nR7Usk +znlsraY2NvRIrX3slCbfZ1tO6mEB6LgZoCyPB4fyKGq6VWoyks+RUp4gwJv+Zq0AvAp ws0xX9fZbvcEuYGHIENAvqyJhxdHQCqDUWLgFDx/OV+qQZEB53e6R9oq3m33vCD1DXJo oU6POYxQvbIMUC7DwK3KBgq80zlozmLZj3IQnZKQdRjbd3bWbMbsSZvvUC9A15HiAr2I gbNw== X-Gm-Message-State: APjAAAWL9bfjmimERYWqFR4WJj87ofuKs7quSqXDe/qTIJrcSBYWNYTV qHXIoj4tDAIkB9/Dfj4y8gF0VQ== X-Received: by 2002:a17:90a:8006:: with SMTP id b6mr17107382pjn.4.1568583516601; Sun, 15 Sep 2019 14:38:36 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id c128sm25937293pfc.166.2019.09.15.14.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2019 14:38:36 -0700 (PDT) Date: Sun, 15 Sep 2019 14:38:35 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Pengfei Li cc: akpm@linux-foundation.org, vbabka@suse.cz, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, guro@fb.com Subject: Re: [RESEND v4 5/7] mm, slab_common: Make kmalloc_caches[] start at size KMALLOC_MIN_SIZE In-Reply-To: <20190915170809.10702-6-lpf.vector@gmail.com> Message-ID: References: <20190915170809.10702-1-lpf.vector@gmail.com> <20190915170809.10702-6-lpf.vector@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Sep 2019, Pengfei Li wrote: > Currently, kmalloc_cache[] is not sorted by size, kmalloc_cache[0] > is kmalloc-96, kmalloc_cache[1] is kmalloc-192 (when ARCH_DMA_MINALIGN > is not defined). > > As suggested by Vlastimil Babka, > > "Since you're doing these cleanups, have you considered reordering > kmalloc_info, size_index, kmalloc_index() etc so that sizes 96 and 192 > are ordered naturally between 64, 128 and 256? That should remove > various special casing such as in create_kmalloc_caches(). I can't > guarantee it will be possible without breaking e.g. constant folding > optimizations etc., but seems to me it should be feasible. (There are > definitely more places to change than those I listed.)" > > So this patch reordered kmalloc_info[], kmalloc_caches[], and modified > kmalloc_index() and kmalloc_slab() accordingly. > > As a result, there is no subtle judgment about size in > create_kmalloc_caches(). And initialize kmalloc_cache[] from 0 instead > of KMALLOC_SHIFT_LOW. > > I used ./scripts/bloat-o-meter to measure the impact of this patch on > performance. The results show that it brings some benefits. > > Considering the size change of kmalloc_info[], the size of the code is > actually about 641 bytes less. > bloat-o-meter is reporting a net benefit of -241 bytes for this, so not sure about relevancy of the difference for only kmalloc_info. This, to me, looks like increased complexity for the statically allocated arrays vs the runtime complexity when initializing the caches themselves. Not sure that this is an improvement given that you still need to do things like +#if KMALLOC_SIZE_96_EXIST == 1 + if (size > 64 && size <= 96) return (7 - KMALLOC_IDX_ADJ_0); +#endif + +#if KMALLOC_SIZE_192_EXIST == 1 + if (size > 128 && size <= 192) return (8 - KMALLOC_IDX_ADJ_1); +#endif