From: Wenwei Tao <ww.tao0320@gmail.com>
To: mb@lightnvm.io
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH] lightnvm: change rrpc slab creation/destruction time
Date: Mon, 7 Dec 2015 20:16:17 +0800 [thread overview]
Message-ID: <1449490577-30574-1-git-send-email-ww.tao0320@gmail.com> (raw)
create rrpc slabs during rrpc module init,
thus eliminate the lock contention and slab
status check in rrpc_core_init. And destroy
them when rrpc exit.
Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
drivers/lightnvm/rrpc.c | 54 ++++++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index 75e59c3..a36f39a 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -17,7 +17,6 @@
#include "rrpc.h"
static struct kmem_cache *rrpc_gcb_cache, *rrpc_rq_cache;
-static DECLARE_RWSEM(rrpc_lock);
static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
struct nvm_rq *rqd, unsigned long flags);
@@ -1019,26 +1018,6 @@ static int rrpc_map_init(struct rrpc *rrpc)
static int rrpc_core_init(struct rrpc *rrpc)
{
- down_write(&rrpc_lock);
- if (!rrpc_gcb_cache) {
- rrpc_gcb_cache = kmem_cache_create("rrpc_gcb",
- sizeof(struct rrpc_block_gc), 0, 0, NULL);
- if (!rrpc_gcb_cache) {
- up_write(&rrpc_lock);
- return -ENOMEM;
- }
-
- rrpc_rq_cache = kmem_cache_create("rrpc_rq",
- sizeof(struct nvm_rq) + sizeof(struct rrpc_rq),
- 0, 0, NULL);
- if (!rrpc_rq_cache) {
- kmem_cache_destroy(rrpc_gcb_cache);
- up_write(&rrpc_lock);
- return -ENOMEM;
- }
- }
- up_write(&rrpc_lock);
-
rrpc->page_pool = mempool_create_page_pool(PAGE_POOL_SIZE, 0);
if (!rrpc->page_pool)
return -ENOMEM;
@@ -1338,14 +1317,47 @@ static struct nvm_tgt_type tt_rrpc = {
.exit = rrpc_exit,
};
+static int __init rrpc_slab_init(void)
+{
+ rrpc_gcb_cache = kmem_cache_create("rrpc_gcb",
+ sizeof(struct rrpc_block_gc), 0, 0, NULL);
+ if (!rrpc_gcb_cache)
+ goto out;
+
+ rrpc_rq_cache = kmem_cache_create("rrpc_rq",
+ sizeof(struct nvm_rq) + sizeof(struct rrpc_rq),
+ 0, 0, NULL);
+ if (!rrpc_rq_cache)
+ goto out_free;
+
+ return 0;
+
+out_free:
+ kmem_cache_destroy(rrpc_gcb_cache);
+out:
+ return -ENOMEM;
+}
+
+static inline void rrpc_slab_free(void)
+{
+ kmem_cache_destroy(rrpc_gcb_cache);
+ kmem_cache_destroy(rrpc_rq_cache);
+}
+
static int __init rrpc_module_init(void)
{
+ int ret;
+
+ ret = rrpc_slab_init();
+ if (ret)
+ return ret;
return nvm_register_target(&tt_rrpc);
}
static void rrpc_module_exit(void)
{
nvm_unregister_target(&tt_rrpc);
+ rrpc_slab_free();
}
module_init(rrpc_module_init);
--
1.8.3.1
next reply other threads:[~2015-12-07 12:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 12:16 Wenwei Tao [this message]
[not found] ` <CAOA7RkMEv6L7EGjcdQmTu-4vRNDDCXdnE9U_Hk4oLVch1yYf=g@mail.gmail.com>
2015-12-08 11:36 ` Wenwei Tao
2015-12-08 13:26 ` Matias Bjørling
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=1449490577-30574-1-git-send-email-ww.tao0320@gmail.com \
--to=ww.tao0320@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®