linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
@ 2014-01-06 20:43 Dave Hansen
  2014-01-07  2:44 ` Christoph Lameter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dave Hansen @ 2014-01-06 20:43 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, cl, akpm, penberg, Dave Hansen


From: Dave Hansen <dave.hansen@linux.intel.com>

There used to be only one path out of __slab_alloc(), and
ALLOC_SLOWPATH got bumped in that exit path.  Now there are two,
and a bunch of gotos.  ALLOC_SLOWPATH can now get set more than once
during a single call to __slab_alloc() which is pretty bogus.
Here's the sequence:

1. Enter __slab_alloc(), fall through all the way to the
   stat(s, ALLOC_SLOWPATH);
2. hit 'if (!freelist)', and bump DEACTIVATE_BYPASS, jump to
   new_slab (goto #1)
3. Hit 'if (c->partial)', bump CPU_PARTIAL_ALLOC, goto redo
   (goto #2)
4. Fall through in the same path we did before all the way to
   stat(s, ALLOC_SLOWPATH)
5. bump ALLOC_REFILL stat, then return

Doing this is obviously bogus.  It keeps us from being able to
accurately compare ALLOC_SLOWPATH vs. ALLOC_FASTPATH.  It also
means that the total number of allocs always exceeds the total
number of frees.

This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
same place that __slab_alloc() is.  This makes it much less
likely that ALLOC_SLOWPATH will get botched again in the
spaghetti-code inside __slab_alloc().

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
---

 linux.git-davehans/mm/slub.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff -puN mm/slub.c~slub-ALLOC_SLOWPATH-stat mm/slub.c
--- linux.git/mm/slub.c~slub-ALLOC_SLOWPATH-stat	2014-01-06 12:39:28.148072544 -0800
+++ linux.git-davehans/mm/slub.c	2014-01-06 12:39:28.155072860 -0800
@@ -2301,8 +2301,6 @@ redo:
 	if (freelist)
 		goto load_freelist;
 
-	stat(s, ALLOC_SLOWPATH);
-
 	freelist = get_freelist(s, page);
 
 	if (!freelist) {
@@ -2409,10 +2407,10 @@ redo:
 
 	object = c->freelist;
 	page = c->page;
-	if (unlikely(!object || !node_match(page, node)))
+	if (unlikely(!object || !node_match(page, node))) {
 		object = __slab_alloc(s, gfpflags, node, addr, c);
-
-	else {
+		stat(s, ALLOC_SLOWPATH);
+	} else {
 		void *next_object = get_freepointer_safe(s, object);
 
 		/*
_

--
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] 6+ messages in thread

* Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
  2014-01-06 20:43 [PATCH] mm: slub: fix ALLOC_SLOWPATH stat Dave Hansen
@ 2014-01-07  2:44 ` Christoph Lameter
  2014-01-07  4:44 ` Wanpeng Li
  2014-01-09  2:24 ` David Rientjes
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2014-01-07  2:44 UTC (permalink / raw)
  To: Dave Hansen; +Cc: linux-mm, linux-kernel, akpm, penberg

On Mon, 6 Jan 2014, Dave Hansen wrote:

> This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
> same place that __slab_alloc() is.  This makes it much less
> likely that ALLOC_SLOWPATH will get botched again in the
> spaghetti-code inside __slab_alloc().


Acked-by: Christoph Lameter <cl@linux.com>

--
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] 6+ messages in thread

* Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
  2014-01-06 20:43 [PATCH] mm: slub: fix ALLOC_SLOWPATH stat Dave Hansen
  2014-01-07  2:44 ` Christoph Lameter
@ 2014-01-07  4:44 ` Wanpeng Li
  2014-01-09  2:24 ` David Rientjes
  2 siblings, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2014-01-07  4:44 UTC (permalink / raw)
  To: Dave Hansen; +Cc: linux-mm, linux-kernel, cl, akpm, penberg

On Mon, Jan 06, 2014 at 12:43:00PM -0800, Dave Hansen wrote:
>
>From: Dave Hansen <dave.hansen@linux.intel.com>
>
>There used to be only one path out of __slab_alloc(), and
>ALLOC_SLOWPATH got bumped in that exit path.  Now there are two,
>and a bunch of gotos.  ALLOC_SLOWPATH can now get set more than once
>during a single call to __slab_alloc() which is pretty bogus.
>Here's the sequence:
>
>1. Enter __slab_alloc(), fall through all the way to the
>   stat(s, ALLOC_SLOWPATH);
>2. hit 'if (!freelist)', and bump DEACTIVATE_BYPASS, jump to
>   new_slab (goto #1)
>3. Hit 'if (c->partial)', bump CPU_PARTIAL_ALLOC, goto redo
>   (goto #2)
>4. Fall through in the same path we did before all the way to
>   stat(s, ALLOC_SLOWPATH)
>5. bump ALLOC_REFILL stat, then return
>
>Doing this is obviously bogus.  It keeps us from being able to
>accurately compare ALLOC_SLOWPATH vs. ALLOC_FASTPATH.  It also
>means that the total number of allocs always exceeds the total
>number of frees.
>
>This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
>same place that __slab_alloc() is.  This makes it much less
>likely that ALLOC_SLOWPATH will get botched again in the
>spaghetti-code inside __slab_alloc().
>
>Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>

Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>

>---
>
> linux.git-davehans/mm/slub.c |    8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
>diff -puN mm/slub.c~slub-ALLOC_SLOWPATH-stat mm/slub.c
>--- linux.git/mm/slub.c~slub-ALLOC_SLOWPATH-stat	2014-01-06 12:39:28.148072544 -0800
>+++ linux.git-davehans/mm/slub.c	2014-01-06 12:39:28.155072860 -0800
>@@ -2301,8 +2301,6 @@ redo:
> 	if (freelist)
> 		goto load_freelist;
>
>-	stat(s, ALLOC_SLOWPATH);
>-
> 	freelist = get_freelist(s, page);
>
> 	if (!freelist) {
>@@ -2409,10 +2407,10 @@ redo:
>
> 	object = c->freelist;
> 	page = c->page;
>-	if (unlikely(!object || !node_match(page, node)))
>+	if (unlikely(!object || !node_match(page, node))) {
> 		object = __slab_alloc(s, gfpflags, node, addr, c);
>-
>-	else {
>+		stat(s, ALLOC_SLOWPATH);
>+	} else {
> 		void *next_object = get_freepointer_safe(s, object);
>
> 		/*
>_
>
>--
>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>

--
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] 6+ messages in thread

* Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
  2014-01-06 20:43 [PATCH] mm: slub: fix ALLOC_SLOWPATH stat Dave Hansen
  2014-01-07  2:44 ` Christoph Lameter
  2014-01-07  4:44 ` Wanpeng Li
@ 2014-01-09  2:24 ` David Rientjes
  2014-01-21 22:14   ` David Rientjes
  2 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2014-01-09  2:24 UTC (permalink / raw)
  To: Dave Hansen; +Cc: linux-mm, linux-kernel, cl, akpm, penberg

On Mon, 6 Jan 2014, Dave Hansen wrote:

> There used to be only one path out of __slab_alloc(), and
> ALLOC_SLOWPATH got bumped in that exit path.  Now there are two,
> and a bunch of gotos.  ALLOC_SLOWPATH can now get set more than once
> during a single call to __slab_alloc() which is pretty bogus.
> Here's the sequence:
> 
> 1. Enter __slab_alloc(), fall through all the way to the
>    stat(s, ALLOC_SLOWPATH);
> 2. hit 'if (!freelist)', and bump DEACTIVATE_BYPASS, jump to
>    new_slab (goto #1)
> 3. Hit 'if (c->partial)', bump CPU_PARTIAL_ALLOC, goto redo
>    (goto #2)
> 4. Fall through in the same path we did before all the way to
>    stat(s, ALLOC_SLOWPATH)
> 5. bump ALLOC_REFILL stat, then return
> 
> Doing this is obviously bogus.  It keeps us from being able to
> accurately compare ALLOC_SLOWPATH vs. ALLOC_FASTPATH.  It also
> means that the total number of allocs always exceeds the total
> number of frees.
> 
> This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
> same place that __slab_alloc() is.  This makes it much less
> likely that ALLOC_SLOWPATH will get botched again in the
> spaghetti-code inside __slab_alloc().
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>

Acked-by: David Rientjes <rientjes@google.com>

--
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] 6+ messages in thread

* Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
  2014-01-09  2:24 ` David Rientjes
@ 2014-01-21 22:14   ` David Rientjes
  2014-05-08  3:05     ` David Rientjes
  0 siblings, 1 reply; 6+ messages in thread
From: David Rientjes @ 2014-01-21 22:14 UTC (permalink / raw)
  To: Dave Hansen
  Cc: linux-mm, linux-kernel, Christoph Lameter, Andrew Morton, Pekka Enberg

On Wed, 8 Jan 2014, David Rientjes wrote:

> > There used to be only one path out of __slab_alloc(), and
> > ALLOC_SLOWPATH got bumped in that exit path.  Now there are two,
> > and a bunch of gotos.  ALLOC_SLOWPATH can now get set more than once
> > during a single call to __slab_alloc() which is pretty bogus.
> > Here's the sequence:
> > 
> > 1. Enter __slab_alloc(), fall through all the way to the
> >    stat(s, ALLOC_SLOWPATH);
> > 2. hit 'if (!freelist)', and bump DEACTIVATE_BYPASS, jump to
> >    new_slab (goto #1)
> > 3. Hit 'if (c->partial)', bump CPU_PARTIAL_ALLOC, goto redo
> >    (goto #2)
> > 4. Fall through in the same path we did before all the way to
> >    stat(s, ALLOC_SLOWPATH)
> > 5. bump ALLOC_REFILL stat, then return
> > 
> > Doing this is obviously bogus.  It keeps us from being able to
> > accurately compare ALLOC_SLOWPATH vs. ALLOC_FASTPATH.  It also
> > means that the total number of allocs always exceeds the total
> > number of frees.
> > 
> > This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
> > same place that __slab_alloc() is.  This makes it much less
> > likely that ALLOC_SLOWPATH will get botched again in the
> > spaghetti-code inside __slab_alloc().
> > 
> > Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> 
> Acked-by: David Rientjes <rientjes@google.com>
> 

Pekka, are you going to pick this up for linux-next?  I think it would be 
nice to have for 3.14 for those of us who use the stats.

--
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] 6+ messages in thread

* Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
  2014-01-21 22:14   ` David Rientjes
@ 2014-05-08  3:05     ` David Rientjes
  0 siblings, 0 replies; 6+ messages in thread
From: David Rientjes @ 2014-05-08  3:05 UTC (permalink / raw)
  To: Andrew Morton, Pekka Enberg
  Cc: Dave Hansen, linux-mm, linux-kernel, Christoph Lameter

On Tue, 21 Jan 2014, David Rientjes wrote:

> On Wed, 8 Jan 2014, David Rientjes wrote:
> 
> > > There used to be only one path out of __slab_alloc(), and
> > > ALLOC_SLOWPATH got bumped in that exit path.  Now there are two,
> > > and a bunch of gotos.  ALLOC_SLOWPATH can now get set more than once
> > > during a single call to __slab_alloc() which is pretty bogus.
> > > Here's the sequence:
> > > 
> > > 1. Enter __slab_alloc(), fall through all the way to the
> > >    stat(s, ALLOC_SLOWPATH);
> > > 2. hit 'if (!freelist)', and bump DEACTIVATE_BYPASS, jump to
> > >    new_slab (goto #1)
> > > 3. Hit 'if (c->partial)', bump CPU_PARTIAL_ALLOC, goto redo
> > >    (goto #2)
> > > 4. Fall through in the same path we did before all the way to
> > >    stat(s, ALLOC_SLOWPATH)
> > > 5. bump ALLOC_REFILL stat, then return
> > > 
> > > Doing this is obviously bogus.  It keeps us from being able to
> > > accurately compare ALLOC_SLOWPATH vs. ALLOC_FASTPATH.  It also
> > > means that the total number of allocs always exceeds the total
> > > number of frees.
> > > 
> > > This patch moves stat(s, ALLOC_SLOWPATH) to be called from the
> > > same place that __slab_alloc() is.  This makes it much less
> > > likely that ALLOC_SLOWPATH will get botched again in the
> > > spaghetti-code inside __slab_alloc().
> > > 
> > > Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> > 
> > Acked-by: David Rientjes <rientjes@google.com>
> > 
> 
> Pekka, are you going to pick this up for linux-next?  I think it would be 
> nice to have for 3.14 for those of us who use the stats.
> 

Ping #2.  Pekka or Andrew, would you pick this up for linux-next?

--
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] 6+ messages in thread

end of thread, other threads:[~2014-05-08  3:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-06 20:43 [PATCH] mm: slub: fix ALLOC_SLOWPATH stat Dave Hansen
2014-01-07  2:44 ` Christoph Lameter
2014-01-07  4:44 ` Wanpeng Li
2014-01-09  2:24 ` David Rientjes
2014-01-21 22:14   ` David Rientjes
2014-05-08  3:05     ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox