Skip to content

Commit

Permalink
lightnvm: pblk: set mempool and workqueue params.
Browse files Browse the repository at this point in the history
Make constants to define sizes for internal mempools and workqueues. In
this process, adjust the values to be more meaningful given the internal
constrains of the FTL. In order to do this for workqueues, separate the
current auxiliary workqueue into two dedicated workqueues to manage
lines being closed and bad blocks.

Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Javier González authored and Jens Axboe committed Jun 26, 2017
1 parent b20ba1b commit ef57649
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
7 changes: 4 additions & 3 deletions drivers/lightnvm/pblk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void pblk_mark_bb(struct pblk *pblk, struct pblk_line *line,
pr_err("pblk: attempted to erase bb: line:%d, pos:%d\n",
line->id, pos);

pblk_line_run_ws(pblk, NULL, ppa, pblk_line_mark_bb);
pblk_line_run_ws(pblk, NULL, ppa, pblk_line_mark_bb, pblk->bb_wq);
}

static void __pblk_end_io_erase(struct pblk *pblk, struct nvm_rq *rqd)
Expand Down Expand Up @@ -1528,7 +1528,8 @@ void pblk_line_mark_bb(struct work_struct *work)
}

void pblk_line_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
void (*work)(struct work_struct *))
void (*work)(struct work_struct *),
struct workqueue_struct *wq)
{
struct pblk_line_ws *line_ws;

Expand All @@ -1541,7 +1542,7 @@ void pblk_line_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
line_ws->priv = priv;

INIT_WORK(&line_ws->ws, work);
queue_work(pblk->kw_wq, &line_ws->ws);
queue_work(wq, &line_ws->ws);
}

void pblk_down_rq(struct pblk *pblk, struct ppa_addr *ppa_list, int nr_ppas,
Expand Down
39 changes: 26 additions & 13 deletions drivers/lightnvm/pblk-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static int pblk_core_init(struct pblk *pblk)
if (!pblk->page_pool)
return -ENOMEM;

pblk->line_ws_pool = mempool_create_slab_pool(geo->nr_luns,
pblk->line_ws_pool = mempool_create_slab_pool(PBLK_WS_POOL_SIZE,
pblk_blk_ws_cache);
if (!pblk->line_ws_pool)
goto free_page_pool;
Expand All @@ -260,35 +260,45 @@ static int pblk_core_init(struct pblk *pblk)
if (!pblk->rec_pool)
goto free_blk_ws_pool;

pblk->g_rq_pool = mempool_create_slab_pool(64, pblk_g_rq_cache);
pblk->g_rq_pool = mempool_create_slab_pool(PBLK_READ_REQ_POOL_SIZE,
pblk_g_rq_cache);
if (!pblk->g_rq_pool)
goto free_rec_pool;

pblk->w_rq_pool = mempool_create_slab_pool(64, pblk_w_rq_cache);
pblk->w_rq_pool = mempool_create_slab_pool(geo->nr_luns * 2,
pblk_w_rq_cache);
if (!pblk->w_rq_pool)
goto free_g_rq_pool;

pblk->line_meta_pool =
mempool_create_slab_pool(16, pblk_line_meta_cache);
mempool_create_slab_pool(PBLK_META_POOL_SIZE,
pblk_line_meta_cache);
if (!pblk->line_meta_pool)
goto free_w_rq_pool;

pblk->kw_wq = alloc_workqueue("pblk-aux-wq",
WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
if (!pblk->kw_wq)
pblk->close_wq = alloc_workqueue("pblk-close-wq",
WQ_MEM_RECLAIM | WQ_UNBOUND, PBLK_NR_CLOSE_JOBS);
if (!pblk->close_wq)
goto free_line_meta_pool;

pblk->bb_wq = alloc_workqueue("pblk-bb-wq",
WQ_MEM_RECLAIM | WQ_UNBOUND, 0);
if (!pblk->bb_wq)
goto free_close_wq;

if (pblk_set_ppaf(pblk))
goto free_kw_wq;
goto free_bb_wq;

if (pblk_rwb_init(pblk))
goto free_kw_wq;
goto free_bb_wq;

INIT_LIST_HEAD(&pblk->compl_list);
return 0;

free_kw_wq:
destroy_workqueue(pblk->kw_wq);
free_bb_wq:
destroy_workqueue(pblk->bb_wq);
free_close_wq:
destroy_workqueue(pblk->close_wq);
free_line_meta_pool:
mempool_destroy(pblk->line_meta_pool);
free_w_rq_pool:
Expand All @@ -306,8 +316,11 @@ static int pblk_core_init(struct pblk *pblk)

static void pblk_core_free(struct pblk *pblk)
{
if (pblk->kw_wq)
destroy_workqueue(pblk->kw_wq);
if (pblk->close_wq)
destroy_workqueue(pblk->close_wq);

if (pblk->bb_wq)
destroy_workqueue(pblk->bb_wq);

mempool_destroy(pblk->page_pool);
mempool_destroy(pblk->line_ws_pool);
Expand Down
5 changes: 3 additions & 2 deletions drivers/lightnvm/pblk-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
}

INIT_WORK(&recovery->ws_rec, pblk_submit_rec);
queue_work(pblk->kw_wq, &recovery->ws_rec);
queue_work(pblk->close_wq, &recovery->ws_rec);

out:
pblk_complete_write(pblk, rqd, c_ctx);
Expand Down Expand Up @@ -198,7 +198,8 @@ static void pblk_end_io_write_meta(struct nvm_rq *rqd)

sync = atomic_add_return(rqd->nr_ppas, &emeta->sync);
if (sync == emeta->nr_entries)
pblk_line_run_ws(pblk, line, NULL, pblk_line_close_ws);
pblk_line_run_ws(pblk, line, NULL, pblk_line_close_ws,
pblk->close_wq);

bio_put(rqd->bio);
pblk_free_rqd(pblk, rqd, READ);
Expand Down
13 changes: 11 additions & 2 deletions drivers/lightnvm/pblk.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#define PBLK_MAX_REQ_ADDRS (64)
#define PBLK_MAX_REQ_ADDRS_PW (6)

#define PBLK_WS_POOL_SIZE (128)
#define PBLK_META_POOL_SIZE (128)
#define PBLK_READ_REQ_POOL_SIZE (1024)

#define PBLK_NR_CLOSE_JOBS (4)

#define PBLK_CACHE_NAME_LEN (DISK_NAME_LEN + 16)

#define PBLK_COMMAND_TIMEOUT_MS 30000
Expand Down Expand Up @@ -599,7 +605,9 @@ struct pblk {
mempool_t *w_rq_pool;
mempool_t *line_meta_pool;

struct workqueue_struct *kw_wq;
struct workqueue_struct *close_wq;
struct workqueue_struct *bb_wq;

struct timer_list wtimer;

struct pblk_gc gc;
Expand Down Expand Up @@ -692,7 +700,8 @@ void pblk_line_close(struct pblk *pblk, struct pblk_line *line);
void pblk_line_close_ws(struct work_struct *work);
void pblk_line_mark_bb(struct work_struct *work);
void pblk_line_run_ws(struct pblk *pblk, struct pblk_line *line, void *priv,
void (*work)(struct work_struct *));
void (*work)(struct work_struct *),
struct workqueue_struct *wq);
u64 pblk_line_smeta_start(struct pblk *pblk, struct pblk_line *line);
int pblk_line_read_smeta(struct pblk *pblk, struct pblk_line *line);
int pblk_line_read_emeta(struct pblk *pblk, struct pblk_line *line,
Expand Down

0 comments on commit ef57649

Please sign in to comment.