* [PATCH] mm: percpu: micro-optimize round-to-even
@ 2014-06-19 10:02 Rasmus Villemoes
2014-06-19 13:25 ` Tejun Heo
0 siblings, 1 reply; 7+ messages in thread
From: Rasmus Villemoes @ 2014-06-19 10:02 UTC (permalink / raw)
To: Tejun Heo, Christoph Lameter; +Cc: linux-mm, linux-kernel, Rasmus Villemoes
This change shaves a few bytes off the generated code.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
mm/percpu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index 2ddf9a9..978097f 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -720,8 +720,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
if (unlikely(align < 2))
align = 2;
- if (unlikely(size & 1))
- size++;
+ size += size & 1;
if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) {
WARN(true, "illegal size (%zu) or align (%zu) for "
--
1.9.2
--
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>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 10:02 [PATCH] mm: percpu: micro-optimize round-to-even Rasmus Villemoes
@ 2014-06-19 13:25 ` Tejun Heo
2014-06-19 13:27 ` Tejun Heo
2014-06-19 14:29 ` Christoph Lameter
0 siblings, 2 replies; 7+ messages in thread
From: Tejun Heo @ 2014-06-19 13:25 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Christoph Lameter, linux-mm, linux-kernel
On Thu, Jun 19, 2014 at 12:02:29PM +0200, Rasmus Villemoes wrote:
> This change shaves a few bytes off the generated code.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> mm/percpu.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 2ddf9a9..978097f 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -720,8 +720,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
> if (unlikely(align < 2))
> align = 2;
>
> - if (unlikely(size & 1))
> - size++;
> + size += size & 1;
I'm not gonna apply this. This isn't that hot a path. It's not
worthwhile to micro optimize code like this.
Thanks.
--
tejun
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 13:25 ` Tejun Heo
@ 2014-06-19 13:27 ` Tejun Heo
2014-06-19 14:29 ` Christoph Lameter
1 sibling, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2014-06-19 13:27 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Christoph Lameter, linux-mm, linux-kernel
On Thu, Jun 19, 2014 at 09:25:36AM -0400, Tejun Heo wrote:
> On Thu, Jun 19, 2014 at 12:02:29PM +0200, Rasmus Villemoes wrote:
> > This change shaves a few bytes off the generated code.
> >
> > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > ---
> > mm/percpu.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/mm/percpu.c b/mm/percpu.c
> > index 2ddf9a9..978097f 100644
> > --- a/mm/percpu.c
> > +++ b/mm/percpu.c
> > @@ -720,8 +720,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
> > if (unlikely(align < 2))
> > align = 2;
> >
> > - if (unlikely(size & 1))
> > - size++;
> > + size += size & 1;
>
> I'm not gonna apply this. This isn't that hot a path. It's not
> worthwhile to micro optimize code like this.
Another thing is that it isn't even clear whether the micro
optimization is even actually better given that predicted branches are
extremely cheap and this one is extremely predictable. So, again,
let's please leave it to the compiler.
Thanks.
--
tejun
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 13:25 ` Tejun Heo
2014-06-19 13:27 ` Tejun Heo
@ 2014-06-19 14:29 ` Christoph Lameter
2014-06-19 14:34 ` Tejun Heo
1 sibling, 1 reply; 7+ messages in thread
From: Christoph Lameter @ 2014-06-19 14:29 UTC (permalink / raw)
To: Tejun Heo; +Cc: Rasmus Villemoes, linux-mm, linux-kernel
On Thu, 19 Jun 2014, Tejun Heo wrote:
> On Thu, Jun 19, 2014 at 12:02:29PM +0200, Rasmus Villemoes wrote:
> > This change shaves a few bytes off the generated code.
> >
> > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > ---
> > mm/percpu.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/mm/percpu.c b/mm/percpu.c
> > index 2ddf9a9..978097f 100644
> > --- a/mm/percpu.c
> > +++ b/mm/percpu.c
> > @@ -720,8 +720,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
> > if (unlikely(align < 2))
> > align = 2;
> >
> > - if (unlikely(size & 1))
> > - size++;
> > + size += size & 1;
>
> I'm not gonna apply this. This isn't that hot a path. It's not
> worthwhile to micro optimize code like this.
Dont we have an ALIGN() macro for this?
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 14:29 ` Christoph Lameter
@ 2014-06-19 14:34 ` Tejun Heo
2014-06-19 14:59 ` Christoph Lameter
0 siblings, 1 reply; 7+ messages in thread
From: Tejun Heo @ 2014-06-19 14:34 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Rasmus Villemoes, linux-mm, linux-kernel
On Thu, Jun 19, 2014 at 09:29:52AM -0500, Christoph Lameter wrote:
> > > - if (unlikely(size & 1))
> > > - size++;
> > > + size += size & 1;
> >
> > I'm not gonna apply this. This isn't that hot a path. It's not
> > worthwhile to micro optimize code like this.
>
> Dont we have an ALIGN() macro for this?
Indeed, a patch?
--
tejun
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 14:34 ` Tejun Heo
@ 2014-06-19 14:59 ` Christoph Lameter
2014-06-19 15:01 ` Tejun Heo
0 siblings, 1 reply; 7+ messages in thread
From: Christoph Lameter @ 2014-06-19 14:59 UTC (permalink / raw)
To: Tejun Heo; +Cc: Rasmus Villemoes, linux-mm, linux-kernel
On Thu, 19 Jun 2014, Tejun Heo wrote:
> Indeed, a patch?
Subject: percpu: Use ALIGN macro instead of hand coding alignment calculation
Signed-off-by: Christoph Lameter <cl@linux.com>
Index: linux/mm/percpu.c
===================================================================
--- linux.orig/mm/percpu.c 2014-06-04 13:43:12.541466633 -0500
+++ linux/mm/percpu.c 2014-06-19 09:56:10.458023912 -0500
@@ -720,8 +720,7 @@ static void __percpu *pcpu_alloc(size_t
if (unlikely(align < 2))
align = 2;
- if (unlikely(size & 1))
- size++;
+ size = ALIGN(size, 2);
if (unlikely(!size || size > PCPU_MIN_UNIT_SIZE || align > PAGE_SIZE)) {
WARN(true, "illegal size (%zu) or align (%zu) for "
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm: percpu: micro-optimize round-to-even
2014-06-19 14:59 ` Christoph Lameter
@ 2014-06-19 15:01 ` Tejun Heo
0 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2014-06-19 15:01 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Rasmus Villemoes, linux-mm, linux-kernel
On Thu, Jun 19, 2014 at 09:59:18AM -0500, Christoph Lameter wrote:
> On Thu, 19 Jun 2014, Tejun Heo wrote:
>
> > Indeed, a patch?
>
> Subject: percpu: Use ALIGN macro instead of hand coding alignment calculation
>
> Signed-off-by: Christoph Lameter <cl@linux.com>
Applied to percpu/for-3.17. Thanks.
--
tejun
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-06-19 15:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 10:02 [PATCH] mm: percpu: micro-optimize round-to-even Rasmus Villemoes
2014-06-19 13:25 ` Tejun Heo
2014-06-19 13:27 ` Tejun Heo
2014-06-19 14:29 ` Christoph Lameter
2014-06-19 14:34 ` Tejun Heo
2014-06-19 14:59 ` Christoph Lameter
2014-06-19 15:01 ` Tejun Heo
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).