linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Jesper Dangaard Brouer <brouer@redhat.com>
Subject: [PATCH 4/6] mm/slab: rearrange irq management
Date: Mon,  5 Jan 2015 10:37:29 +0900	[thread overview]
Message-ID: <1420421851-3281-5-git-send-email-iamjoonsoo.kim@lge.com> (raw)
In-Reply-To: <1420421851-3281-1-git-send-email-iamjoonsoo.kim@lge.com>

Currently, irq is disabled at the very beginning phase of allocation
functions. In the following patch, some of allocation functions will
be changed to work without irq disabling so rearrange irq management
code as preparation step.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/slab.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 62cd5c6..1246ac6 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2934,8 +2934,9 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 	void *objp;
 	struct array_cache *ac;
 	bool force_refill = false;
+	unsigned long save_flags;
 
-	check_irq_off();
+	local_irq_save(save_flags);
 
 	ac = cpu_cache_get(cachep);
 	if (likely(ac->avail)) {
@@ -2957,6 +2958,8 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 	objp = cache_alloc_refill(cachep, flags, force_refill);
 
 out:
+	local_irq_restore(save_flags);
+
 	return objp;
 }
 
@@ -3082,13 +3085,15 @@ static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
 	struct kmem_cache_node *n;
 	void *obj;
 	int x;
+	unsigned long save_flags;
 
 	VM_BUG_ON(nodeid < 0 || nodeid >= MAX_NUMNODES);
 	n = get_node(cachep, nodeid);
 	BUG_ON(!n);
 
+	local_irq_save(save_flags);
+
 retry:
-	check_irq_off();
 	spin_lock(&n->list_lock);
 	entry = n->slabs_partial.next;
 	if (entry == &n->slabs_partial) {
@@ -3126,9 +3131,10 @@ must_grow:
 	if (x)
 		goto retry;
 
-	return fallback_alloc(cachep, flags);
+	obj = fallback_alloc(cachep, flags);
 
 done:
+	local_irq_restore(save_flags);
 	return obj;
 }
 
@@ -3150,14 +3156,15 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
 	cachep = memcg_kmem_get_cache(cachep, flags);
 
 	cache_alloc_debugcheck_before(cachep, flags);
-	local_irq_save(save_flags);
 
 	if (nodeid == NUMA_NO_NODE)
 		nodeid = slab_node;
 
 	if (unlikely(!get_node(cachep, nodeid))) {
 		/* Node not bootstrapped yet */
+		local_irq_save(save_flags);
 		ptr = fallback_alloc(cachep, flags);
+		local_irq_restore(save_flags);
 		goto out;
 	}
 
@@ -3174,8 +3181,8 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
 	}
 	/* ___cache_alloc_node can fall back to other nodes */
 	ptr = ____cache_alloc_node(cachep, flags, nodeid);
-  out:
-	local_irq_restore(save_flags);
+
+out:
 	ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
 	kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
 				 flags);
@@ -3225,7 +3232,6 @@ __do_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
 static __always_inline void *
 slab_alloc(struct kmem_cache *cachep, gfp_t flags, unsigned long caller)
 {
-	unsigned long save_flags;
 	void *objp;
 
 	flags &= gfp_allowed_mask;
@@ -3238,9 +3244,7 @@ slab_alloc(struct kmem_cache *cachep, gfp_t flags, unsigned long caller)
 	cachep = memcg_kmem_get_cache(cachep, flags);
 
 	cache_alloc_debugcheck_before(cachep, flags);
-	local_irq_save(save_flags);
 	objp = __do_cache_alloc(cachep, flags);
-	local_irq_restore(save_flags);
 	objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
 	kmemleak_alloc_recursive(objp, cachep->object_size, 1, cachep->flags,
 				 flags);
-- 
1.7.9.5

--
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-01-05  1:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05  1:37 [PATCH 0/6] mm/slab: optimize allocation fastpath Joonsoo Kim
2015-01-05  1:37 ` [PATCH 1/6] mm/slab: fix gfp flags of percpu allocation at boot phase Joonsoo Kim
2015-01-05  1:37 ` [PATCH 2/6] mm/slab: remove kmemleak_erase() call Joonsoo Kim
2015-01-08 12:01   ` Catalin Marinas
2015-01-05  1:37 ` [PATCH 3/6] mm/slab: clean-up __ac_get_obj() to prepare future changes Joonsoo Kim
2015-01-05  1:37 ` Joonsoo Kim [this message]
2015-01-05  1:37 ` [PATCH 5/6] mm/slab: cleanup ____cache_alloc() Joonsoo Kim
2015-01-05  1:37 ` [PATCH 6/6] mm/slab: allocation fastpath without disabling irq Joonsoo Kim
2015-01-05 15:28   ` Christoph Lameter
2015-01-06  1:04     ` Joonsoo Kim
2015-01-05 17:21   ` Andreas Mohr
2015-01-05 17:52     ` Christoph Lameter
2015-01-06  1:31     ` Joonsoo Kim
2015-01-06 10:34       ` Andreas Mohr
2015-01-06 15:33         ` Christoph Lameter
2015-01-06 16:26           ` Andreas Mohr
2015-01-08  7:54         ` 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=1420421851-3281-5-git-send-email-iamjoonsoo.kim@lge.com \
    --to=iamjoonsoo.kim@lge.com \
    --cc=akpm@linux-foundation.org \
    --cc=brouer@redhat.com \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /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