linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: Dave Hansen <dave@sr71.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	cl@linux-foundation.org, akpm@linux-foundation.org,
	penberg@kernel.org
Subject: Re: [PATCH] mm: slub: fix ALLOC_SLOWPATH stat
Date: Tue, 7 Jan 2014 12:44:32 +0800	[thread overview]
Message-ID: <52cb8638.2590420a.46e0.ffffd916SMTPIN_ADDED_BROKEN@mx.google.com> (raw)
In-Reply-To: <20140106204300.DE79BA86@viggo.jf.intel.com>

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>

  parent reply	other threads:[~2014-01-07  4:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-06 20:43 Dave Hansen
2014-01-07  2:44 ` Christoph Lameter
2014-01-07  4:44 ` Wanpeng Li [this message]
2014-01-09  2:24 ` David Rientjes
2014-01-21 22:14   ` David Rientjes
2014-05-08  3:05     ` David Rientjes

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=52cb8638.2590420a.46e0.ffffd916SMTPIN_ADDED_BROKEN@mx.google.com \
    --to=liwanp@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=dave@sr71.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox