All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] null_blk patches for 4.4-rc2
@ 2015-11-19 11:50 Matias Bjørling
  2015-11-19 11:50 ` [PATCH 1/3] null_blk: use ppa_cache pool Matias Bjørling
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Matias Bjørling @ 2015-11-19 11:50 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

Hi Jens,

Please take a look at these three patches for 4.4-rc2.

The first patch uses a slab allocator for ppa list to only allocate the
necessary memory. As the linear addressing mode was removed, the second
patch changes the driver to use the ppa format adressing mode and at
last, the third patch fixes two bugs. One when freeing gendisk on unload
and another to pass a null pointer to lightnvm unregister function.

Feel free to fold them into the original null_blk patch.

Matias Bjørling (3):
  null_blk: use ppa_cache pool
  null_blk: use device addressing mode
  null_blk: do not del gendisk with lightnvm

 drivers/block/null_blk.c | 62 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 10 deletions(-)

-- 
2.1.4


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

* [PATCH 1/3] null_blk: use ppa_cache pool
  2015-11-19 11:50 [PATCH 0/3] null_blk patches for 4.4-rc2 Matias Bjørling
@ 2015-11-19 11:50 ` Matias Bjørling
  2015-11-19 11:50 ` [PATCH 2/3] null_blk: use device addressing mode Matias Bjørling
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Matias Bjørling @ 2015-11-19 11:50 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

Instead of using a page pool, we can save memory by only allocating room
for 64 entries for the ppa command. Introduce a ppa_cache to allocate only
the required memory for the ppa list.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/block/null_blk.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 8165251..173ba24 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -47,6 +47,7 @@ static LIST_HEAD(nullb_list);
 static struct mutex lock;
 static int null_major;
 static int nullb_indexes;
+static struct kmem_cache *ppa_cache;
 
 struct completion_queue {
 	struct llist_head list;
@@ -521,7 +522,7 @@ static void *null_lnvm_create_dma_pool(struct request_queue *q, char *name)
 {
 	mempool_t *virtmem_pool;
 
-	virtmem_pool = mempool_create_page_pool(64, 0);
+	virtmem_pool = mempool_create_slab_pool(64, ppa_cache);
 	if (!virtmem_pool) {
 		pr_err("null_blk: Unable to create virtual memory pool\n");
 		return NULL;
@@ -767,6 +768,12 @@ static int __init null_init(void)
 		bs = PAGE_SIZE;
 	}
 
+	if (use_lightnvm && bs != 4096) {
+		pr_warn("null_blk: LightNVM only supports 4k block size\n");
+		pr_warn("null_blk: defaults block size to 4k\n");
+		bs = 4096;
+	}
+
 	if (use_lightnvm && queue_mode != NULL_Q_MQ) {
 		pr_warn("null_blk: LightNVM only supported for blk-mq\n");
 		pr_warn("null_blk: defaults queue mode to blk-mq\n");
@@ -803,15 +810,27 @@ static int __init null_init(void)
 	if (null_major < 0)
 		return null_major;
 
+	if (use_lightnvm) {
+		ppa_cache = kmem_cache_create("ppa_cache", 64 * sizeof(u64),
+								0, 0, NULL);
+		if (!ppa_cache) {
+			pr_err("null_blk: unable to create ppa cache\n");
+			return -ENOMEM;
+		}
+	}
+
 	for (i = 0; i < nr_devices; i++) {
 		if (null_add_dev()) {
 			unregister_blkdev(null_major, "nullb");
-			return -EINVAL;
+			goto err_ppa;
 		}
 	}
 
 	pr_info("null: module loaded\n");
 	return 0;
+err_ppa:
+	kmem_cache_destroy(ppa_cache);
+	return -EINVAL;
 }
 
 static void __exit null_exit(void)
@@ -826,6 +845,9 @@ static void __exit null_exit(void)
 		null_del_dev(nullb);
 	}
 	mutex_unlock(&lock);
+
+	if (use_lightnvm)
+		kmem_cache_destroy(ppa_cache);
 }
 
 module_init(null_init);
-- 
2.1.4


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

* [PATCH 2/3] null_blk: use device addressing mode
  2015-11-19 11:50 [PATCH 0/3] null_blk patches for 4.4-rc2 Matias Bjørling
  2015-11-19 11:50 ` [PATCH 1/3] null_blk: use ppa_cache pool Matias Bjørling
