linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: linux-mm@kvack.org, Christoph Lameter <cl@linux.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: netdev@vger.kernel.org,
	Alexander Duyck <alexander.duyck@gmail.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>
Subject: [PATCH 3/7] slub: reduce indention level in kmem_cache_alloc_bulk()
Date: Mon, 15 Jun 2015 17:52:17 +0200	[thread overview]
Message-ID: <20150615155216.18824.26550.stgit@devil> (raw)
In-Reply-To: <20150615155053.18824.617.stgit@devil>

Use kernel early return style to reduce indention level,
by testing for kmem_cache_debug() and fallback to
none-optimized bulking via __kmem_cache_alloc_bulk().

This also make it easier to fix a bug in the current
implementation, in the next patch.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 mm/slub.c |   37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index d18f8e195ac4..753f88bd8b40 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2757,32 +2757,33 @@ void kmem_cache_free_bulk(struct kmem_cache *s, size_t size, void **p)
 EXPORT_SYMBOL(kmem_cache_free_bulk);
 
 bool kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, size_t size,
-								void **p)
+			   void **p)
 {
-	if (!kmem_cache_debug(s)) {
-		struct kmem_cache_cpu *c;
+	struct kmem_cache_cpu *c;
 
-		/* Drain objects in the per cpu slab */
-		local_irq_disable();
-		c = this_cpu_ptr(s->cpu_slab);
+	/* Debugging fallback to generic bulk */
+	if (kmem_cache_debug(s))
+		return __kmem_cache_alloc_bulk(s, flags, size, p);
 
-		while (size) {
-			void *object = c->freelist;
+	/* Drain objects in the per cpu slab */
+	local_irq_disable();
+	c = this_cpu_ptr(s->cpu_slab);
 
-			if (!object)
-				break;
+	while (size) {
+		void *object = c->freelist;
 
-			c->freelist = get_freepointer(s, object);
-			*p++ = object;
-			size--;
+		if (!object)
+			break;
 
-			if (unlikely(flags & __GFP_ZERO))
-				memset(object, 0, s->object_size);
-		}
-		c->tid = next_tid(c->tid);
+		c->freelist = get_freepointer(s, object);
+		*p++ = object;
+		size--;
 
-		local_irq_enable();
+		if (unlikely(flags & __GFP_ZERO))
+			memset(object, 0, s->object_size);
 	}
+	c->tid = next_tid(c->tid);
+	local_irq_enable();
 
 	return __kmem_cache_alloc_bulk(s, flags, size, p);
 }

--
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:[~2015-06-15 15:52 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 15:51 [PATCH 0/7] slub: bulk alloc and free for slub allocator Jesper Dangaard Brouer
2015-06-15 15:51 ` [PATCH 1/7] slab: infrastructure for bulk object allocation and freeing Jesper Dangaard Brouer
2015-06-15 16:45   ` Alexander Duyck
2015-06-15 16:50     ` Christoph Lameter
2015-06-16 21:44   ` Andrew Morton
2015-06-15 15:52 ` [PATCH 2/7] slub bulk alloc: extract objects from the per cpu slab Jesper Dangaard Brouer
2015-06-16  7:21   ` Joonsoo Kim
2015-06-16 15:05     ` Christoph Lameter
2015-06-16 21:48   ` Andrew Morton
2015-06-17  6:24     ` Jesper Dangaard Brouer
2015-06-15 15:52 ` Jesper Dangaard Brouer [this message]
2015-06-15 15:52 ` [PATCH 4/7] slub: fix error path bug in kmem_cache_alloc_bulk Jesper Dangaard Brouer
2015-06-16 21:51   ` Andrew Morton
2015-06-17  6:25     ` Jesper Dangaard Brouer
2015-06-15 15:52 ` [PATCH 5/7] slub: kmem_cache_alloc_bulk() move clearing outside IRQ disabled section Jesper Dangaard Brouer
2015-06-15 15:52 ` [PATCH 6/7] slub: improve bulk alloc strategy Jesper Dangaard Brouer
2015-06-15 16:36   ` Christoph Lameter
2015-06-16 21:53   ` Andrew Morton
2015-06-17  6:29     ` Jesper Dangaard Brouer
2015-06-15 15:52 ` [PATCH 7/7] slub: initial bulk free implementation Jesper Dangaard Brouer
2015-06-15 16:34   ` Christoph Lameter
2015-06-16  8:04     ` Jesper Dangaard Brouer
2015-06-15 17:04   ` Alexander Duyck
2015-06-16  7:23   ` Joonsoo Kim
2015-06-16  9:20     ` Jesper Dangaard Brouer
2015-06-16 12:00       ` Joonsoo Kim
2015-06-16 13:58         ` Jesper Dangaard Brouer
2015-06-16 15:06         ` Christoph Lameter
2015-06-16  7:28   ` Joonsoo Kim
2015-06-16  8:21     ` Jesper Dangaard Brouer
2015-06-16  8:57       ` Jesper Dangaard Brouer
2015-06-16 12:05         ` Joonsoo Kim
2015-06-16 15:10           ` Christoph Lameter
2015-06-16 15:52             ` Jesper Dangaard Brouer
2015-06-16 16:04               ` Christoph Lameter

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=20150615155216.18824.26550.stgit@devil \
    --to=brouer@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --cc=cl@linux.com \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).