All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: mingo@elte.hu, Thomas Gleixner <tglx@linutronix.de>
Cc: linux-rt-users@vger.kernel.org
Subject: [PATCH] Fix alternate_node_alloc() on RT kernel
Date: Mon, 17 Sep 2007 15:36:59 +0200	[thread overview]
Message-ID: <200709171536.59367.ak@suse.de> (raw)


__do_cache_allow/alternate_node_alloc() need to pass the this_cpu variable from
the caller to cache_grow(); otherwise the slab lock for the wrong CPU
can be released when a task switches CPUs inside cache_grow().

Signed-off-by: Andi Kleen <ak@suse.de>

Index: linux-2.6.23-rc4-rt1/mm/slab.c
===================================================================
--- linux-2.6.23-rc4-rt1.orig/mm/slab.c
+++ linux-2.6.23-rc4-rt1/mm/slab.c
@@ -1070,7 +1070,7 @@ cache_free_alien(struct kmem_cache *cach
 }
 
 static inline void *alternate_node_alloc(struct kmem_cache *cachep,
-		gfp_t flags)
+		gfp_t flags, int *this_cpu)
 {
 	return NULL;
 }
@@ -1085,7 +1085,7 @@ static inline void *____cache_alloc_node
 
 static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
 				int nodeid, int *this_cpu);
-static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
+static void *alternate_node_alloc(struct kmem_cache *, gfp_t, int *);
 
 static struct array_cache **alloc_alien_cache(int node, int limit)
 {
@@ -3308,9 +3308,10 @@ ____cache_alloc(struct kmem_cache *cache
  * If we are in_interrupt, then process context, including cpusets and
  * mempolicy, may not apply and should not be used for allocation policy.
  */
-static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
+static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags,
+				int *this_cpu)
 {
-	int nid_alloc, nid_here, this_cpu = raw_smp_processor_id();
+	int nid_alloc, nid_here;
 
 	if (in_interrupt() || (flags & __GFP_THISNODE))
 		return NULL;
@@ -3320,7 +3321,7 @@ static void *alternate_node_alloc(struct
 	else if (current->mempolicy)
 		nid_alloc = slab_node(current->mempolicy);
 	if (nid_alloc != nid_here)
-		return ____cache_alloc_node(cachep, flags, nid_alloc, &this_cpu);
+		return ____cache_alloc_node(cachep, flags, nid_alloc, this_cpu);
 	return NULL;
 }
 
@@ -3533,7 +3534,7 @@ __do_cache_alloc(struct kmem_cache *cach
 	void *objp;
 
 	if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) {
-		objp = alternate_node_alloc(cache, flags);
+		objp = alternate_node_alloc(cache, flags, this_cpu);
 		if (objp)
 			goto out;
 	}

                 reply	other threads:[~2007-09-17 13:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200709171536.59367.ak@suse.de \
    --to=ak@suse.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.