null_blk: Register as a LightNVM device
Subsystems (2)
PATCH 1/1 null_blk: Register as a LightNVM device
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.
--- Documentation/block/null_blk.txt | 3 + drivers/Makefile | 2 +- drivers/block/null_blk.c | 170 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 168 insertions(+), 7 deletions(-)
Documentation/block/null_blk.txt +3 -0
@@ -70,3 +70,6 @@ use_per_node_hctx=[0/1]: Default: 0 parameter. 1: The multi-queue block layer is instantiated with a hardware dispatch queue for each CPU node in the system. + +use_lightnvm=[0/1]: Default: 0 + Register device with LightNVM. Requires blk-mq to be used.
drivers/Makefile +1 -1
@@ -63,6 +63,7 @@ obj-$(CONFIG_FB_I810) += video/fbdev/i810/ obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/ obj-$(CONFIG_PARPORT) += parport/ +obj-$(CONFIG_NVM) += lightnvm/ obj-y += base/ block/ misc/ mfd/ nfc/ obj-$(CONFIG_LIBNVDIMM) += nvdimm/ obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
@@ -70,7 +71,6 @@ obj-$(CONFIG_NUBUS) += nubus/ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/ obj-$(CONFIG_SCSI) += scsi/ -obj-$(CONFIG_NVM) += lightnvm/ obj-y += nvme/ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_TARGET_CORE) += target/
drivers/block/null_blk.c +164 -6
227 lines not on this page · raw message
Signature · 1 line
2.1.4
Jens Axboe
maintainerQuoted 6 lines · Matias Bjørling
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:
Quoted 8 lines
drivers/block/null_blk.c +8
-0+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 ;
drivers/block/null_blk.c static void null_del_dev(struct nullb *nullb) · line 538
Quoted 10 lines
drivers/block/null_blk.c +10
-0+ } + + 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?
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerQuoted 24 lines · Jens Axboe
Quoted 6 lines · Matias Bjørling
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:
Quoted 14 lines
+static void *null_lnvm_create_dma_pool(struct
request_queue*q, char *name)(quoted diff) +12
-0+{ + 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");
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ 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.
Signature · 1 line
Jens Axboe
drivers/block/null_blk.c +2 -12
@@ -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)
Quoted 34 lines · Jens Axboe
Quoted 24 lines · Jens Axboe
Quoted 6 lines · Matias Bjørling
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:
Quoted 14 lines
+static void *null_lnvm_create_dma_pool(struct
request_queue*q, char *name)(quoted diff) +12
-0+{ + 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");Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ 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?
Quoted 3 lines
Ala attached. Also fixes a leak of not freeing the
ppa_cacheslab cache. Did you try and load/reload the module? I'm thinking it would have crashed.
Good idea. I'll apply it. Thanks
Quoted 6 lines · Matias Bj??rling
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.
I don't think mixing the lighnvm code into null_blk is a good idea. Please just create a separate null_nvm device for lighnvm. It already has a completely separate I/O path.
Jens Axboe
maintainerQuoted 11 lines · Christoph Hellwig
Quoted 6 lines · Matias Bj??rling
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.
I don't think mixing the lighnvm code into
null_blkis a good idea. Please just create a separatenull_nvmdevice for lighnvm. It already has a completely separate I/O path.
But it still avoids duplicating the generics of it. Patch for null_blk:
3 files changed, 168 insertions(+), 7 deletions (-)
vs a standalone of:
3 files changed, 459 insertions(+)
It doesn't screw up null_blk, so I'd prefer just adding it as an on-the-side mode for that.
Signature · 1 line
Jens Axboe
Quoted 10 lines · Jens Axboe
But it still avoids duplicating the generics of it. Patch for
null_blk:3 files changed, 168 insertions(+), 7 deletions (-)vs a standalone of:
3 files changed, 459 insertions(+)It doesn't screw up
null_blk, so I'd prefer just adding it as an on-the-side mode for that.
300 lines of boilerplate for just setting up a few request_queues seem wrong, can you show the actual patch you measured?
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Jens Axboe
But it still avoids duplicating the generics of it. Patch for
null_blk:3 files changed, 168 insertions(+), 7 deletions (-)vs a standalone of:
Quoted 7 lines
Quoted 4 lines
3 files changed, 459 insertions(+)It doesn't screw up
null_blk, so I'd prefer just adding it as an on-the-side mode for that.300 lines of boilerplate for just setting up a few
request_queuesseem wrong, can you show the actual patch you measured?
I just took it from Matias' last posting:
http://marc.info/?l=linux-kernel&m=144605858228534&w=2
Signature · 1 line
Jens Axboe
Quoted 6 lines · Jens Axboe
Quoted 2 lines
300 lines of boilerplate for just setting up a few
request_queuesseem wrong, can you show the actual patch you measured?I just took it from Matias' last posting:
Well, that one has all these crazy completion methods which are of no use for a blk-mq driver, so it should really be compared without those.
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jens Axboe
Quoted 2 lines
300 lines of boilerplate for just setting up a few
request_queuesseem wrong, can you show the actual patch you measured?I just took it from Matias' last posting:
Well, that one has all these crazy completion methods which are of no use for a blk-mq driver, so it should really be compared without those.
So we can cut it down a bit, it's still going to be the same boilerplate code that null_blk has, even with just mq completions. If it ended up rewriting null_blk to be something else entirely or full of ifdef sprinkles, I'd agree. But for adding a hundred lines of code to be able to test lightnvm perf, I think it's a no-brainer to just add it to null_blk and not have a separate module.
Signature · 1 line
Jens Axboe
Quoted 13 lines · Jens Axboe
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Jens Axboe
Quoted 2 lines
300 lines of boilerplate for just setting up a few
request_queuesseem wrong, can you show the actual patch you measured?I just took it from Matias' last posting:
Well, that one has all these crazy completion methods which are of no use for a blk-mq driver, so it should really be compared without those.
Quoted 7 lines
So we can cut it down a bit, it's still going to be the same boilerplate code that
null_blkhas, even with just mq completions. If it ended up rewritingnull_blkto be something else entirely or full of ifdef sprinkles, I'd agree. But for adding a hundred lines of code to be able to test lightnvm perf, I think it's a no-brainer to just add it tonull_blkand not have a separate module.
As it is now, I prefer it part of null_blk, as long as it basically copy the core queueing structure. If null_nvm, we will have to maintain in two places. It'll be nice to keep it in one place.
The reason I would keep null_nvm, would be to add appropriate waiting times to simulate flash. However, I've now seen three implementations that utilized lightnvm for simulations, and it still doesn't scale to +1M IOPS that we need to actually compare it to a real device.