* [RFC/PATCH] SLUB: Optimize slab_free() debug check
@ 2010-10-02 8:40 Pekka Enberg
2010-10-03 1:03 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Pekka Enberg @ 2010-10-02 8:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Pekka Enberg, Christoph Lameter, David Rientjes
This patch optimizes slab_free() debug check to use "c->node != NUMA_NO_NODE"
instead of "c->node >= 0" because the former generates smaller code on x86-64:
Before:
4736: 48 39 70 08 cmp %rsi,0x8(%rax)
473a: 75 26 jne 4762 <kfree+0xa2>
473c: 44 8b 48 10 mov 0x10(%rax),%r9d
4740: 45 85 c9 test %r9d,%r9d
4743: 78 1d js 4762 <kfree+0xa2>
After:
4736: 48 39 70 08 cmp %rsi,0x8(%rax)
473a: 75 23 jne 475f <kfree+0x9f>
473c: 83 78 10 ff cmpl $0xffffffffffffffff,0x10(%rax)
4740: 74 1d je 475f <kfree+0x9f>
This patch also cleans up __slab_alloc() to use NUMA_NO_NODE instead of "-1"
for enabling debugging for a per-CPU cache.
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
mm/slub.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 9f121c1..a018019 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1718,7 +1718,7 @@ debug:
c->page->inuse++;
c->page->freelist = get_freepointer(s, object);
- c->node = -1;
+ c->node = NUMA_NO_NODE;
goto unlock_out;
}
@@ -1895,7 +1895,7 @@ static __always_inline void slab_free(struct kmem_cache *s,
slab_free_hook_irq(s, x);
- if (likely(page == c->page && c->node >= 0)) {
+ if (likely(page == c->page && c->node != NUMA_NO_NODE)) {
set_freepointer(s, object, c->freelist);
c->freelist = object;
stat(s, FREE_FASTPATH);
--
1.6.3.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC/PATCH] SLUB: Optimize slab_free() debug check
2010-10-02 8:40 [RFC/PATCH] SLUB: Optimize slab_free() debug check Pekka Enberg
@ 2010-10-03 1:03 ` David Rientjes
2010-10-04 1:43 ` Christoph Lameter
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2010-10-03 1:03 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-kernel, Christoph Lameter
On Sat, 2 Oct 2010, Pekka Enberg wrote:
> This patch optimizes slab_free() debug check to use "c->node != NUMA_NO_NODE"
> instead of "c->node >= 0" because the former generates smaller code on x86-64:
>
> Before:
>
> 4736: 48 39 70 08 cmp %rsi,0x8(%rax)
> 473a: 75 26 jne 4762 <kfree+0xa2>
> 473c: 44 8b 48 10 mov 0x10(%rax),%r9d
> 4740: 45 85 c9 test %r9d,%r9d
> 4743: 78 1d js 4762 <kfree+0xa2>
>
> After:
>
> 4736: 48 39 70 08 cmp %rsi,0x8(%rax)
> 473a: 75 23 jne 475f <kfree+0x9f>
> 473c: 83 78 10 ff cmpl $0xffffffffffffffff,0x10(%rax)
> 4740: 74 1d je 475f <kfree+0x9f>
>
> This patch also cleans up __slab_alloc() to use NUMA_NO_NODE instead of "-1"
> for enabling debugging for a per-CPU cache.
>
> Cc: Christoph Lameter <cl@linux.com>
> Cc: David Rientjes <rientjes@google.com>
> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Acked-by: David Rientjes <rientjes@google.com>
You could compare to NUMA_NO_NODE in show_slab_objects(), as well, for the
same optimization.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC/PATCH] SLUB: Optimize slab_free() debug check
2010-10-03 1:03 ` David Rientjes
@ 2010-10-04 1:43 ` Christoph Lameter
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Lameter @ 2010-10-04 1:43 UTC (permalink / raw)
To: David Rientjes; +Cc: Pekka Enberg, linux-kernel
Acked-by: Christoph Lameter <cl@linux.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-04 1:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-02 8:40 [RFC/PATCH] SLUB: Optimize slab_free() debug check Pekka Enberg
2010-10-03 1:03 ` David Rientjes
2010-10-04 1:43 ` 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®