From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>,
akpm <akpm@linuxfoundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
iamjoonsoo@lge.com, brouer@redhat.com
Subject: Re: [PATCH 3/7] slub: Do not use c->page on free
Date: Thu, 11 Dec 2014 14:19:38 +0100 [thread overview]
Message-ID: <20141211141938.6420b94a@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1412101136520.6639@gentwo.org>
On Wed, 10 Dec 2014 11:37:56 -0600 (CST) Christoph Lameter <cl@linux.com> wrote:
[...]
>
> There were some other issues so its now:
>
>
> Subject: slub: Do not use c->page on free
>
> Avoid using the page struct address on free by just doing an
> address comparison. That is easily doable now that the page address
> is available in the page struct and we already have the page struct
> address of the object to be freed calculated.
>
> Reviewed-by: Pekka Enberg <penberg@kernel.org>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> Index: linux/mm/slub.c
> ===================================================================
> --- linux.orig/mm/slub.c 2014-12-10 11:35:32.538563734 -0600
> +++ linux/mm/slub.c 2014-12-10 11:36:39.032447807 -0600
> @@ -2625,6 +2625,17 @@ slab_empty:
> discard_slab(s, page);
> }
>
> +static bool is_pointer_to_page(struct page *page, void *p)
> +{
> + long d = p - page->address;
> +
> + /*
> + * Do a comparison for a MAX_ORDER page first before using
> + * compound_order() to determine the actual page size.
> + */
> + return d >= 0 && d < (1 << MAX_ORDER) && d < (compound_order(page) << PAGE_SHIFT);
> +}
My current compiler (gcc 4.9.1), choose not to inline is_pointer_to_page().
(perf record of [1])
Samples: 8K of event 'cycles', Event count (approx.): 5737618489
+ 46.13% modprobe [kernel.kallsyms] [k] kmem_cache_free
+ 33.02% modprobe [kernel.kallsyms] [k] kmem_cache_alloc
+ 16.14% modprobe [kernel.kallsyms] [k] is_pointer_to_page
If I explicitly add "inline", then it gets inlined, and performance is good again.
Test[1] cost of kmem_cache_alloc+free:
* baseline: 47 cycles(tsc) 19.032 ns (net-next without patchset)
* patchset: 50 cycles(tsc) 20.028 ns
* inline : 45 cycles(tsc) 18.135 ns (inlined is_pointer_to_page())
> /*
> * Fastpath with forced inlining to produce a kfree and kmem_cache_free that
> * can perform fastpath freeing without additional function calls.
> @@ -2658,7 +2669,7 @@ redo:
> tid = c->tid;
> preempt_enable();
>
> - if (likely(page == c->page)) {
> + if (likely(is_pointer_to_page(page, c->freelist))) {
> set_freepointer(s, object, c->freelist);
>
> if (unlikely(!this_cpu_cmpxchg_double(
[1] https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/lib/time_bench_kmem_cache1.c
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>,
akpm <akpm@linuxfoundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
iamjoonsoo@lge.com, brouer@redhat.com
Subject: Re: [PATCH 3/7] slub: Do not use c->page on free
Date: Thu, 11 Dec 2014 14:19:38 +0100 [thread overview]
Message-ID: <20141211141938.6420b94a@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1412101136520.6639@gentwo.org>
On Wed, 10 Dec 2014 11:37:56 -0600 (CST) Christoph Lameter <cl@linux.com> wrote:
[...]
>
> There were some other issues so its now:
>
>
> Subject: slub: Do not use c->page on free
>
> Avoid using the page struct address on free by just doing an
> address comparison. That is easily doable now that the page address
> is available in the page struct and we already have the page struct
> address of the object to be freed calculated.
>
> Reviewed-by: Pekka Enberg <penberg@kernel.org>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> Index: linux/mm/slub.c
> ===================================================================
> --- linux.orig/mm/slub.c 2014-12-10 11:35:32.538563734 -0600
> +++ linux/mm/slub.c 2014-12-10 11:36:39.032447807 -0600
> @@ -2625,6 +2625,17 @@ slab_empty:
> discard_slab(s, page);
> }
>
> +static bool is_pointer_to_page(struct page *page, void *p)
> +{
> + long d = p - page->address;
> +
> + /*
> + * Do a comparison for a MAX_ORDER page first before using
> + * compound_order() to determine the actual page size.
> + */
> + return d >= 0 && d < (1 << MAX_ORDER) && d < (compound_order(page) << PAGE_SHIFT);
> +}
My current compiler (gcc 4.9.1), choose not to inline is_pointer_to_page().
(perf record of [1])
Samples: 8K of event 'cycles', Event count (approx.): 5737618489
+ 46.13% modprobe [kernel.kallsyms] [k] kmem_cache_free
+ 33.02% modprobe [kernel.kallsyms] [k] kmem_cache_alloc
+ 16.14% modprobe [kernel.kallsyms] [k] is_pointer_to_page
If I explicitly add "inline", then it gets inlined, and performance is good again.
Test[1] cost of kmem_cache_alloc+free:
* baseline: 47 cycles(tsc) 19.032 ns (net-next without patchset)
* patchset: 50 cycles(tsc) 20.028 ns
* inline : 45 cycles(tsc) 18.135 ns (inlined is_pointer_to_page())
> /*
> * Fastpath with forced inlining to produce a kfree and kmem_cache_free that
> * can perform fastpath freeing without additional function calls.
> @@ -2658,7 +2669,7 @@ redo:
> tid = c->tid;
> preempt_enable();
>
> - if (likely(page == c->page)) {
> + if (likely(is_pointer_to_page(page, c->freelist))) {
> set_freepointer(s, object, c->freelist);
>
> if (unlikely(!this_cpu_cmpxchg_double(
[1] https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/lib/time_bench_kmem_cache1.c
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2014-12-11 13:19 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 16:30 [PATCH 0/7] slub: Fastpath optimization (especially for RT) V1 Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:30 ` [PATCH 1/7] slub: Remove __slab_alloc code duplication Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:39 ` Pekka Enberg
2014-12-10 16:39 ` Pekka Enberg
2014-12-10 16:30 ` [PATCH 2/7] slub: Use page-mapping to store address of page frame like done in SLAB Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:45 ` Pekka Enberg
2014-12-10 16:45 ` Pekka Enberg
2014-12-10 16:30 ` [PATCH 3/7] slub: Do not use c->page on free Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:54 ` Pekka Enberg
2014-12-10 16:54 ` Pekka Enberg
2014-12-10 17:08 ` Christoph Lameter
2014-12-10 17:08 ` Christoph Lameter
2014-12-10 17:32 ` Pekka Enberg
2014-12-10 17:32 ` Pekka Enberg
2014-12-10 17:37 ` Christoph Lameter
2014-12-10 17:37 ` Christoph Lameter
2014-12-11 13:19 ` Jesper Dangaard Brouer [this message]
2014-12-11 13:19 ` Jesper Dangaard Brouer
2014-12-11 15:01 ` Christoph Lameter
2014-12-11 15:01 ` Christoph Lameter
2014-12-15 8:03 ` Joonsoo Kim
2014-12-15 8:03 ` Joonsoo Kim
2014-12-15 14:16 ` Christoph Lameter
2014-12-15 14:16 ` Christoph Lameter
2014-12-16 2:42 ` Joonsoo Kim
2014-12-16 2:42 ` Joonsoo Kim
2014-12-16 7:54 ` Andrey Ryabinin
2014-12-16 7:54 ` Andrey Ryabinin
2014-12-16 8:25 ` Joonsoo Kim
2014-12-16 8:25 ` Joonsoo Kim
2014-12-16 14:53 ` Christoph Lameter
2014-12-16 14:53 ` Christoph Lameter
2014-12-16 15:15 ` Jesper Dangaard Brouer
2014-12-16 15:15 ` Jesper Dangaard Brouer
2014-12-16 15:34 ` Andrey Ryabinin
2014-12-16 15:34 ` Andrey Ryabinin
2014-12-16 15:48 ` Christoph Lameter
2014-12-16 15:48 ` Christoph Lameter
2014-12-17 7:15 ` Joonsoo Kim
2014-12-17 7:15 ` Joonsoo Kim
2014-12-16 15:33 ` Andrey Ryabinin
2014-12-16 15:33 ` Andrey Ryabinin
2014-12-16 14:05 ` Jesper Dangaard Brouer
2014-12-16 14:05 ` Jesper Dangaard Brouer
2014-12-10 16:30 ` [PATCH 4/7] slub: Avoid using the page struct address in allocation fastpath Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:56 ` Pekka Enberg
2014-12-10 16:56 ` Pekka Enberg
2014-12-10 16:30 ` [PATCH 5/7] slub: Use end_token instead of NULL to terminate freelists Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 16:59 ` Pekka Enberg
2014-12-10 16:59 ` Pekka Enberg
2014-12-10 16:30 ` [PATCH 6/7] slub: Drop ->page field from kmem_cache_cpu Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-10 17:29 ` Pekka Enberg
2014-12-10 17:29 ` Pekka Enberg
2014-12-10 16:30 ` [PATCH 7/7] slub: Remove preemption disable/enable from fastpath Christoph Lameter
2014-12-10 16:30 ` Christoph Lameter
2014-12-11 13:35 ` [PATCH 0/7] slub: Fastpath optimization (especially for RT) V1 Jesper Dangaard Brouer
2014-12-11 13:35 ` Jesper Dangaard Brouer
2014-12-11 15:03 ` Christoph Lameter
2014-12-11 15:03 ` Christoph Lameter
2014-12-11 16:50 ` Jesper Dangaard Brouer
2014-12-11 16:50 ` Jesper Dangaard Brouer
2014-12-11 17:18 ` Christoph Lameter
2014-12-11 17:18 ` Christoph Lameter
2014-12-11 18:11 ` Jesper Dangaard Brouer
2014-12-11 18:11 ` Jesper Dangaard Brouer
2014-12-11 17:37 ` Jesper Dangaard Brouer
2014-12-11 17:37 ` Jesper Dangaard Brouer
2014-12-12 10:39 ` Jesper Dangaard Brouer
2014-12-12 10:39 ` Jesper Dangaard Brouer
2014-12-12 18:31 ` Christoph Lameter
2014-12-12 18:31 ` Christoph Lameter
2014-12-15 7:59 ` Joonsoo Kim
2014-12-15 7:59 ` Joonsoo Kim
2014-12-17 7:13 ` Joonsoo Kim
2014-12-17 7:13 ` Joonsoo Kim
2014-12-17 12:08 ` Jesper Dangaard Brouer
2014-12-17 12:08 ` Jesper Dangaard Brouer
2014-12-18 14:34 ` Joonsoo Kim
2014-12-18 14:34 ` Joonsoo Kim
2014-12-17 15:36 ` Christoph Lameter
2014-12-17 15:36 ` Christoph Lameter
2014-12-18 14:38 ` Joonsoo Kim
2014-12-18 14:38 ` Joonsoo Kim
2014-12-18 14:57 ` Christoph Lameter
2014-12-18 14:57 ` Christoph Lameter
2014-12-18 15:08 ` Joonsoo Kim
2014-12-18 15:08 ` Joonsoo Kim
2014-12-17 16:10 ` Christoph Lameter
2014-12-17 16:10 ` Christoph Lameter
2014-12-17 19:44 ` Christoph Lameter
2014-12-17 19:44 ` Christoph Lameter
2014-12-18 14:41 ` Joonsoo Kim
2014-12-18 14:41 ` Joonsoo Kim
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=20141211141938.6420b94a@redhat.com \
--to=brouer@redhat.com \
--cc=akpm@linuxfoundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.