SLQB: YASA
Subsystems (5)
RFC 1/1 SLQB: YASA
Hi,
I've been playing around with slab allocators because I'm concerned about the directions that SLUB is going in. I've come up so far with a working alternative implementation, which I have called SLQB (the remaining vowels are crap).
It's not exactly polished, and still needs work to improve eg in OOM or spread allocation paths, and also maybe I should try to get all the sysfs stuff from SLUB working... but at present at least it works and seems stable and has /proc/slabinfo. It hasn't had too much performance analysis on real workloads, but on a couple of microbenchmarks it seems to be more or less competitive.
What I have tried to concentrate on is:
- Per CPU scalability, which is important for MC and MT CPUs. This is achieved by having per CPU queues of node local free and partial lists. Per node lists are used for off-node allocations.
- Good performance with order-0 pages.
I feel that order-0 allocations are the way to go and higher orders are not. This is achieved by using queues of pages. We still could* use higher order allocations, but it is not as important as SLUB.
I'm not quite sure what to do with this. If anybody could test or comment, I guess that would be a good start :)
Patch is against mainline.
Thanks,
Nick
---
include/linux/rcupdate.h +8 -8
@@ -35,14 +35,6 @@#ifdef __KERNEL__ -#include <linux/cache.h> -#include <linux/spinlock.h> -#include <linux/threads.h> -#include <linux/percpu.h> -#include <linux/cpumask.h> -#include <linux/seqlock.h> -#include <linux/lockdep.h> -/** * struct rcu_head - callback structure for use with RCU * @next: next update requests in a list
@@ -53,6 +45,14 @@ struct rcu_head {void (*func)(struct rcu_head *head); }; +#include <linux/cache.h> +#include <linux/spinlock.h> +#include <linux/threads.h> +#include <linux/percpu.h> +#include <linux/cpumask.h> +#include <linux/seqlock.h> +#include <linux/lockdep.h> +#ifdef CONFIG_CLASSIC_RCU #include <linux/rcuclassic.h> #else /* #ifdef CONFIG_CLASSIC_RCU */
arch/x86/kernel/nmi_64.c +1 -1
@@ -28,7 +28,7 @@int unknown_nmi_panic;int nmi_watchdog_enabled; -int panic_on_unrecovered_nmi; +int panic_on_unrecovered_nmi =1 ;static cpumask_t backtrace_mask =CPU_MASK_NONE ;
include/linux/slqb_def.h new file +261 -0
261 lines not on this page · raw message
init/Kconfig +9 -1
@@ -701,6 +701,11 @@ config SLUB_DEBUG SLUB sysfs support. /sys/slab will not exist and there will be no support for cache validation etc. +config SLQB_DEBUG + default y + bool "Enable SLQB debugging support" + depends on SLQB + choice prompt "Choose SLAB allocator" default SLUB
@@ -724,6 +729,9 @@ config SLUB of queues of objects. SLUB can use memory efficiently and has enhanced diagnostics. +config SLQB + bool "SLQB (Qeued allocator)" + config SLOB depends on EMBEDDED bool "SLOB (Simple Allocator)"
@@ -763,7 +771,7 @@ endmenu # General setup config SLABINFO bool depends on PROC_FS - depends on SLAB || SLUB + depends on SLAB || SLUB || SLQB default y config RT_MUTEXES
lib/Kconfig.debug +10 -0
@@ -221,6 +221,16 @@ config SLUB_STATS out which slabs are relevant to a particular load. Try running: slabinfo -DA +config SLQB_DEBUG_ON + bool "SLQB debugging on by default" + depends on SLQB_DEBUG + default n + +config SLQB_STATS + default n + bool "Enable SLQB performance statistics" + depends on SLQB + config DEBUG_PREEMPT bool "Debug preemptible kernel" depends on DEBUG_KERNEL && PREEMPT && (TRACE_IRQFLAGS_SUPPORT || PPC64)
mm/slqb.c new file +4017 -0
2,659 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Hi Nick,
Quoted 2 lines · Nick Piggin
I'm not quite sure what to do with this. If anybody could test or comment, I guess that would be a good start :)
Why is this not a patch set against SLUB?
Quoted 7 lines · Pekka Enberg
Hi Nick,
Quoted 2 lines · Nick Piggin
I'm not quite sure what to do with this. If anybody could test or comment, I guess that would be a good start :)
Why is this not a patch set against SLUB?
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.
Quoted 9 lines · Nick Piggin
Quoted 7 lines · Pekka Enberg
Hi Nick,
Quoted 2 lines · Nick Piggin
I'm not quite sure what to do with this. If anybody could test or comment, I guess that would be a good start :)
Why is this not a patch set against SLUB?
Quoted 8 lines
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with
slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.
And also I guess I don't think Christoph would be very happy about it :) He loves higher order allocations :)
The high level choices are pretty clear and I simply think there might be a better way to do it. I'm not saying it *is* better because I simply don't know, and there are areas where the tradeoffs I've made means that in some situations SLQB cannot match SLUB.
Hi Nick,
Quoted 8 lines · Nick Piggin
Quoted 8 lines
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with
slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.
Quoted 7 lines · Nick Piggin
And also I guess I don't think Christoph would be very happy about it :) He loves higher order allocations :)
The high level choices are pretty clear and I simply think there might be a better way to do it. I'm not saying it *is* better because I simply don't know, and there are areas where the tradeoffs I've made means that in some situations SLQB cannot match SLUB.
So do you disagree with Christoph's statement that we should fix page allocator performance instead of adding queues to SLUB? I also don't think higher order allocations are the answer for regular boxes but I can see why they're useful for HPC people with huge machines.
Pekka
Quoted 16 lines · Pekka Enberg
Hi Nick,
Quoted 8 lines · Nick Piggin
Quoted 8 lines
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with
slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.Quoted 3 lines · Nick Piggin
And also I guess I don't think Christoph would be very happy about it :) He loves higher order allocations :)
Quoted 7 lines
Quoted 4 lines
The high level choices are pretty clear and I simply think there might be a better way to do it. I'm not saying it *is* better because I simply don't know, and there are areas where the tradeoffs I've made means that in some situations SLQB cannot match SLUB.
So do you disagree with Christoph's statement that we should fix page allocator performance instead of adding queues to SLUB?
It's not just adding queues to SLUB, by any means (SLUB effectively already has queues anyway, with it's MIN_PARTIAL thing).
I think some page allocator performance can be improved (see my patch to remove the atomic refcounting for example). But in other cases the page allocator just has to do a lot more work and fixing it would just involve removing some of those things.
Quoted 3 lines
I also don't
think higher order allocations are the answer for regular boxes but I can see why they're useful for HPC people with huge machines.
I don't disagree with what you say. SLQB doesn't prevent them from being used.
Hi
Quoted 10 lines
Quoted 1 line
Why is this not a patch set against SLUB?
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with
slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.
Do you have performance mesurement result?
I hope see it if possible.
Thanks! :)
Quoted 13 lines · KOSAKI Motohiro
Hi
Quoted 10 lines
Quoted 1 line
Why is this not a patch set against SLUB?
It's a completely different design of the core allocator algorithms really.
It probably looks quite similar because I started with
slub.c, but really is just the peripheral supporting code and structure. I'm never intending to try to go through the pain of incrementally changing SLUB into SLQB. If SLQB is found to be a good idea, then it could maybe get merged.
Quoted 4 lines
Do you have performance mesurement result?
I hope see it if possible.Thanks! :)
Nothing really interesting, unfortunately. I have run some tests on various microbenchmarks like tbench and things like that. But I don't have many good ideas for more meaningful tests where slab allocation performance is critial. Any suggestions? :)
Thanks,
Nick
Hi
Quoted 9 lines
Quoted 4 lines
Do you have performance mesurement result?
I hope see it if possible.Thanks! :)
Nothing really interesting, unfortunately. I have run some tests on various microbenchmarks like tbench and things like that. But I don't have many good ideas for more meaningful tests where slab allocation performance is critial. Any suggestions? :)
nothing.
sorry, i am not slab expert ;)
Quoted 5 lines · Nick Piggin
Nothing really interesting, unfortunately. I have run some tests on various microbenchmarks like tbench and things like that. But I don't have many good ideas for more meaningful tests where slab allocation performance is critial. Any suggestions? :)
Some networking workloads hit slab pretty aggressive (two allocations per packet)
Just be careful with standard loopback, it has a contended lock elsewhere
-Andi
Quoted 6 lines · Nick Piggin
Hi,
I've been playing around with slab allocators because I'm concerned about the directions that SLUB is going in. I've come up so far with a working alternative implementation, which I have called SLQB (the remaining vowels are crap).
Oh, hmm, I think I messed up a hunk when merging in a patch here... so this version is going to be buggy. I'll repost another tomorrow, so nobody try to test this yet :)
Thanks,
Nick
Em Thu, 3 Apr 2008 16:23:26 +0200
Nick Piggin <[email protected]> escreveu:
| On Thu, Apr 03, 2008 at 09:25:50AM +0200, Nick Piggin wrote: | > Hi, | > | > I've been playing around with slab allocators because I'm concerned about | > the directions that SLUB is going in. I've come up so far with a working | > alternative implementation, which I have called SLQB (the remaining vowels | > are crap). | | Oh, hmm, I think I messed up a hunk when merging in a patch here... so | this version is going to be buggy. I'll repost another tomorrow, so | nobody try to test this yet :)
Thanks for letting us know, I was trying to merge this.
Would be nice if you say for what kernel the patch is for,
normally I assume Linus' latest but sometimes patches are against -mm.
Signature · 1 line
Luiz Fernando N. Capitulino
Quoted 4 lines · Nick Piggin
I've been playing around with slab allocators because I'm concerned about the directions that SLUB is going in. I've come up so far with a working alternative implementation, which I have called SLQB (the remaining vowels are crap).
Hmm... Interesting stuff. I have toyed around with a lot of similar ideas to add at least limited queuing to SLUB but the increased overhead / complexity in the hot paths always killed these attempts. Well worth pursuing and I could even imagine the queuing you are adding to be merged to SLUB (or rename it to whatever else) if it does not impact performance otherwise.
Quoted 4 lines
What I have tried to concentrate on is:
- Per CPU scalability, which is important for MC and MT CPUs. This is achieved by having per CPU queues of node local free and partial lists. Per node lists are used for off-node allocations.
Yeah that is similar to SLAB. The off node lists will require locks and thus you run into similar issues with queue management as in SLAB. How do you expire the objects and configure the queues?
Quoted 4 lines
- Good performance with order-0 pages.
I feel that order-0 allocations are the way to go and higher orders are not. This is achieved by using queues of pages. We still could* use higher order allocations, but it is not as important as SLUB.
If you want to go with order-0 pages then it would be good to first work on the page allocator performance so that there is no need of buffering order-0 allocations in the slab allocators. The buffering stuff for 4k allocs that I had to add to SLUB in 2.6.25 and that likely concerns you could go mostly away if the page allocator had competitive performance.
Higher orders are still likely a must in the future because it allows a reduction of the metadata management overhead (pretty important for filesystems f.e.). And the argument about faster processors compensating for the increased effort to manage the metadata (page structs and such) really does not cut it because memory speeds do not keep up nor does the evolution of the locking algorithms / reclaim logic in the kernel.
Here is my more working version of SLQB.
Was experimenting with a couple of different ways to do remote freeing, but it is really hard to tune properly without having "real" workloads, due to cache effects.
Anyway, same comments apply. Patch is against mainline.
---
include/linux/rcupdate.h +8 -8
@@ -35,14 +35,6 @@#ifdef __KERNEL__ -#include <linux/cache.h> -#include <linux/spinlock.h> -#include <linux/threads.h> -#include <linux/percpu.h> -#include <linux/cpumask.h> -#include <linux/seqlock.h> -#include <linux/lockdep.h> -/** * struct rcu_head - callback structure for use with RCU * @next: next update requests in a list
@@ -53,6 +45,14 @@ struct rcu_head {void (*func)(struct rcu_head *head); }; +#include <linux/cache.h> +#include <linux/spinlock.h> +#include <linux/threads.h> +#include <linux/percpu.h> +#include <linux/cpumask.h> +#include <linux/seqlock.h> +#include <linux/lockdep.h> +#ifdef CONFIG_CLASSIC_RCU #include <linux/rcuclassic.h> #else /* #ifdef CONFIG_CLASSIC_RCU */
arch/x86/kernel/nmi_64.c +1 -1
@@ -28,7 +28,7 @@int unknown_nmi_panic;int nmi_watchdog_enabled; -int panic_on_unrecovered_nmi; +int panic_on_unrecovered_nmi =1 ;static cpumask_t backtrace_mask =CPU_MASK_NONE ;
include/linux/slqb_def.h new file +264 -0
264 lines not on this page · raw message
init/Kconfig +9 -1
@@ -701,6 +701,11 @@ config SLUB_DEBUG SLUB sysfs support. /sys/slab will not exist and there will be no support for cache validation etc. +config SLQB_DEBUG + default y + bool "Enable SLQB debugging support" + depends on SLQB + choice prompt "Choose SLAB allocator" default SLUB
@@ -724,6 +729,9 @@ config SLUB of queues of objects. SLUB can use memory efficiently and has enhanced diagnostics. +config SLQB + bool "SLQB (Qeued allocator)" + config SLOB depends on EMBEDDED bool "SLOB (Simple Allocator)"
@@ -763,7 +771,7 @@ endmenu # General setup config SLABINFO bool depends on PROC_FS - depends on SLAB || SLUB + depends on SLAB || SLUB || SLQB default y config RT_MUTEXES
lib/Kconfig.debug +10 -0
@@ -221,6 +221,16 @@ config SLUB_STATS out which slabs are relevant to a particular load. Try running: slabinfo -DA +config SLQB_DEBUG_ON + bool "SLQB debugging on by default" + depends on SLQB_DEBUG + default n + +config SLQB_STATS + default n + bool "Enable SLQB performance statistics" + depends on SLQB + config DEBUG_PREEMPT bool "Debug preemptible kernel" depends on DEBUG_KERNEL && PREEMPT && (TRACE_IRQFLAGS_SUPPORT || PPC64)
mm/slqb.c new file +4017 -0
2,656 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Em Tue, 8 Apr 2008 13:57:17 +0200
Nick Piggin <[email protected]> escreveu:
| Here is my more working version of SLQB. | | Was experimenting with a couple of different ways to do remote freeing, | but it is really hard to tune properly without having "real" workloads, | due to cache effects. | | Anyway, same comments apply. Patch is against mainline.
I get the following error when compiling without CONFIG_SMP
"""
In file included from include/linux/rcupdate.h:52,
from include/linux/slqb_def.h:15,
from include/linux/slab.h:121,
from include/asm/pgtable_32.h:22,
from include/asm/pgtable.h:241,
from include/linux/mm.h:40,
from arch/x86/kernel/pci-dma_32.c:12:include/linux/percpu.h: In function '__percpu_alloc_mask':include/linux/percpu.h:106: error: implicit declaration of function 'kzalloc' include/linux/percpu.h:106: warning: return makes pointer from integer without a cast In file included from include/asm/pgtable_32.h:22,
from include/asm/pgtable.h:241,
from include/linux/mm.h:40,
from arch/x86/kernel/pci-dma_32.c:12:include/linux/slab.h: At top level:include/linux/slab.h:272: error: conflicting types for 'kzalloc' include/linux/percpu.h:106: error: previous implicit declaration of 'kzalloc' was here ICECC[27645] 15:49:30: Compiled on XXXXXXXX
make[1]: *** [arch/x86/kernel/pci-dma_32.o] Error 1
make: *** [arch/x86/kernel] Error 2
"""
Could not figure out what the problem is.
Regarding performance tests, I saw that Christoph has some
interesting test modules in his git repository. Do you think it's worth to run them?
Signature · 7 lines
Luiz Fernando N. Capitulino -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 35 lines · Luiz Fernando N. Capitulino
Em Tue, 8 Apr 2008 13:57:17 +0200
Nick Piggin <[email protected]> escreveu:| Here is my more working version of SLQB. | | Was experimenting with a couple of different ways to do remote freeing, | but it is really hard to tune properly without having "real" workloads, | due to cache effects. | | Anyway, same comments apply. Patch is against mainline.I get the following error when compiling without
CONFIG_SMP"""
In file included frominclude/linux/rcupdate.h:52,from include/linux/slqb_def.h:15, from include/linux/slab.h:121, from include/asm/pgtable_32.h:22, from include/asm/pgtable.h:241, from include/linux/mm.h:40, from arch/x86/kernel/pci-dma_32.c:12:
include/linux/percpu.h: In function '__percpu_alloc_mask':include/linux/percpu.h:106: error: implicit declaration of function 'kzalloc'include/linux/percpu.h:106: warning: return makes pointer from integer without a cast In file included frominclude/asm/pgtable_32.h:22,from include/asm/pgtable.h:241, from include/linux/mm.h:40, from arch/x86/kernel/pci-dma_32.c:12:
include/linux/slab.h: At top level:include/linux/slab.h:272: error: conflicting types for 'kzalloc'include/linux/percpu.h:106: error: previous implicit declaration of 'kzalloc' was here ICECC[27645] 15:49:30: Compiled on XXXXXXXX
make[1]: *** [arch/x86/kernel/pci-dma_32.o] Error 1
make: *** [arch/x86/kernel] Error 2
Quoted 3 lines
"""
Could not figure out what the problem is.
Hmm, it seems like some kind of recursive dep, but somehow it goes away with SMP, so it must be fixable... I'll take a further look.
Quoted 3 lines
Regarding performance tests, I saw that Christoph has some
interesting test modules in his git repository. Do you think it's worth to run them?
I have tried some of them, yes. Performance comparisons vary depending on machine and workload, but I'd say it is mostly competitive. But those tests are quite basic and are very far from real world situations. They are very good for some cases showing where you might have a problem, but not so useful when comparing 2 different allocators.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>