Re: [PATCH] null_blk: Register as a LightNVM device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/11/2015 02:27 PM, Jens Axboe wrote:
On 11/11/2015 03:06 AM, Matias Bjørling wrote:
Add support for registering as a LightNVM device. This allows us to
evaluate the performance of the LightNVM library.

In /drivers/Makefile, LightNVM is moved above block device drivers
to make sure that the LightNVM media managers have been initialized
before drivers under /drivers/block are initialized.

Generally looks ok. One question:

+static void *null_lnvm_create_dma_pool(struct request_queue *q, char
*name)
+{
+    mempool_t *virtmem_pool;
+
+    ppa_cache = kmem_cache_create(name, PAGE_SIZE, 0, 0, NULL);
+    if (!ppa_cache) {
+        pr_err("null_nvm: Unable to create kmem cache\n");
+        return NULL;
+    }
+
+    virtmem_pool = mempool_create_slab_pool(64, ppa_cache);
+    if (!virtmem_pool) {
+        pr_err("null_nvm: Unable to create virtual memory pool\n");
+        return NULL;
+    }
+
+    return virtmem_pool;
+}

Why create a slab cache if it's pages? Why not just have the mempool
alloc/free alloc single pages?

Ala attached. Also fixes a leak of not freeing the ppa_cache slab cache. Did you try and load/reload the module? I'm thinking it would have crashed.

--
Jens Axboe

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 1efaef6e54e9..31d5debc020e 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -446,8 +446,6 @@ static void null_del_dev(struct nullb *nullb)
 
 #ifdef CONFIG_NVM
 
-static struct kmem_cache *ppa_cache;
-
 static void null_lnvm_end_io(struct request *rq, int error)
 {
 	struct nvm_rq *rqd = rq->end_io_data;
@@ -523,13 +521,7 @@ static void *null_lnvm_create_dma_pool(struct request_queue *q, char *name)
 {
 	mempool_t *virtmem_pool;
 
-	ppa_cache = kmem_cache_create(name, PAGE_SIZE, 0, 0, NULL);
-	if (!ppa_cache) {
-		pr_err("null_nvm: Unable to create kmem cache\n");
-		return NULL;
-	}
-
-	virtmem_pool = mempool_create_slab_pool(64, ppa_cache);
+	virtmem_pool = mempool_create_page_pool(64, 0);
 	if (!virtmem_pool) {
 		pr_err("null_nvm: Unable to create virtual memory pool\n");
 		return NULL;
@@ -540,10 +532,8 @@ static void *null_lnvm_create_dma_pool(struct request_queue *q, char *name)
 
 static void null_lnvm_destroy_dma_pool(void *pool)
 {
-	mempool_t *virtmem_pool = pool;
+	mempool_destroy(pool);
 
-	mempool_destroy(virtmem_pool);
-}
 
 static void *null_lnvm_dev_dma_alloc(struct request_queue *q, void *pool,
 				gfp_t mem_flags, dma_addr_t *dma_handler)

[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux