aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
authorHans Holmberg <hans.holmberg@cnexlabs.com>2018-03-29 18:04:52 -0400
committerJens Axboe <axboe@kernel.dk>2018-03-29 19:29:09 -0400
commit76758390f83e5abc3bfc776d793480836d17120c (patch)
treeaa385935b6f4359775c0f0abfa9f9d35b971b7ef /drivers/lightnvm/pblk-init.c
parentd0ab0b1ab991f48fc1fb579490df397d5f819913 (diff)
lightnvm: pblk: export write amplification counters to sysfs
In a SSD, write amplification, WA, is defined as the average number of page writes per user page write. Write amplification negatively affects write performance and decreases the lifetime of the disk, so it's a useful metric to add to sysfs. In plkb's case, the number of writes per user sector is the sum of: (1) number of user writes (2) number of sectors written by the garbage collector (3) number of sectors padded (i.e. due to syncs) This patch adds persistent counters for 1-3 and two sysfs attributes to export these along with WA calculated with five decimals: write_amp_mileage: the accumulated write amplification stats for the lifetime of the pblk instance write_amp_trip: resetable stats to facilitate delta measurements, values reset at creation and if 0 is written to the attribute. 64-bit counters are used as a 32 bit counter would wrap around already after about 17 TB worth of user data. It will take a long long time before the 64 bit sector counters wrap around. The counters are stored after the bad block bitmap in the first emeta sector of each written line. There is plenty of space in the first emeta sector, so we don't need to bump the major version of the line data format. Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com> Signed-off-by: Javier González <javier@cnexlabs.com> 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.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 5b46924ac66c..0ffc17ccf1cc 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -559,8 +559,8 @@ static unsigned int calc_emeta_len(struct pblk *pblk)
559 559
560 /* Round to sector size so that lba_list starts on its own sector */ 560 /* Round to sector size so that lba_list starts on its own sector */
561 lm->emeta_sec[1] = DIV_ROUND_UP( 561 lm->emeta_sec[1] = DIV_ROUND_UP(
562 sizeof(struct line_emeta) + lm->blk_bitmap_len, 562 sizeof(struct line_emeta) + lm->blk_bitmap_len +
563 geo->sec_size); 563 sizeof(struct wa_counters), geo->sec_size);
564 lm->emeta_len[1] = lm->emeta_sec[1] * geo->sec_size; 564 lm->emeta_len[1] = lm->emeta_sec[1] * geo->sec_size;
565 565
566 /* Round to sector size so that vsc_list starts on its own sector */ 566 /* Round to sector size so that vsc_list starts on its own sector */
@@ -991,6 +991,13 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
991 if (flags & NVM_TARGET_FACTORY) 991 if (flags & NVM_TARGET_FACTORY)
992 pblk_setup_uuid(pblk); 992 pblk_setup_uuid(pblk);
993 993
994 atomic64_set(&pblk->user_wa, 0);
995 atomic64_set(&pblk->pad_wa, 0);
996 atomic64_set(&pblk->gc_wa, 0);
997 pblk->user_rst_wa = 0;
998 pblk->pad_rst_wa = 0;
999 pblk->gc_rst_wa = 0;
1000
994#ifdef CONFIG_NVM_DEBUG 1001#ifdef CONFIG_NVM_DEBUG
995 atomic_long_set(&pblk->inflight_writes, 0); 1002 atomic_long_set(&pblk->inflight_writes, 0);
996 atomic_long_set(&pblk->padded_writes, 0); 1003 atomic_long_set(&pblk->padded_writes, 0);