public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: zcache: reduce tmem bucket lock contention
@ 2011-09-29 14:32 Seth Jennings
  2011-10-03 18:51 ` Dan Magenheimer
  2011-10-03 23:06 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Seth Jennings @ 2011-09-29 14:32 UTC (permalink / raw)
  To: gregkh
  Cc: cascardo, dan.magenheimer, rdunlap, devel, linux-kernel,
	Seth Jennings

tmem uses hash buckets each with their own rbtree and lock to
quickly lookup tmem objects.  tmem has TMEM_HASH_BUCKETS (256)
buckets per pool.  However, because of the way the tmem_oid is
generated for frontswap pages, only 16 unique tmem_oids are being
generated, resulting in only 16 of the 256 buckets being used.
This cause high lock contention for the per bucket locks.

This patch changes SWIZ_BITS to include more bits of the offset.
The result is that all 256 hash buckets are potentially used resulting in a
95% drop in hash bucket lock contention.

Based on v3.1-rc7

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zcache/zcache-main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 462fbc2..ba982f5 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1798,8 +1798,11 @@ static int zcache_frontswap_poolid = -1;
 /*
  * Swizzling increases objects per swaptype, increasing tmem concurrency
  * for heavy swaploads.  Later, larger nr_cpus -> larger SWIZ_BITS
+ * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from
+ * frontswap_get_page()
  */
-#define SWIZ_BITS		4
+#define SWIZ_BITS		27
 #define SWIZ_MASK		((1 << SWIZ_BITS) - 1)
 #define _oswiz(_type, _ind)	((_type << SWIZ_BITS) | (_ind & SWIZ_MASK))
 #define iswiz(_ind)		(_ind >> SWIZ_BITS)
-- 
1.7.4.1


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

* RE: [PATCH] staging: zcache: reduce tmem bucket lock contention
  2011-09-29 14:32 [PATCH] staging: zcache: reduce tmem bucket lock contention Seth Jennings
@ 2011-10-03 18:51 ` Dan Magenheimer
  2011-10-03 23:06 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Magenheimer @ 2011-10-03 18:51 UTC (permalink / raw)
  To: Seth Jennings, gregkh; +Cc: cascardo, rdunlap, devel, linux-kernel

> From: Seth Jennings [mailto:sjenning@linux.vnet.ibm.com]
> Sent: Thursday, September 29, 2011 8:32 AM
> To: gregkh@suse.de
> Cc: cascardo@holoscopio.com; Dan Magenheimer; rdunlap@xenotime.net; devel@driverdev.osuosl.org; linux-
> kernel@vger.kernel.org; Seth Jennings
> Subject: [PATCH] staging: zcache: reduce tmem bucket lock contention
> 
> tmem uses hash buckets each with their own rbtree and lock to
> quickly lookup tmem objects.  tmem has TMEM_HASH_BUCKETS (256)
> buckets per pool.  However, because of the way the tmem_oid is
> generated for frontswap pages, only 16 unique tmem_oids are being
> generated, resulting in only 16 of the 256 buckets being used.
> This cause high lock contention for the per bucket locks.
> 
> This patch changes SWIZ_BITS to include more bits of the offset.
> The result is that all 256 hash buckets are potentially used resulting in a
> 95% drop in hash bucket lock contention.
> 
> Based on v3.1-rc7
> 
> Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>

Good catch Seth!

Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>

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

* Re: [PATCH] staging: zcache: reduce tmem bucket lock contention
  2011-09-29 14:32 [PATCH] staging: zcache: reduce tmem bucket lock contention Seth Jennings
  2011-10-03 18:51 ` Dan Magenheimer
@ 2011-10-03 23:06 ` Greg KH
  2011-10-04 13:21   ` Seth Jennings
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2011-10-03 23:06 UTC (permalink / raw)
  To: Seth Jennings
  Cc: gregkh, cascardo, dan.magenheimer, rdunlap, devel, linux-kernel

On Thu, Sep 29, 2011 at 09:32:26AM -0500, Seth Jennings wrote:
> tmem uses hash buckets each with their own rbtree and lock to
> quickly lookup tmem objects.  tmem has TMEM_HASH_BUCKETS (256)
> buckets per pool.  However, because of the way the tmem_oid is
> generated for frontswap pages, only 16 unique tmem_oids are being
> generated, resulting in only 16 of the 256 buckets being used.
> This cause high lock contention for the per bucket locks.
> 
> This patch changes SWIZ_BITS to include more bits of the offset.
> The result is that all 256 hash buckets are potentially used resulting in a
> 95% drop in hash bucket lock contention.

This patch is somehow corrupted and can't be applied, care to resend it
with Dan's acked-by so that I can apply it?

thanks,

greg k-h

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

* [PATCH] staging: zcache: reduce tmem bucket lock contention
  2011-10-03 23:06 ` Greg KH
@ 2011-10-04 13:21   ` Seth Jennings
  0 siblings, 0 replies; 4+ messages in thread
From: Seth Jennings @ 2011-10-04 13:21 UTC (permalink / raw)
  To: greg
  Cc: gregkh, cascardo, dan.magenheimer, rdunlap, devel, linux-kernel,
	brking, rcj, Seth Jennings

tmem uses hash buckets each with their own rbtree and lock to
quickly lookup tmem objects.  tmem has TMEM_HASH_BUCKETS (256)
buckets per pool.  However, because of the way the tmem_oid is
generated for frontswap pages, only 16 unique tmem_oids are being
generated, resulting in only 16 of the 256 buckets being used.
This cause high lock contention for the per bucket locks.

This patch changes SWIZ_BITS to include more bits of the offset.
The result is that all 256 hash buckets are potentially used resulting in a
95% drop in hash bucket lock contention.

Based on v3.1-rc7

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>
---
 drivers/staging/zcache/zcache-main.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 462fbc2..b4b692f 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1798,8 +1798,10 @@ static int zcache_frontswap_poolid = -1;
 /*
  * Swizzling increases objects per swaptype, increasing tmem concurrency
  * for heavy swaploads.  Later, larger nr_cpus -> larger SWIZ_BITS
+ * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from
+ * frontswap_get_page()
  */
-#define SWIZ_BITS		4
+#define SWIZ_BITS		27
 #define SWIZ_MASK		((1 << SWIZ_BITS) - 1)
 #define _oswiz(_type, _ind)	((_type << SWIZ_BITS) | (_ind & SWIZ_MASK))
 #define iswiz(_ind)		(_ind >> SWIZ_BITS)
-- 
1.7.4.1


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

end of thread, other threads:[~2011-10-04 13:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 14:32 [PATCH] staging: zcache: reduce tmem bucket lock contention Seth Jennings
2011-10-03 18:51 ` Dan Magenheimer
2011-10-03 23:06 ` Greg KH
2011-10-04 13:21   ` Seth Jennings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox