* [PATCH] mm/slub: branch optimization in free slowpath
@ 2020-08-13 10:18 wuyun.wu
2020-08-13 16:47 ` Christopher Lameter
0 siblings, 1 reply; 2+ messages in thread
From: wuyun.wu @ 2020-08-13 10:18 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton
Cc: hewenliang4, hushiyuan, Abel Wu, open list:SLAB ALLOCATOR, open list
From: Abel Wu <wuyun.wu@huawei.com>
The two conditions are mutually exclusive and gcc compiler will
optimise this into if-else-like pattern. Given that the majority
of free_slowpath is free_frozen, let's provide some hint to the
compilers.
Tests (perf bench sched messaging -g 20 -l 400000, executed 10x
after reboot) are done and the summarized result:
un-patched patched
max. 192.316 189.851
min. 187.267 186.252
avg. 189.154 188.086
stdev. 1.37 0.99
Signed-off-by: Abel Wu <wuyun.wu@huawei.com>
---
mm/slub.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 4f496ae5a820..f9182a760675 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2958,20 +2958,21 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
if (likely(!n)) {
- /*
- * If we just froze the page then put it onto the
- * per cpu partial list.
- */
- if (new.frozen && !was_frozen) {
+ if (likely(was_frozen)) {
+ /*
+ * The list lock was not taken therefore no list
+ * activity can be necessary.
+ */
+ stat(s, FREE_FROZEN);
+ } else if (new.frozen) {
+ /*
+ * If we just froze the page then put it onto the
+ * per cpu partial list.
+ */
put_cpu_partial(s, page, 1);
stat(s, CPU_PARTIAL_FREE);
}
- /*
- * The list lock was not taken therefore no list
- * activity can be necessary.
- */
- if (was_frozen)
- stat(s, FREE_FROZEN);
+
return;
}
--
2.28.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/slub: branch optimization in free slowpath
2020-08-13 10:18 [PATCH] mm/slub: branch optimization in free slowpath wuyun.wu
@ 2020-08-13 16:47 ` Christopher Lameter
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Lameter @ 2020-08-13 16:47 UTC (permalink / raw)
To: Abel Wu
Cc: Pekka Enberg, David Rientjes, Joonsoo Kim, Andrew Morton,
hewenliang4, hushiyuan, open list:SLAB ALLOCATOR, open list
On Thu, 13 Aug 2020, wuyun.wu@huawei.com wrote:
> The two conditions are mutually exclusive and gcc compiler will
> optimise this into if-else-like pattern. Given that the majority
> of free_slowpath is free_frozen, let's provide some hint to the
> compilers.
Acked-by: Christoph Lameter <cl@linux.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-13 16:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 10:18 [PATCH] mm/slub: branch optimization in free slowpath wuyun.wu
2020-08-13 16:47 ` Christopher Lameter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).