All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@cs.helsinki.fi>
To: manfred@colorfullife.com, christoph@lameter.com
Cc: linux-kernel@vger.kernel.org
Subject: [RFC/PATCH 2/3] slab: extract alloc_node_cache
Date: Mon, 23 Jan 2006 18:57:19 +0200	[thread overview]
Message-ID: <1138035439.10527.21.camel@localhost> (raw)

From: Pekka Enberg <penberg@cs.helsinki.fi>

This patch removes duplicate code by extracting node_cache allocation
to alloc_node_cache function.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 mm/slab.c |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c
+++ 2.6/mm/slab.c
@@ -347,6 +347,16 @@ static void node_cache_init(struct node_
 	parent->free_touched = 0;
 }
 
+static struct node_cache *alloc_node_cache(int node)
+{
+	struct node_cache *node_cache;
+
+	node_cache = kmalloc_node(sizeof(*node_cache), GFP_KERNEL, node);
+	if (node_cache)
+		node_cache_init(node_cache);
+	return node_cache;
+}
+
 #define MAKE_LIST(cachep, listp, slab, nodeid)	\
 	do {	\
 		INIT_LIST_HEAD(listp);		\
@@ -907,7 +917,6 @@ static int __devinit cpuup_callback(stru
 	struct kmem_cache *cachep;
 	struct node_cache *node_cache = NULL;
 	int node = cpu_to_node(cpu);
-	int memsize = sizeof(struct node_cache);
 
 	switch (action) {
 	case CPU_UP_PREPARE:
@@ -924,10 +933,9 @@ static int __devinit cpuup_callback(stru
 			 * node has not already allocated this
 			 */
 			if (!cachep->nodelists[node]) {
-				if (!(node_cache = kmalloc_node(memsize,
-							GFP_KERNEL, node)))
+				node_cache = alloc_node_cache(node);
+				if (!node_cache)
 					goto bad;
-				node_cache_init(node_cache);
 				node_cache->next_reap = jiffies + REAPTIMEOUT_LIST3 +
 				    ((unsigned long)cachep) % REAPTIMEOUT_LIST3;
 
@@ -1891,14 +1899,9 @@ kmem_cache_create (const char *name, siz
 			} else {
 				int node;
 				for_each_online_node(node) {
-
 					cachep->nodelists[node] =
-					    kmalloc_node(sizeof
-							 (struct node_cache),
-							 GFP_KERNEL, node);
+						alloc_node_cache(node);
 					BUG_ON(!cachep->nodelists[node]);
-					node_cache_init(cachep->
-							nodelists[node]);
 				}
 			}
 		}
@@ -3211,11 +3214,9 @@ static int alloc_node_caches(struct kmem
 			free_alien_cache(new_alien);
 			continue;
 		}
-		if (!(node_cache = kmalloc_node(sizeof(struct node_cache),
-					GFP_KERNEL, node)))
+		node_cache = alloc_node_cache(node);
+		if (!node_cache)
 			goto fail;
-
-		node_cache_init(node_cache);
 		node_cache->next_reap = jiffies + REAPTIMEOUT_LIST3 +
 		    ((unsigned long)cachep) % REAPTIMEOUT_LIST3;
 		node_cache->shared = new;



                 reply	other threads:[~2006-01-23 16:57 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=1138035439.10527.21.camel@localhost \
    --to=penberg@cs.helsinki.fi \
    --cc=christoph@lameter.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.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 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.