@ 2015-11-19 11:50 ` Matias Bjørling
  2015-11-19 11:50 ` [PATCH 3/3] null_blk: do not del gendisk with lightnvm Matias Bjørling
  2015-11-19 20:06 ` [PATCH 0/3] null_blk patches for 4.4-rc2 Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Matias Bjørling @ 2015-11-19 11:50 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

The linear addressing mode was removed in 7386af2. Make null_blk instead
expose the ppa format geometry and support the generic addressing mode.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/block/null_blk.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 173ba24..6184b82 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -486,6 +486,7 @@ static int null_lnvm_submit_io(struct request_queue *q, struct nvm_rq *rqd)
 static int null_lnvm_id(struct request_queue *q, struct nvm_id *id)
 {
 	sector_t size = gb * 1024 * 1024 * 1024ULL;
+	sector_t blksize;
 	struct nvm_id_group *grp;
 
 	id->ver_id = 0x1;
@@ -493,17 +494,34 @@ static int null_lnvm_id(struct request_queue *q, struct nvm_id *id)
 	id->cgrps = 1;
 	id->cap = 0x3;
 	id->dom = 0x1;
-	id->ppat = NVM_ADDRMODE_LINEAR;
+
+	id->ppaf.blk_offset = 0;
+	id->ppaf.blk_len = 16;
+	id->ppaf.pg_offset = 16;
+	id->ppaf.pg_len = 16;
+	id->ppaf.sect_offset = 32;
+	id->ppaf.sect_len = 8;
+	id->ppaf.pln_offset = 40;
+	id->ppaf.pln_len = 8;
+	id->ppaf.lun_offset = 48;
+	id->ppaf.lun_len = 8;
+	id->ppaf.ch_offset = 56;
+	id->ppaf.ch_len = 8;
 
 	do_div(size, bs); /* convert size to pages */
+	do_div(size, 256); /* concert size to pgs pr blk */
 	grp = &id->groups[0];
 	grp->mtype = 0;
-	grp->fmtype = 1;
+	grp->fmtype = 0;
 	grp->num_ch = 1;
-	grp->num_lun = 1;
-	grp->num_pln = 1;
-	grp->num_blk = size / 256;
 	grp->num_pg = 256;
+	blksize = size;
+	do_div(size, (1 << 16));
+	grp->num_lun = size + 1;
+	do_div(blksize, grp->num_lun);
+	grp->num_blk = blksize;
+	grp->num_pln = 1;
+
 	grp->fpg_sz = bs;
 	grp->csecs = bs;
 	grp->trdt = 25000;
-- 
2.1.4


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

* [PATCH 3/3] null_blk: do not del gendisk with lightnvm
  2015-11-19 11:50 [PATCH 0/3] null_blk patches for 4.4-rc2 Matias Bjørling
  2015-11-19 11:50 ` [PATCH 1/3] null_blk: use ppa_cache pool Matias Bjørling
  2015-11-19 11:50 ` [PATCH 2/3] null_blk: use device addressing mode Matias Bjørling
@ 2015-11-19 11:50 ` Matias Bjørling
  2015-11-19 20:06 ` [PATCH 0/3] null_blk patches for 4.4-rc2 Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Matias Bjørling @ 2015-11-19 11:50 UTC (permalink / raw)
  To: linux-block, linux-kernel, axboe; +Cc: Matias Bjørling

The gendisk structure has not been initialized when using lightnvm.
Make sure to not delete it upon exit. Also make sure that we use the
appropriate disk_name at unregistration.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/block/null_blk.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 6184b82..fb70b54 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -435,12 +435,14 @@ static void null_del_dev(struct nullb *nullb)
 	list_del_init(&nullb->list);
 
 	if (use_lightnvm)
-		nvm_unregister(nullb->disk->disk_name);
-	del_gendisk(nullb->disk);
+		nvm_unregister(nullb->disk_name);
+	else
+		del_gendisk(nullb->disk);
 	blk_cleanup_queue(nullb->q);
 	if (queue_mode == NULL_Q_MQ)
 		blk_mq_free_tag_set(&nullb->tag_set);
-	put_disk(nullb->disk);
+	if (!use_lightnvm)
+		put_disk(nullb->disk);
 	cleanup_queues(nullb);
 	kfree(nullb);
 }
-- 
2.1.4


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

* Re: [PATCH 0/3] null_blk patches for 4.4-rc2
  2015-11-19 11:50 [PATCH 0/3] null_blk patches for 4.4-rc2 Matias Bjørling
                   ` (2 preceding siblings ...)
  2015-11-19 11:50 ` [PATCH 3/3] null_blk: do not del gendisk with lightnvm Matias Bjørling
@ 2015-11-19 20:06 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2015-11-19 20:06 UTC (permalink / raw)
  To: Matias Bjørling, linux-block, linux-kernel

On 11/19/2015 04:50 AM, Matias Bjørling wrote:
> Hi Jens,
>
> Please take a look at these three patches for 4.4-rc2.
>
> The first patch uses a slab allocator for ppa list to only allocate the
> necessary memory. As the linear addressing mode was removed, the second
> patch changes the driver to use the ppa format adressing mode and at
> last, the third patch fixes two bugs. One when freeing gendisk on unload
> and another to pass a null pointer to lightnvm unregister function.
>
> Feel free to fold them into the original null_blk patch.

I applied them separately for 4.4.

-- 
Jens Axboe


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

end of thread, other threads:[~2015-11-19 20:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-19 11:50 [PATCH 0/3] null_blk patches for 4.4-rc2 Matias Bjørling
2015-11-19 11:50 ` [PATCH 1/3] null_blk: use ppa_cache pool Matias Bjørling
2015-11-19 11:50 ` [PATCH 2/3] null_blk: use device addressing mode Matias Bjørling
2015-11-19 11:50 ` [PATCH 3/3] null_blk: do not del gendisk with lightnvm Matias Bjørling
2015-11-19 20:06 ` [PATCH 0/3] null_blk patches for 4.4-rc2 Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.