staging: zcache: reduce tmem bucket lock contention
PATCH 1/1 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
--- drivers/staging/zcache/zcache-main.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/staging/zcache/zcache-main.c +3 -1
@@ -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)
Signature · 1 line
1.7.4.1
Quoted 14 lines
From: Seth Jennings [mailto:[email protected]]
Sent: Thursday, September 29, 2011 8:32 AM
To: [email protected]
Cc: [email protected]; Dan Magenheimer; [email protected]; [email protected]; linux- [email protected]; Seth Jennings
Subject: [PATCH] staging: zcache: reduce tmem bucket lock contentiontmem 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 thetmem_oidis generated for frontswap pages, only 16 uniquetmem_oidsare being generated, resulting in only 16 of the 256 buckets being used. This cause high lock contention for the per bucket locks.
Quoted 7 lines
This patch changes
SWIZ_BITSto 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 <[email protected]>
Good catch Seth!
Quoted 10 lines · 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 thetmem_oidis generated for frontswap pages, only 16 uniquetmem_oidsare 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_BITSto 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
PATCH 1/1 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
--- drivers/staging/zcache/zcache-main.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/staging/zcache/zcache-main.c +3 -1
@@ -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)
Signature · 1 line
1.7.4.1