aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
authorHans Holmberg <hans.holmberg@cnexlabs.com>2018-03-29 18:04:55 -0400
committerJens Axboe <axboe@kernel.dk>2018-03-29 19:29:09 -0400
commit5d149bfabeb889b7ee5cd6491bc6d2b5b20c4abd (patch)
tree03398b6d423681651a0181463912056226af68c8 /drivers/lightnvm/pblk-init.c
parentff12581ec702d6c4607f614107d4816c21c6be56 (diff)
lightnvm: pblk: add padding distribution sysfs attribute
When pblk receives a sync, all data up to that point in the write buffer must be comitted to persistent storage, and as flash memory comes with a minimal write size there is a significant cost involved both in terms of time for completing the sync and in terms of write amplification padded sectors for filling up to the minimal write size. In order to get a better understanding of the costs involved for syncs, Add a sysfs attribute to pblk: padded_dist, showing a normalized distribution of sectors padded. In order to facilitate measurements of specific workloads during the lifetime of the pblk instance, the distribution can be reset by writing 0 to the attribute. Do this by introducing counters for each possible padding: {0..(minimal write size - 1)} and calculate the normalized distribution when showing the attribute. Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com> Signed-off-by: Javier González <javier@cnexlabs.com> Rearranged total_buckets statement in pblk_sysfs_get_padding_dist Signed-off-by: Matias Bjørling <mb@lightnvm.io> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 0ffc17ccf1cc..8416910ee8bf 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -921,6 +921,7 @@ static void pblk_free(struct pblk *pblk)
921{ 921{
922 pblk_luns_free(pblk); 922 pblk_luns_free(pblk);
923 pblk_lines_free(pblk); 923 pblk_lines_free(pblk);
924 kfree(pblk->pad_dist);
924 pblk_line_meta_free(pblk); 925 pblk_line_meta_free(pblk);
925 pblk_core_free(pblk); 926 pblk_core_free(pblk);
926 pblk_l2p_free(pblk); 927 pblk_l2p_free(pblk);
@@ -998,11 +999,13 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
998 pblk->pad_rst_wa = 0; 999 pblk->pad_rst_wa = 0;
999 pblk->gc_rst_wa = 0; 1000 pblk->gc_rst_wa = 0;
1000 1001
1002 atomic64_set(&pblk->nr_flush, 0);
1003 pblk->nr_flush_rst = 0;
1004
1001#ifdef CONFIG_NVM_DEBUG 1005#ifdef CONFIG_NVM_DEBUG
1002 atomic_long_set(&pblk->inflight_writes, 0); 1006 atomic_long_set(&pblk->inflight_writes, 0);
1003 atomic_long_set(&pblk->padded_writes, 0); 1007 atomic_long_set(&pblk->padded_writes, 0);
1004 atomic_long_set(&pblk->padded_wb, 0); 1008 atomic_long_set(&pblk->padded_wb, 0);
1005 atomic_long_set(&pblk->nr_flush, 0);
1006 atomic_long_set(&pblk->req_writes, 0); 1009 atomic_long_set(&pblk->req_writes, 0);
1007 atomic_long_set(&pblk->sub_writes, 0); 1010 atomic_long_set(&pblk->sub_writes, 0);
1008 atomic_long_set(&pblk->sync_writes, 0); 1011 atomic_long_set(&pblk->sync_writes, 0);
@@ -1034,10 +1037,17 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1034 goto fail_free_luns; 1037 goto fail_free_luns;
1035 } 1038 }
1036 1039
1040 pblk->pad_dist = kzalloc((pblk->min_write_pgs - 1) * sizeof(atomic64_t),
1041 GFP_KERNEL);
1042 if (!pblk->pad_dist) {
1043 ret = -ENOMEM;
1044 goto fail_free_line_meta;
1045 }
1046
1037 ret = pblk_core_init(pblk); 1047 ret = pblk_core_init(pblk);
1038 if (ret) { 1048 if (ret) {
1039 pr_err("pblk: could not initialize core\n"); 1049 pr_err("pblk: could not initialize core\n");
1040 goto fail_free_line_meta; 1050 goto fail_free_pad_dist;
1041 } 1051 }
1042 1052
1043 ret = pblk_l2p_init(pblk); 1053 ret = pblk_l2p_init(pblk);
@@ -1097,6 +1107,8 @@ fail_free_l2p:
1097 pblk_l2p_free(pblk); 1107 pblk_l2p_free(pblk);
1098fail_free_core: 1108fail_free_core:
1099 pblk_core_free(pblk); 1109 pblk_core_free(pblk);
1110fail_free_pad_dist:
1111 kfree(pblk->pad_dist);
1100fail_free_line_meta: 1112fail_free_line_meta:
1101 pblk_line_meta_free(pblk); 1113 pblk_line_meta_free(pblk);
1102fail_free_luns: 1114fail_free_luns: