linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] slub: move kmem_cache_node into it's own cacheline
@ 2010-05-21 21:41 Alexander Duyck
  2010-05-22  8:35 ` Pekka Enberg
  2010-05-24 13:52 ` Christoph Lameter
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Duyck @ 2010-05-21 21:41 UTC (permalink / raw)
  To: penberg, cl; +Cc: linux-mm

This patch is meant to improve the performance of SLUB by moving the local
kmem_cache_node lock into it's own cacheline separate from kmem_cache.
This is accomplished by simply removing the local_node when NUMA is enabled.

On my system with 2 nodes I saw around a 5% performance increase w/
hackbench times dropping from 6.2 seconds to 5.9 seconds on average.  I
suspect the performance gain would increase as the number of nodes
increases, but I do not have the data to currently back that up.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---

 include/linux/slub_def.h |    9 +++------
 mm/slub.c                |   33 +++++++++++----------------------
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 0249d41..7d7bf5a 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -75,12 +75,6 @@ struct kmem_cache {
 	int offset;		/* Free pointer offset. */
 	struct kmem_cache_order_objects oo;
 
-	/*
-	 * Avoid an extra cache line for UP, SMP and for the node local to
-	 * struct kmem_cache.
-	 */
-	struct kmem_cache_node local_node;
-
 	/* Allocation and freeing of slabs */
 	struct kmem_cache_order_objects max;
 	struct kmem_cache_order_objects min;
@@ -102,6 +96,9 @@ struct kmem_cache {
 	 */
 	int remote_node_defrag_ratio;
 	struct kmem_cache_node *node[MAX_NUMNODES];
+#else
+	/* Avoid an extra cache line for UP */
+	struct kmem_cache_node local_node;
 #endif
 };
 
diff --git a/mm/slub.c b/mm/slub.c
index 461314b..8af03de 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2141,7 +2141,7 @@ static void free_kmem_cache_nodes(struct kmem_cache *s)
 
 	for_each_node_state(node, N_NORMAL_MEMORY) {
 		struct kmem_cache_node *n = s->node[node];
-		if (n && n != &s->local_node)
+		if (n)
 			kmem_cache_free(kmalloc_caches, n);
 		s->node[node] = NULL;
 	}
@@ -2150,33 +2150,22 @@ static void free_kmem_cache_nodes(struct kmem_cache *s)
 static int init_kmem_cache_nodes(struct kmem_cache *s, gfp_t gfpflags)
 {
 	int node;
-	int local_node;
-
-	if (slab_state >= UP && (s < kmalloc_caches ||
-			s >= kmalloc_caches + KMALLOC_CACHES))
-		local_node = page_to_nid(virt_to_page(s));
-	else
-		local_node = 0;
 
 	for_each_node_state(node, N_NORMAL_MEMORY) {
 		struct kmem_cache_node *n;
 
-		if (local_node == node)
-			n = &s->local_node;
-		else {
-			if (slab_state == DOWN) {
-				early_kmem_cache_node_alloc(gfpflags, node);
-				continue;
-			}
-			n = kmem_cache_alloc_node(kmalloc_caches,
-							gfpflags, node);
-
-			if (!n) {
-				free_kmem_cache_nodes(s);
-				return 0;
-			}
+		if (slab_state == DOWN) {
+			early_kmem_cache_node_alloc(gfpflags, node);
+			continue;
+		}
+		n = kmem_cache_alloc_node(kmalloc_caches,
+						gfpflags, node);
 
+		if (!n) {
+			free_kmem_cache_nodes(s);
+			return 0;
 		}
+
 		s->node[node] = n;
 		init_kmem_cache_node(n, s);
 	}

--
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>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] slub: move kmem_cache_node into it's own cacheline
  2010-05-21 21:41 [PATCH v2] slub: move kmem_cache_node into it's own cacheline Alexander Duyck
@ 2010-05-22  8:35 ` Pekka Enberg
  2010-05-23 13:15   ` Shi, Alex
  2010-05-24 13:52 ` Christoph Lameter
  1 sibling, 1 reply; 4+ messages in thread
From: Pekka Enberg @ 2010-05-22  8:35 UTC (permalink / raw)
  To: Alexander Duyck
  Cc: cl, linux-mm, alex.shi, yanmin_zhang, akpm, linux-kernel, rjw

Alexander Duyck wrote:
> This patch is meant to improve the performance of SLUB by moving the local
> kmem_cache_node lock into it's own cacheline separate from kmem_cache.
> This is accomplished by simply removing the local_node when NUMA is enabled.
> 
> On my system with 2 nodes I saw around a 5% performance increase w/
> hackbench times dropping from 6.2 seconds to 5.9 seconds on average.  I
> suspect the performance gain would increase as the number of nodes
> increases, but I do not have the data to currently back that up.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>

Thanks for the fix, Alexander!

Yanmin and Alex, can I have your Tested-by or Acked-by please so we can 
close "[Bug #15713] hackbench regression due to commit 9dfc6e68bfe6e" 
after this patch is merged?

			Pekka

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] slub: move kmem_cache_node into it's own cacheline
  2010-05-22  8:35 ` Pekka Enberg
@ 2010-05-23 13:15   ` Shi, Alex
  0 siblings, 0 replies; 4+ messages in thread
From: Shi, Alex @ 2010-05-23 13:15 UTC (permalink / raw)
  To: Pekka Enberg, Duyck, Alexander H
  Cc: cl@linux.com, linux-mm@kvack.org, yanmin_zhang@linux.intel.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	rjw@sisk.pl

sure. glad to a fix on this! 
 

-----Original Message-----
From: Pekka Enberg [mailto:penberg@cs.helsinki.fi] 
Sent: 2010年5月22日 16:36
To: Duyck, Alexander H
Cc: cl@linux.com; linux-mm@kvack.org; Shi, Alex; yanmin_zhang@linux.intel.com; akpm@linux-foundation.org; linux-kernel@vger.kernel.org; rjw@sisk.pl
Subject: Re: [PATCH v2] slub: move kmem_cache_node into it's own cacheline

Alexander Duyck wrote:
> This patch is meant to improve the performance of SLUB by moving the 
> local kmem_cache_node lock into it's own cacheline separate from kmem_cache.
> This is accomplished by simply removing the local_node when NUMA is enabled.
> 
> On my system with 2 nodes I saw around a 5% performance increase w/ 
> hackbench times dropping from 6.2 seconds to 5.9 seconds on average.  
> I suspect the performance gain would increase as the number of nodes 
> increases, but I do not have the data to currently back that up.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>

Thanks for the fix, Alexander!

Yanmin and Alex, can I have your Tested-by or Acked-by please so we can close "[Bug #15713] hackbench regression due to commit 9dfc6e68bfe6e" 
after this patch is merged?

			Pekka

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] slub: move kmem_cache_node into it's own cacheline
  2010-05-21 21:41 [PATCH v2] slub: move kmem_cache_node into it's own cacheline Alexander Duyck
  2010-05-22  8:35 ` Pekka Enberg
@ 2010-05-24 13:52 ` Christoph Lameter
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Lameter @ 2010-05-24 13:52 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: penberg, cl, linux-mm


Acked-by: Christoph Lameter <cl@linux-foundation.org>


--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-24 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-21 21:41 [PATCH v2] slub: move kmem_cache_node into it's own cacheline Alexander Duyck
2010-05-22  8:35 ` Pekka Enberg
2010-05-23 13:15   ` Shi, Alex
2010-05-24 13:52 ` Christoph Lameter

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).