* [PATCH] x86_64 - Use non locked version for local_cmpxchg() @ 2007-07-14 1:19 Mathieu Desnoyers 0 siblings, 0 replies; 3+ messages in thread From: Mathieu Desnoyers @ 2007-07-14 1:19 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-kernel, Christoph Lameter, Andi Kleen x86_64 - Use non locked version for local_cmpxchg() local_cmpxchg() should not use any LOCK prefix. This change probably got lost in the move to cmpxchg.h. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Acked-by: Christoph Lameter <clameter@sgi.com> CC: Andi Kleen <andi@firstfloor.org> --- include/asm-x86_64/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-2.6-lttng/include/asm-x86_64/cmpxchg.h =================================================================== --- linux-2.6-lttng.orig/include/asm-x86_64/cmpxchg.h 2007-07-10 01:10:10.000000000 -0400 +++ linux-2.6-lttng/include/asm-x86_64/cmpxchg.h 2007-07-10 01:11:03.000000000 -0400 @@ -128,7 +128,7 @@ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) #define cmpxchg_local(ptr,o,n)\ - ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ + ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) #endif -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance @ 2007-07-08 3:49 Christoph Lameter 2007-07-08 11:20 ` Andi Kleen 0 siblings, 1 reply; 3+ messages in thread From: Christoph Lameter @ 2007-07-08 3:49 UTC (permalink / raw) To: linux-kernel; +Cc: linux-mm, suresh.b.siddha, corey.d.gough, Pekka Enberg, akpm This series here contains a number of patches that need some discussion or evaluation. They apply on top of 2.6.22-rc6-mm1 + slub patches already in mm. 1. Page allocator pass through SLOB does pass through all larger kmalloc requests directly to the page allocator. The advantage is that the allocator overhead is eliminated and that we do not need to provide kmalloc slabs >= PAGE_SIZE. This patch does the same thing in SLUB. For allocation whose size is know the call to the slab may be converted to a call to the page allocator at compile time. The result of doing so is also that the behavior of SLUB for pagesize and higher kmalloc allocation will conform to SLAB. Meaning large kmalloc allocations are no longer debuggable and are guaranteed to be page aligned. Do we want this? 2. A series of performance enhancements patches The patches improve the producer / consumer scenario. If objects are always allocated on one processor and released on another then both will use distinct cachelines to store their information in order to avoid a bouncing cacheline. In order to do so we have to introduce a per cpu structure to keep per cpu allocation lists in distinct cachelines from the remote free information in the page struct. If we introduce a per cpu structure then we also need to allocate that in a NUMA aware fashion from the local node. Having a per cpu structure allows to avoid the use of certain fields in the page struct which in turn allows us to avoid using page->mapping and increasing the maximum number of objects per slab. More optimizations become possible by shifting information from the kmem_cache structure that is used in the hotpath to the per cpu structure thereby minimizing cacheline coverage. Finally there is an implementation of slab_alloc/slab_free using a cmpxchg instead of current interrupt enable disable approach. This was inspired by LTTng's approach. A cmpxchg is less costly than interrupt enabe/disable but means more complexity in managing the resulting race conditions. The disadvantage is that the allocation / free paths become very complex and fragile. All of these patches need to be evaluated as to what impact they have on a variety of loads. 3. Removal of SLOB and SLAB. We would like to consolidate and only have one slab allocator in the future. Two patches are included that remove SLOB and SLAB. There is only minimal justification for retaining SLOB. So I think we could remove SLOB for 2.6.23. SLAB is the reference that SLUB must be measured against to avoid regressions. On the other hand it will be a problem to support new functionality like Slab defragmentation since its design makes it difficult to implement comparable features. So I think that we need to keep SLAB around for one more cycle and then we may be able to get rid of it. Or we can keep it in the tree for awhile and produce more and more shims for new slab functionality. -- ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-08 3:49 [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance Christoph Lameter @ 2007-07-08 11:20 ` Andi Kleen 2007-07-09 15:50 ` Christoph Lameter 0 siblings, 1 reply; 3+ messages in thread From: Andi Kleen @ 2007-07-08 11:20 UTC (permalink / raw) To: Christoph Lameter; +Cc: linux-kernel, linux-mm Christoph Lameter <clameter@sgi.com> writes: > A cmpxchg is less costly than interrupt enabe/disable That sounds wrong. -Andi ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-08 11:20 ` Andi Kleen @ 2007-07-09 15:50 ` Christoph Lameter 2007-07-09 15:59 ` Martin Bligh 0 siblings, 1 reply; 3+ messages in thread From: Christoph Lameter @ 2007-07-09 15:50 UTC (permalink / raw) To: Andi Kleen; +Cc: linux-kernel, linux-mm, mbligh On Sun, 8 Jul 2007, Andi Kleen wrote: > Christoph Lameter <clameter@sgi.com> writes: > > > A cmpxchg is less costly than interrupt enabe/disable > > That sounds wrong. Martin Bligh was able to significantly increase his LTTng performance by using cmpxchg. See his article in the 2007 proceedings of the OLS Volume 1, page 39. His numbers were: interrupts enable disable : 210.6ns local cmpxchg : 9.0ns ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 15:50 ` Christoph Lameter @ 2007-07-09 15:59 ` Martin Bligh 2007-07-09 18:11 ` Christoph Lameter 0 siblings, 1 reply; 3+ messages in thread From: Martin Bligh @ 2007-07-09 15:59 UTC (permalink / raw) To: Christoph Lameter; +Cc: Andi Kleen, linux-kernel, linux-mm Christoph Lameter wrote: > On Sun, 8 Jul 2007, Andi Kleen wrote: > >> Christoph Lameter <clameter@sgi.com> writes: >> >>> A cmpxchg is less costly than interrupt enabe/disable >> That sounds wrong. > > Martin Bligh was able to significantly increase his LTTng performance > by using cmpxchg. See his article in the 2007 proceedings of the OLS > Volume 1, page 39. > > His numbers were: > > interrupts enable disable : 210.6ns > local cmpxchg : 9.0ns Those numbers came from Mathieu Desnoyers (LTTng) if you want more details. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 15:59 ` Martin Bligh @ 2007-07-09 18:11 ` Christoph Lameter 2007-07-09 21:00 ` Martin Bligh 0 siblings, 1 reply; 3+ messages in thread From: Christoph Lameter @ 2007-07-09 18:11 UTC (permalink / raw) To: Martin Bligh; +Cc: Andi Kleen, linux-kernel, linux-mm On Mon, 9 Jul 2007, Martin Bligh wrote: > Those numbers came from Mathieu Desnoyers (LTTng) if you > want more details. Okay the source for these numbers is in his paper for the OLS 2006: Volume 1 page 208-209? I do not see the exact number that you referred to there. He seems to be comparing spinlock acquire / release vs. cmpxchg. So I guess you got your material from somewhere else? Also the cmpxchg used there is the lockless variant. cmpxchg 29 cycles w/o lock prefix and 112 with lock prefix. I see you reference another paper by Desnoyers: http://tree.celinuxforum.org/CelfPubWiki/ELC2006Presentations?action=AttachFile&do=get&target=celf2006-desnoyers.pdf I do not see anything relevant there. Where did those numbers come from? The lockless cmpxchg is certainly an interesting idea. Certain for some platforms I could disable preempt and then do a lockless cmpxchg. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 18:11 ` Christoph Lameter @ 2007-07-09 21:00 ` Martin Bligh 2007-07-09 21:44 ` Mathieu Desnoyers 0 siblings, 1 reply; 3+ messages in thread From: Martin Bligh @ 2007-07-09 21:00 UTC (permalink / raw) To: Christoph Lameter; +Cc: Andi Kleen, linux-kernel, linux-mm, Mathieu Desnoyers Christoph Lameter wrote: > On Mon, 9 Jul 2007, Martin Bligh wrote: > >> Those numbers came from Mathieu Desnoyers (LTTng) if you >> want more details. > > Okay the source for these numbers is in his paper for the OLS 2006: Volume > 1 page 208-209? I do not see the exact number that you referred to there. Nope, he was a direct co-author on the paper, was working here, and measured it. > He seems to be comparing spinlock acquire / release vs. cmpxchg. So I > guess you got your material from somewhere else? > > Also the cmpxchg used there is the lockless variant. cmpxchg 29 cycles w/o > lock prefix and 112 with lock prefix. > > I see you reference another paper by Desnoyers: > http://tree.celinuxforum.org/CelfPubWiki/ELC2006Presentations?action=AttachFile&do=get&target=celf2006-desnoyers.pdf > > I do not see anything relevant there. Where did those numbers come from? > > The lockless cmpxchg is certainly an interesting idea. Certain for some > platforms I could disable preempt and then do a lockless cmpxchg. Matheiu, can you give some more details? Obviously the exact numbers will vary by archicture, machine size, etc, but it's a good point for discussion. M. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 21:00 ` Martin Bligh @ 2007-07-09 21:44 ` Mathieu Desnoyers 2007-07-09 21:55 ` Christoph Lameter 0 siblings, 1 reply; 3+ messages in thread From: Mathieu Desnoyers @ 2007-07-09 21:44 UTC (permalink / raw) To: Martin Bligh; +Cc: Christoph Lameter, Andi Kleen, linux-kernel, linux-mm Hi, * Martin Bligh (mbligh@mbligh.org) wrote: > Christoph Lameter wrote: > >On Mon, 9 Jul 2007, Martin Bligh wrote: > > > >>Those numbers came from Mathieu Desnoyers (LTTng) if you > >>want more details. > > > >Okay the source for these numbers is in his paper for the OLS 2006: Volume > >1 page 208-209? I do not see the exact number that you referred to there. > Hrm, the reference page number is wrong: it is in OLS 2006, Vol. 1 page 216 (section 4.5.2 Scalability). I originally pulled out the page number from my local paper copy. oops. > Nope, he was a direct co-author on the paper, was > working here, and measured it. > > >He seems to be comparing spinlock acquire / release vs. cmpxchg. So I > >guess you got your material from somewhere else? > > I ran a test specifically for this paper where I got this result comparing the local irq enable/disable to local cmpxchg. > >Also the cmpxchg used there is the lockless variant. cmpxchg 29 cycles w/o > >lock prefix and 112 with lock prefix. Yep, I volountarily used the variant without lock prefix because the data is per cpu and I disable preemption. > > > >I see you reference another paper by Desnoyers: > >http://tree.celinuxforum.org/CelfPubWiki/ELC2006Presentations?action=AttachFile&do=get&target=celf2006-desnoyers.pdf > > > >I do not see anything relevant there. Where did those numbers come from? > > > >The lockless cmpxchg is certainly an interesting idea. Certain for some > >platforms I could disable preempt and then do a lockless cmpxchg. > Yes, preempt disabling or, eventually, the new thread migration disabling I just proposed as an RFC on LKML. (that would make -rt people happier) > Mathieu, can you give some more details? Obviously the exact numbers > will vary by archicture, machine size, etc, but it's a good point > for discussion. > Sure, also note that the UP cmpxchg (see asm-$ARCH/local.h in 2.6.22) is faster on architectures like powerpc and MIPS where it is possible to remove some memory barriers. See 2.6.22 Documentation/local_ops.txt for a thorough discussion. Don't hesitate ping me if you have more questions. Regards, Mathieu -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 21:44 ` Mathieu Desnoyers @ 2007-07-09 21:55 ` Christoph Lameter 2007-07-09 22:58 ` Mathieu Desnoyers 0 siblings, 1 reply; 3+ messages in thread From: Christoph Lameter @ 2007-07-09 21:55 UTC (permalink / raw) To: Mathieu Desnoyers; +Cc: Martin Bligh, Andi Kleen, linux-kernel, linux-mm On Mon, 9 Jul 2007, Mathieu Desnoyers wrote: > > >Okay the source for these numbers is in his paper for the OLS 2006: Volume > > >1 page 208-209? I do not see the exact number that you referred to there. > > > > Hrm, the reference page number is wrong: it is in OLS 2006, Vol. 1 page > 216 (section 4.5.2 Scalability). I originally pulled out the page number > from my local paper copy. oops. 4.5.2 is on page 208 in my copy of the proceedings. > > >He seems to be comparing spinlock acquire / release vs. cmpxchg. So I > > >guess you got your material from somewhere else? > > > > > I ran a test specifically for this paper where I got this result > comparing the local irq enable/disable to local cmpxchg. The numbers are pretty important and suggest that we can obtain a significant speed increase by avoid local irq disable enable in the slab allocator fast paths. Do you some more numbers? Any other publication that mentions these? > Yep, I volountarily used the variant without lock prefix because the > data is per cpu and I disable preemption. local_cmpxchg generates this? > Yes, preempt disabling or, eventually, the new thread migration > disabling I just proposed as an RFC on LKML. (that would make -rt people > happier) Right. > Sure, also note that the UP cmpxchg (see asm-$ARCH/local.h in 2.6.22) is > faster on architectures like powerpc and MIPS where it is possible to > remove some memory barriers. UP cmpxchg meaning local_cmpxchg? > See 2.6.22 Documentation/local_ops.txt for a thorough discussion. Don't > hesitate ping me if you have more questions. That is pretty thin and does not mention atomic_cmpxchg. You way want to expand on your ideas a bit. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 21:55 ` Christoph Lameter @ 2007-07-09 22:58 ` Mathieu Desnoyers 2007-07-09 23:08 ` Christoph Lameter 0 siblings, 1 reply; 3+ messages in thread From: Mathieu Desnoyers @ 2007-07-09 22:58 UTC (permalink / raw) To: Christoph Lameter; +Cc: Martin Bligh, Andi Kleen, linux-kernel, linux-mm * Christoph Lameter (clameter@sgi.com) wrote: > On Mon, 9 Jul 2007, Mathieu Desnoyers wrote: > > > > >He seems to be comparing spinlock acquire / release vs. cmpxchg. So I > > > >guess you got your material from somewhere else? > > > > > > > > I ran a test specifically for this paper where I got this result > > comparing the local irq enable/disable to local cmpxchg. > > > The numbers are pretty important and suggest that we can obtain > a significant speed increase by avoid local irq disable enable in the slab > allocator fast paths. Do you some more numbers? Any other publication that > mentions these? > The original publication in which I released the idea was my LTTng paper at OLS 2006. Outside this, I have not found other paper that talks about this idea. The test code is basically just disabling interrupts, reading the TSC at the beginning and end and does 20000 loops of local_cmpxchg. I can send you the code if you want it. > > > Yep, I volountarily used the variant without lock prefix because the > > data is per cpu and I disable preemption. > > local_cmpxchg generates this? > Yes. > > Yes, preempt disabling or, eventually, the new thread migration > > disabling I just proposed as an RFC on LKML. (that would make -rt people > > happier) > > Right. > > > Sure, also note that the UP cmpxchg (see asm-$ARCH/local.h in 2.6.22) is > > faster on architectures like powerpc and MIPS where it is possible to > > remove some memory barriers. > > UP cmpxchg meaning local_cmpxchg? > Yes. > > See 2.6.22 Documentation/local_ops.txt for a thorough discussion. Don't > > hesitate ping me if you have more questions. > > That is pretty thin and does not mention atomic_cmpxchg. You way want to > expand on your ideas a bit. Sure, the idea goes as follow: if you have a per cpu variable that needs to be concurrently modified in a coherent manner by any context (NMI, irq, bh, process) running on the given CPU, you only need to use an operation atomic wrt to the given CPU. You just have to make sure that only this CPU will modify the variable (therefore, you must disable preemption around modification) and you have to make sure that the read-side, which can come from any CPU, is accessing this variable atomically. Also, you have to be aware that the read-side might see an older version of the other cpu's value because there is no SMP write memory barrier involved. The value, however, will always be up to date if the variable is read from the "local" CPU. What applies to local_inc, given as example in the local_ops.txt document, applies integrally to local_cmpxchg. And I would say that local_cmpxchg is by far the cheapest locking mechanism I have found, and use today, for my kernel tracer. The idea emerged from my need to trace every execution context, including NMIs, while still providing good performances. local_cmpxchg was the perfect fit; that's why I deployed it in local.h in each and every architecture. Mathieu -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance 2007-07-09 22:58 ` Mathieu Desnoyers @ 2007-07-09 23:08 ` Christoph Lameter 2007-07-10 5:16 ` [PATCH] x86_64 - Use non locked version for local_cmpxchg() Mathieu Desnoyers 0 siblings, 1 reply; 3+ messages in thread From: Christoph Lameter @ 2007-07-09 23:08 UTC (permalink / raw) To: Mathieu Desnoyers; +Cc: Martin Bligh, Andi Kleen, linux-kernel, linux-mm On Mon, 9 Jul 2007, Mathieu Desnoyers wrote: > > > Yep, I volountarily used the variant without lock prefix because the > > > data is per cpu and I disable preemption. > > > > local_cmpxchg generates this? > > > > Yes. Does not work here. If I use static void __always_inline *slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, void *addr) { void **object; struct kmem_cache_cpu *c; preempt_disable(); c = get_cpu_slab(s, smp_processor_id()); redo: object = c->freelist; if (unlikely(!object || !node_match(c, node))) return __slab_alloc(s, gfpflags, node, addr, c); if (cmpxchg_local(&c->freelist, object, object[c->offset]) != object) goto redo; preempt_enable(); if (unlikely((gfpflags & __GFP_ZERO))) memset(object, 0, c->objsize); return object; } Then the code will include a lock prefix: 3270: 48 8b 1a mov (%rdx),%rbx 3273: 48 85 db test %rbx,%rbx 3276: 74 23 je 329b <kmem_cache_alloc+0x4b> 3278: 8b 42 14 mov 0x14(%rdx),%eax 327b: 4c 8b 0c c3 mov (%rbx,%rax,8),%r9 327f: 48 89 d8 mov %rbx,%rax 3282: f0 4c 0f b1 0a lock cmpxchg %r9,(%rdx) 3287: 48 39 c3 cmp %rax,%rbx 328a: 75 e4 jne 3270 <kmem_cache_alloc+0x20> 328c: 66 85 f6 test %si,%si 328f: 78 19 js 32aa <kmem_cache_alloc+0x5a> 3291: 48 89 d8 mov %rbx,%rax 3294: 48 83 c4 08 add $0x8,%rsp 3298: 5b pop %rbx 3299: c9 leaveq 329a: c3 retq > What applies to local_inc, given as example in the local_ops.txt > document, applies integrally to local_cmpxchg. And I would say that > local_cmpxchg is by far the cheapest locking mechanism I have found, and > use today, for my kernel tracer. The idea emerged from my need to trace > every execution context, including NMIs, while still providing good > performances. local_cmpxchg was the perfect fit; that's why I deployed > it in local.h in each and every architecture. Great idea. The SLUB allocator may be able to use your idea to improve both the alloc and free path. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] x86_64 - Use non locked version for local_cmpxchg() 2007-07-09 23:08 ` Christoph Lameter @ 2007-07-10 5:16 ` Mathieu Desnoyers 2007-07-10 20:46 ` Christoph Lameter 0 siblings, 1 reply; 3+ messages in thread From: Mathieu Desnoyers @ 2007-07-10 5:16 UTC (permalink / raw) To: akpm; +Cc: Martin Bligh, Andi Kleen, linux-kernel, linux-mm You are completely right: on x86_64, a bit got lost in the move to cmpxchg.h, here is the fix. It applies on 2.6.22-rc6-mm1. x86_64 - Use non locked version for local_cmpxchg() local_cmpxchg() should not use any LOCK prefix. This change probably got lost in the move to cmpxchg.h. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> --- include/asm-x86_64/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-2.6-lttng/include/asm-x86_64/cmpxchg.h =================================================================== --- linux-2.6-lttng.orig/include/asm-x86_64/cmpxchg.h 2007-07-10 01:10:10.000000000 -0400 +++ linux-2.6-lttng/include/asm-x86_64/cmpxchg.h 2007-07-10 01:11:03.000000000 -0400 @@ -128,7 +128,7 @@ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) #define cmpxchg_local(ptr,o,n)\ - ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ + ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) #endif * Christoph Lameter (clameter@sgi.com) wrote: > On Mon, 9 Jul 2007, Mathieu Desnoyers wrote: > > > > > Yep, I volountarily used the variant without lock prefix because the > > > > data is per cpu and I disable preemption. > > > > > > local_cmpxchg generates this? > > > > > > > Yes. > > Does not work here. If I use > > static void __always_inline *slab_alloc(struct kmem_cache *s, > gfp_t gfpflags, int node, void *addr) > { > void **object; > struct kmem_cache_cpu *c; > > preempt_disable(); > c = get_cpu_slab(s, smp_processor_id()); > redo: > object = c->freelist; > if (unlikely(!object || !node_match(c, node))) > return __slab_alloc(s, gfpflags, node, addr, c); > > if (cmpxchg_local(&c->freelist, object, object[c->offset]) != object) > goto redo; > > preempt_enable(); > if (unlikely((gfpflags & __GFP_ZERO))) > memset(object, 0, c->objsize); > > return object; > } > > Then the code will include a lock prefix: > > 3270: 48 8b 1a mov (%rdx),%rbx > 3273: 48 85 db test %rbx,%rbx > 3276: 74 23 je 329b <kmem_cache_alloc+0x4b> > 3278: 8b 42 14 mov 0x14(%rdx),%eax > 327b: 4c 8b 0c c3 mov (%rbx,%rax,8),%r9 > 327f: 48 89 d8 mov %rbx,%rax > 3282: f0 4c 0f b1 0a lock cmpxchg %r9,(%rdx) > 3287: 48 39 c3 cmp %rax,%rbx > 328a: 75 e4 jne 3270 <kmem_cache_alloc+0x20> > 328c: 66 85 f6 test %si,%si > 328f: 78 19 js 32aa <kmem_cache_alloc+0x5a> > 3291: 48 89 d8 mov %rbx,%rax > 3294: 48 83 c4 08 add $0x8,%rsp > 3298: 5b pop %rbx > 3299: c9 leaveq > 329a: c3 retq > > > > What applies to local_inc, given as example in the local_ops.txt > > document, applies integrally to local_cmpxchg. And I would say that > > local_cmpxchg is by far the cheapest locking mechanism I have found, and > > use today, for my kernel tracer. The idea emerged from my need to trace > > every execution context, including NMIs, while still providing good > > performances. local_cmpxchg was the perfect fit; that's why I deployed > > it in local.h in each and every architecture. > > Great idea. The SLUB allocator may be able to use your idea to improve > both the alloc and free path. > -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86_64 - Use non locked version for local_cmpxchg() 2007-07-10 5:16 ` [PATCH] x86_64 - Use non locked version for local_cmpxchg() Mathieu Desnoyers @ 2007-07-10 20:46 ` Christoph Lameter 0 siblings, 0 replies; 3+ messages in thread From: Christoph Lameter @ 2007-07-10 20:46 UTC (permalink / raw) To: Mathieu Desnoyers; +Cc: akpm, Martin Bligh, Andi Kleen, linux-kernel, linux-mm On Tue, 10 Jul 2007, Mathieu Desnoyers wrote: > You are completely right: on x86_64, a bit got lost in the move to > cmpxchg.h, here is the fix. It applies on 2.6.22-rc6-mm1. A trival fix. Make sure that it gets merged soon. Acked-by: Christoph Lameter <clameter@sgi.com> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-14 1:19 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-07-14 1:19 [PATCH] x86_64 - Use non locked version for local_cmpxchg() Mathieu Desnoyers -- strict thread matches above, loose matches on Subject: below -- 2007-07-08 3:49 [patch 00/10] [RFC] SLUB patches for more functionality, performance and maintenance Christoph Lameter 2007-07-08 11:20 ` Andi Kleen 2007-07-09 15:50 ` Christoph Lameter 2007-07-09 15:59 ` Martin Bligh 2007-07-09 18:11 ` Christoph Lameter 2007-07-09 21:00 ` Martin Bligh 2007-07-09 21:44 ` Mathieu Desnoyers 2007-07-09 21:55 ` Christoph Lameter 2007-07-09 22:58 ` Mathieu Desnoyers 2007-07-09 23:08 ` Christoph Lameter 2007-07-10 5:16 ` [PATCH] x86_64 - Use non locked version for local_cmpxchg() Mathieu Desnoyers 2007-07-10 20:46 ` Christoph Lameter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®