From: Vlastimil Babka <vbabka@suse.cz>
To: 1587089010-110083-1-git-send-email-bernard@vivo.com,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com, Bernard Zhao <bernard@vivo.com>
Subject: Re: [PATCH V2] kmalloc_index optimization(code size & runtime stable)
Date: Tue, 21 Apr 2020 15:13:55 +0200 [thread overview]
Message-ID: <339dbb54-b4bc-78e2-e3f0-986814e86d0e@suse.cz> (raw)
In-Reply-To: <20200421032501.127370-1-bernard@vivo.com>
On 4/21/20 5:25 AM, Bernard Zhao wrote:
> kmalloc_index inline function code size optimization and runtime
> performance stability optimization. After optimization, the function
> kmalloc_index is more stable, the size will never affecte the function`s
> execution efficiency.
> And follow test data shows that the performance of new optimization
> exceeds the original algorithm when applying for more than 512 Bytes
> (include 512B).And new optimization runtime is more stable than before.
> Test platform:install vmware ubuntu 16.04, ram 2G, cpu 1, i5-8500 3.00GHz
> Compiler: gcc -O2 optimization, gcc version 5.4.0.
> Just test diff code part.
> Follow is detailed test data:
> size time/Per 100 million times
> old fun new fun with optimise
> 8 203777 241934
> 16 245611 409278
> 32 236384 408419
> 64 275499 447732
> 128 354909 416439
> 256 360472 406598
> 512 431072 409168
> 1024 463822 407401
> 2 * 1024 548519 407710
> 4 * 1024 623378 422326
> 8 * 1024 655932 407457
> 16 * 1024 744673 417574
> 32 * 1024 824889 415316
> 64 * 1024 854374 408577
> 128 * 1024 968079 433582
> 256 * 1024 985527 412080
> 512 * 1024 1196877 448199
> 1024 * 1024 1310315 448969
> 2 * 1024 * 1024 1367441 513117
> 4 * 1024 * 1024 1264623 415019
> 8 * 1024 * 1024 1255727 417197
> 16 * 1024 * 1024 1401431 411087
> 32 * 1024 * 1024 1440415 416616
> 64 * 1024 * 1024 1428122 417459
No, the kernel will never see these time improvements (or non-improvements for
small sizes). See how kmalloc() and kmalloc_node() both call kmalloc_index()
only under "if (__builtin_constant_p(size))"
which means kmalloc is called with a (compile-time) constant size, so this code
is only evaluated at compile time, not while kernel is running. Otherwise it
really wouldn't be implemented as a stream of if's :)
The cases that are not compile time constant size end up in kmalloc_slab(), so
you can see how that one is implemented and what its performance is.
prev parent reply other threads:[~2020-04-21 13:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-21 3:25 Bernard Zhao
2020-04-21 11:18 ` Matthew Wilcox
2020-04-21 11:55 ` 赵军奎
2020-04-21 14:36 ` Matthew Wilcox
2020-04-22 1:12 ` 赵军奎
2020-04-21 13:13 ` Vlastimil Babka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=339dbb54-b4bc-78e2-e3f0-986814e86d0e@suse.cz \
--to=vbabka@suse.cz \
--cc=1587089010-110083-1-git-send-email-bernard@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=bernard@vivo.com \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=opensource.kernel@vivo.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox