* [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs
@ 2024-10-11 9:21 Rickard Andersson
2024-10-11 9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
` (9 more replies)
0 siblings, 10 replies; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Currently, only "max_ec" can be read from sysfs, which provides a
limited view of the flash device’s wear. In certain cases, such as
bugs in the wear-leveling algorithm, specific blocks can be worn down
more than others, resulting in uneven wear distribution. Providing a
mean erase counter value gives a better understanding of the overall
flash wear.
There exists more detailed info in debugfs, but this information is
only available for debug builds.
This patch calculates the mean value only when it is requested. This
calculation typically takes 2.7 ms for an UBI device with 4091 blocks
running on a single core Cortex-A9 at 792 MHz.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
drivers/mtd/ubi/build.c | 48 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index f5140a78a4a8..fa38c434e447 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -131,6 +131,8 @@ static struct device_attribute dev_volumes_count =
__ATTR(volumes_count, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_max_ec =
__ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
+static struct device_attribute dev_mean_ec =
+ __ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_reserved_for_bad =
__ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_bad_peb_count =
@@ -337,6 +339,49 @@ int ubi_major2num(int major)
return ubi_num;
}
+/**
+ * ubi_calc_mean_ec - calculate mean erase counter value.
+ * @ubi: UBI device description object
+ * @start_peb: First PEB in the range
+ * @end_peb: End PEB in the half-open range
+ *
+ * Returns the mean value of all non-bad blocks of the device that are
+ * in the range. Range is half-open i.e end_peb is not actually included.
+ *
+ * Returns zero if it was not possible to calculate the mean value
+ */
+static int ubi_calc_mean_ec(struct ubi_device *ubi, int start_peb, int end_peb)
+{
+ struct ubi_wl_entry *wl;
+ int peb;
+ int ec_count = 0;
+ int mean_ec = 0;
+ uint64_t ec_sum = 0;
+
+ for (peb = start_peb; peb < end_peb; peb++) {
+ int err;
+
+ err = ubi_io_is_bad(ubi, peb);
+ if (err)
+ continue;
+
+ spin_lock(&ubi->wl_lock);
+
+ wl = ubi->lookuptbl[peb];
+ if (wl) {
+ ec_sum += wl->ec;
+ ec_count++;
+ }
+
+ spin_unlock(&ubi->wl_lock);
+ }
+
+ if (ec_count > 0)
+ mean_ec = div_u64(ec_sum, ec_count);
+
+ return mean_ec;
+}
+
/* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
static ssize_t dev_attribute_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -366,6 +411,8 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi->vol_count - UBI_INT_VOL_COUNT);
else if (attr == &dev_max_ec)
ret = sprintf(buf, "%d\n", ubi->max_ec);
+ else if (attr == &dev_mean_ec)
+ ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
else if (attr == &dev_reserved_for_bad)
ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
else if (attr == &dev_bad_peb_count)
@@ -392,6 +439,7 @@ static struct attribute *ubi_dev_attrs[] = {
&dev_total_eraseblocks.attr,
&dev_volumes_count.attr,
&dev_max_ec.attr,
+ &dev_mean_ec.attr,
&dev_reserved_for_bad.attr,
&dev_bad_peb_count.attr,
&dev_max_vol_count.attr,
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap in sysfs
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:02 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 03/10] ubi: Expose max " Rickard Andersson
` (8 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Since the fastmap area has its own wear levelling it is valuable to
provide a mean value for that area. This value can be used in order
to estimate life expectancy of the flash.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
drivers/mtd/ubi/build.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index fa38c434e447..3633c743e7d1 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -133,6 +133,10 @@ static struct device_attribute dev_max_ec =
__ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mean_ec =
__ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
+#ifdef CONFIG_MTD_UBI_FASTMAP
+static struct device_attribute dev_mean_ec_fastmap =
+ __ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
+#endif
static struct device_attribute dev_reserved_for_bad =
__ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_bad_peb_count =
@@ -413,6 +417,10 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi->max_ec);
else if (attr == &dev_mean_ec)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
+#ifdef CONFIG_MTD_UBI_FASTMAP
+ else if (attr == &dev_mean_ec_fastmap)
+ ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
+#endif
else if (attr == &dev_reserved_for_bad)
ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
else if (attr == &dev_bad_peb_count)
@@ -440,6 +448,9 @@ static struct attribute *ubi_dev_attrs[] = {
&dev_volumes_count.attr,
&dev_max_ec.attr,
&dev_mean_ec.attr,
+#ifdef CONFIG_MTD_UBI_FASTMAP
+ &dev_mean_ec_fastmap.attr,
+#endif
&dev_reserved_for_bad.attr,
&dev_bad_peb_count.attr,
&dev_max_vol_count.attr,
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 03/10] ubi: Expose max erase counter for fastmap in sysfs
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
2024-10-11 9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:03 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 04/10] ubi: Expose mean erase counter for data " Rickard Andersson
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Since the fastmap area has its own wear levelling it is valuable to
provide a max erase counter value specifically for that area.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
drivers/mtd/ubi/build.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 3633c743e7d1..f5a3a3f7d490 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -134,6 +134,8 @@ static struct device_attribute dev_max_ec =
static struct device_attribute dev_mean_ec =
__ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
#ifdef CONFIG_MTD_UBI_FASTMAP
+static struct device_attribute dev_max_ec_fastmap =
+ __ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mean_ec_fastmap =
__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
#endif
@@ -386,6 +388,45 @@ static int ubi_calc_mean_ec(struct ubi_device *ubi, int start_peb, int end_peb)
return mean_ec;
}
+/**
+ * ubi_calc_max_ec_fastmap - calculate max erase counter value.
+ * @ubi: UBI device description object
+ * @start_peb: First PEB in the range
+ * @end_peb: End PEB in the half-open range
+ *
+ * Returns the max erase counter value that can be found in the range.
+ * Range is half-open i.e end_peb is not actually included.
+ * Returns zero if it was not possible to calculate the max ec value
+ */
+#ifdef CONFIG_MTD_UBI_FASTMAP
+static int ubi_calc_max_ec(struct ubi_device *ubi, int start_peb, int end_peb)
+{
+ struct ubi_wl_entry *wl;
+ int peb;
+ int max_ec = 0;
+
+ for (peb = start_peb; peb < end_peb; peb++) {
+ int err;
+
+ err = ubi_io_is_bad(ubi, peb);
+ if (err)
+ continue;
+
+ spin_lock(&ubi->wl_lock);
+
+ wl = ubi->lookuptbl[peb];
+ if (wl) {
+ if (max_ec < wl->ec)
+ max_ec = wl->ec;
+ }
+
+ spin_unlock(&ubi->wl_lock);
+ }
+
+ return max_ec;
+}
+#endif
+
/* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
static ssize_t dev_attribute_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -418,6 +459,8 @@ static ssize_t dev_attribute_show(struct device *dev,
else if (attr == &dev_mean_ec)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
#ifdef CONFIG_MTD_UBI_FASTMAP
+ else if (attr == &dev_max_ec_fastmap)
+ ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
else if (attr == &dev_mean_ec_fastmap)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
#endif
@@ -449,6 +492,7 @@ static struct attribute *ubi_dev_attrs[] = {
&dev_max_ec.attr,
&dev_mean_ec.attr,
#ifdef CONFIG_MTD_UBI_FASTMAP
+ &dev_max_ec_fastmap.attr,
&dev_mean_ec_fastmap.attr,
#endif
&dev_reserved_for_bad.attr,
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 04/10] ubi: Expose mean erase counter for data in sysfs
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
2024-10-11 9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
2024-10-11 9:21 ` [PATCH v2 03/10] ubi: Expose max " Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:04 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 05/10] ubi: Expose max " Rickard Andersson
` (6 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Expose mean erase counter for data area in sysfs. Data area includes
all blocks except for the fastmap area.
This value can be used in order to estimate life expectancy of the
flash.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
drivers/mtd/ubi/build.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index f5a3a3f7d490..b253dcf849c7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -138,6 +138,8 @@ static struct device_attribute dev_max_ec_fastmap =
__ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mean_ec_fastmap =
__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
+static struct device_attribute dev_mean_ec_data =
+ __ATTR(mean_ec_data, S_IRUGO, dev_attribute_show, NULL);
#endif
static struct device_attribute dev_reserved_for_bad =
__ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
@@ -463,6 +465,8 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
else if (attr == &dev_mean_ec_fastmap)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
+ else if (attr == &dev_mean_ec_data)
+ ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
#endif
else if (attr == &dev_reserved_for_bad)
ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
@@ -494,6 +498,7 @@ static struct attribute *ubi_dev_attrs[] = {
#ifdef CONFIG_MTD_UBI_FASTMAP
&dev_max_ec_fastmap.attr,
&dev_mean_ec_fastmap.attr,
+ &dev_mean_ec_data.attr,
#endif
&dev_reserved_for_bad.attr,
&dev_bad_peb_count.attr,
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 05/10] ubi: Expose max erase counter for data in sysfs
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (2 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 04/10] ubi: Expose mean erase counter for data " Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:04 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute Rickard Andersson
` (5 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Expose max erase counter for data area in sysfs. Data area includes
all blocks except for the fastmap area.
This value can be used in order to estimate life expectancy of the
flash.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
drivers/mtd/ubi/build.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index b253dcf849c7..f3649afbc777 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -138,6 +138,8 @@ static struct device_attribute dev_max_ec_fastmap =
__ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mean_ec_fastmap =
__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
+static struct device_attribute dev_max_ec_data =
+ __ATTR(max_ec_data, S_IRUGO, dev_attribute_show, NULL);
static struct device_attribute dev_mean_ec_data =
__ATTR(mean_ec_data, S_IRUGO, dev_attribute_show, NULL);
#endif
@@ -465,6 +467,8 @@ static ssize_t dev_attribute_show(struct device *dev,
ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
else if (attr == &dev_mean_ec_fastmap)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
+ else if (attr == &dev_max_ec_data)
+ ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
else if (attr == &dev_mean_ec_data)
ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
#endif
@@ -498,6 +502,7 @@ static struct attribute *ubi_dev_attrs[] = {
#ifdef CONFIG_MTD_UBI_FASTMAP
&dev_max_ec_fastmap.attr,
&dev_mean_ec_fastmap.attr,
+ &dev_max_ec_data.attr,
&dev_mean_ec_data.attr,
#endif
&dev_reserved_for_bad.attr,
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (3 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 05/10] ubi: Expose max " Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area Rickard Andersson
` (4 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
A mean erase counter gives a better understanding of the flash
wear.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index a6b324014692..535a3e6dab12 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -219,3 +219,10 @@ Description:
Logical eraseblock size of this volume. Equivalent to logical
eraseblock size of the device aligned on the volume alignment
value.
+
+What: /sys/class/ubi/ubiX/mean_ec
+Date: October 2024
+KernelVersion: 6.X
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Mean physical eraseblock erase counter value.
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (4 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 08/10] ubi: Add max " Rickard Andersson
` (3 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
A mean erase counter gives a better understanding of the flash
wear of the fastmap area.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index 535a3e6dab12..05a701b03a9a 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -226,3 +226,11 @@ KernelVersion: 6.X
Contact: linux-mtd@lists.infradead.org
Description:
Mean physical eraseblock erase counter value.
+
+What: /sys/class/ubi/ubiX/mean_ec_fastmap
+Date: October 2024
+KernelVersion: 6.X
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Mean physical eraseblock erase counter value for the fastmap
+ area.
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 08/10] ubi: Add max erase counter sysfs attribute for fastmap area
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (5 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area Rickard Andersson
` (2 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
A max erase counter specifically for the fastmap area gives a better
understanding of the flash wear.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index 05a701b03a9a..62c93fda0bc4 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -78,6 +78,14 @@ Contact: Artem Bityutskiy <dedekind@infradead.org>
Description:
Maximum physical eraseblock erase counter value.
+What: /sys/class/ubi/ubiX/max_ec_fastmap
+Date: October 2024
+KernelVersion: 6.X
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Maximum physical eraseblock erase counter value for a block
+ in the fastmap area.
+
What: /sys/class/ubi/ubiX/max_vol_count
Date: July 2006
KernelVersion: 2.6.22
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (6 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 08/10] ubi: Add max " Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:08 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 10/10] ubi: Add max " Rickard Andersson
2024-10-11 12:01 ` [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Zhihao Cheng
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Data area includes all blocks except for the fastmap area.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index 62c93fda0bc4..100e1c0698a3 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -242,3 +242,11 @@ Contact: linux-mtd@lists.infradead.org
Description:
Mean physical eraseblock erase counter value for the fastmap
area.
+
+What: /sys/class/ubi/ubiX/mean_ec_data
+Date: October 2024
+KernelVersion: 6.X
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Mean physical eraseblock erase counter value for data area.
+ Data area includes all blocks except for the fastmap area.
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 10/10] ubi: Add max erase counter sysfs attribute for data area
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (7 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area Rickard Andersson
@ 2024-10-11 9:21 ` Rickard Andersson
2024-10-11 12:08 ` Zhihao Cheng
2024-10-11 12:01 ` [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Zhihao Cheng
9 siblings, 1 reply; 20+ messages in thread
From: Rickard Andersson @ 2024-10-11 9:21 UTC (permalink / raw)
To: richard, chengzhihao1, linux-mtd, rickard314.andersson
Cc: rickard.andersson, kernel
Data area includes all blocks except for the fastmap area.
Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
index 100e1c0698a3..ff453557b0db 100644
--- a/Documentation/ABI/stable/sysfs-class-ubi
+++ b/Documentation/ABI/stable/sysfs-class-ubi
@@ -86,6 +86,14 @@ Description:
Maximum physical eraseblock erase counter value for a block
in the fastmap area.
+What: /sys/class/ubi/ubiX/max_ec_data
+Date: October 2024
+KernelVersion: 6.X
+Contact: linux-mtd@lists.infradead.org
+Description:
+ Max physical eraseblock erase counter value for data area.
+ Data area includes all blocks except for the fastmap area.
+
What: /sys/class/ubi/ubiX/max_vol_count
Date: July 2006
KernelVersion: 2.6.22
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
` (8 preceding siblings ...)
2024-10-11 9:21 ` [PATCH v2 10/10] ubi: Add max " Rickard Andersson
@ 2024-10-11 12:01 ` Zhihao Cheng
9 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:01 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Currently, only "max_ec" can be read from sysfs, which provides a
> limited view of the flash device’s wear. In certain cases, such as
> bugs in the wear-leveling algorithm, specific blocks can be worn down
> more than others, resulting in uneven wear distribution. Providing a
> mean erase counter value gives a better understanding of the overall
> flash wear.
> There exists more detailed info in debugfs, but this information is
> only available for debug builds.
>
> This patch calculates the mean value only when it is requested. This
> calculation typically takes 2.7 ms for an UBI device with 4091 blocks
> running on a single core Cortex-A9 at 792 MHz.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> drivers/mtd/ubi/build.c | 48 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index f5140a78a4a8..fa38c434e447 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -131,6 +131,8 @@ static struct device_attribute dev_volumes_count =
> __ATTR(volumes_count, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_max_ec =
> __ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
> +static struct device_attribute dev_mean_ec =
> + __ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_reserved_for_bad =
> __ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_bad_peb_count =
> @@ -337,6 +339,49 @@ int ubi_major2num(int major)
> return ubi_num;
> }
>
> +/**
> + * ubi_calc_mean_ec - calculate mean erase counter value.
> + * @ubi: UBI device description object
> + * @start_peb: First PEB in the range
> + * @end_peb: End PEB in the half-open range
> + *
> + * Returns the mean value of all non-bad blocks of the device that are
> + * in the range. Range is half-open i.e end_peb is not actually included.
> + *
> + * Returns zero if it was not possible to calculate the mean value
Delete this line from the comments, since zero is a normal value if all
PEBs' erase counter is initialized as '0' by ubiformat tool.
> + */
> +static int ubi_calc_mean_ec(struct ubi_device *ubi, int start_peb, int end_peb)
> +{
> + struct ubi_wl_entry *wl;
> + int peb;
> + int ec_count = 0;
> + int mean_ec = 0;
> + uint64_t ec_sum = 0;
> +
> + for (peb = start_peb; peb < end_peb; peb++) {
> + int err;
> +
> + err = ubi_io_is_bad(ubi, peb);
> + if (err)
> + continue;
> +
> + spin_lock(&ubi->wl_lock);
> +
> + wl = ubi->lookuptbl[peb];
> + if (wl) {
> + ec_sum += wl->ec;
> + ec_count++;
> + }
> +
> + spin_unlock(&ubi->wl_lock);
> + }
> +
> + if (ec_count > 0)
> + mean_ec = div_u64(ec_sum, ec_count);
> +
> + return mean_ec;
> +}
> +
> /* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
> static ssize_t dev_attribute_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> @@ -366,6 +411,8 @@ static ssize_t dev_attribute_show(struct device *dev,
> ret = sprintf(buf, "%d\n", ubi->vol_count - UBI_INT_VOL_COUNT);
> else if (attr == &dev_max_ec)
> ret = sprintf(buf, "%d\n", ubi->max_ec);
> + else if (attr == &dev_mean_ec)
> + ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
> else if (attr == &dev_reserved_for_bad)
> ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
> else if (attr == &dev_bad_peb_count)
> @@ -392,6 +439,7 @@ static struct attribute *ubi_dev_attrs[] = {
> &dev_total_eraseblocks.attr,
> &dev_volumes_count.attr,
> &dev_max_ec.attr,
> + &dev_mean_ec.attr,
> &dev_reserved_for_bad.attr,
> &dev_bad_peb_count.attr,
> &dev_max_vol_count.attr,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap in sysfs
2024-10-11 9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
@ 2024-10-11 12:02 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:02 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Since the fastmap area has its own wear levelling it is valuable to
> provide a mean value for that area. This value can be used in order
> to estimate life expectancy of the flash.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> drivers/mtd/ubi/build.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index fa38c434e447..3633c743e7d1 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -133,6 +133,10 @@ static struct device_attribute dev_max_ec =
> __ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_mean_ec =
> __ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> +static struct device_attribute dev_mean_ec_fastmap =
> + __ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> +#endif
> static struct device_attribute dev_reserved_for_bad =
> __ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_bad_peb_count =
> @@ -413,6 +417,10 @@ static ssize_t dev_attribute_show(struct device *dev,
> ret = sprintf(buf, "%d\n", ubi->max_ec);
> else if (attr == &dev_mean_ec)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> + else if (attr == &dev_mean_ec_fastmap)
> + ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
> +#endif
> else if (attr == &dev_reserved_for_bad)
> ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
> else if (attr == &dev_bad_peb_count)
> @@ -440,6 +448,9 @@ static struct attribute *ubi_dev_attrs[] = {
> &dev_volumes_count.attr,
> &dev_max_ec.attr,
> &dev_mean_ec.attr,
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> + &dev_mean_ec_fastmap.attr,
> +#endif
> &dev_reserved_for_bad.attr,
> &dev_bad_peb_count.attr,
> &dev_max_vol_count.attr,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 03/10] ubi: Expose max erase counter for fastmap in sysfs
2024-10-11 9:21 ` [PATCH v2 03/10] ubi: Expose max " Rickard Andersson
@ 2024-10-11 12:03 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:03 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Since the fastmap area has its own wear levelling it is valuable to
> provide a max erase counter value specifically for that area.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> drivers/mtd/ubi/build.c | 44 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 3633c743e7d1..f5a3a3f7d490 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -134,6 +134,8 @@ static struct device_attribute dev_max_ec =
> static struct device_attribute dev_mean_ec =
> __ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
> #ifdef CONFIG_MTD_UBI_FASTMAP
> +static struct device_attribute dev_max_ec_fastmap =
> + __ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_mean_ec_fastmap =
> __ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> #endif
> @@ -386,6 +388,45 @@ static int ubi_calc_mean_ec(struct ubi_device *ubi, int start_peb, int end_peb)
> return mean_ec;
> }
>
> +/**
> + * ubi_calc_max_ec_fastmap - calculate max erase counter value.
> + * @ubi: UBI device description object
> + * @start_peb: First PEB in the range
> + * @end_peb: End PEB in the half-open range
> + *
> + * Returns the max erase counter value that can be found in the range.
> + * Range is half-open i.e end_peb is not actually included.
> + * Returns zero if it was not possible to calculate the max ec value
Delete this line from the comments, since zero is a normal value if all
PEBs' erase counter is initialized as '0' by ubiformat tool.
> + */
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> +static int ubi_calc_max_ec(struct ubi_device *ubi, int start_peb, int end_peb)
> +{
> + struct ubi_wl_entry *wl;
> + int peb;
> + int max_ec = 0;
> +
> + for (peb = start_peb; peb < end_peb; peb++) {
> + int err;
> +
> + err = ubi_io_is_bad(ubi, peb);
> + if (err)
> + continue;
> +
> + spin_lock(&ubi->wl_lock);
> +
> + wl = ubi->lookuptbl[peb];
> + if (wl) {
> + if (max_ec < wl->ec)
> + max_ec = wl->ec;
> + }
> +
> + spin_unlock(&ubi->wl_lock);
> + }
> +
> + return max_ec;
> +}
> +#endif
> +
> /* "Show" method for files in '/<sysfs>/class/ubi/ubiX/' */
> static ssize_t dev_attribute_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> @@ -418,6 +459,8 @@ static ssize_t dev_attribute_show(struct device *dev,
> else if (attr == &dev_mean_ec)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
> #ifdef CONFIG_MTD_UBI_FASTMAP
> + else if (attr == &dev_max_ec_fastmap)
> + ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
> else if (attr == &dev_mean_ec_fastmap)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
> #endif
> @@ -449,6 +492,7 @@ static struct attribute *ubi_dev_attrs[] = {
> &dev_max_ec.attr,
> &dev_mean_ec.attr,
> #ifdef CONFIG_MTD_UBI_FASTMAP
> + &dev_max_ec_fastmap.attr,
> &dev_mean_ec_fastmap.attr,
> #endif
> &dev_reserved_for_bad.attr,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 04/10] ubi: Expose mean erase counter for data in sysfs
2024-10-11 9:21 ` [PATCH v2 04/10] ubi: Expose mean erase counter for data " Rickard Andersson
@ 2024-10-11 12:04 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:04 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Expose mean erase counter for data area in sysfs. Data area includes
> all blocks except for the fastmap area.
>
> This value can be used in order to estimate life expectancy of the
> flash.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> drivers/mtd/ubi/build.c | 5 +++++
> 1 file changed, 5 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index f5a3a3f7d490..b253dcf849c7 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -138,6 +138,8 @@ static struct device_attribute dev_max_ec_fastmap =
> __ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_mean_ec_fastmap =
> __ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> +static struct device_attribute dev_mean_ec_data =
> + __ATTR(mean_ec_data, S_IRUGO, dev_attribute_show, NULL);
> #endif
> static struct device_attribute dev_reserved_for_bad =
> __ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
> @@ -463,6 +465,8 @@ static ssize_t dev_attribute_show(struct device *dev,
> ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
> else if (attr == &dev_mean_ec_fastmap)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
> + else if (attr == &dev_mean_ec_data)
> + ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
> #endif
> else if (attr == &dev_reserved_for_bad)
> ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
> @@ -494,6 +498,7 @@ static struct attribute *ubi_dev_attrs[] = {
> #ifdef CONFIG_MTD_UBI_FASTMAP
> &dev_max_ec_fastmap.attr,
> &dev_mean_ec_fastmap.attr,
> + &dev_mean_ec_data.attr,
> #endif
> &dev_reserved_for_bad.attr,
> &dev_bad_peb_count.attr,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 05/10] ubi: Expose max erase counter for data in sysfs
2024-10-11 9:21 ` [PATCH v2 05/10] ubi: Expose max " Rickard Andersson
@ 2024-10-11 12:04 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:04 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Expose max erase counter for data area in sysfs. Data area includes
> all blocks except for the fastmap area.
>
> This value can be used in order to estimate life expectancy of the
> flash.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> drivers/mtd/ubi/build.c | 5 +++++
> 1 file changed, 5 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index b253dcf849c7..f3649afbc777 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -138,6 +138,8 @@ static struct device_attribute dev_max_ec_fastmap =
> __ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_mean_ec_fastmap =
> __ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> +static struct device_attribute dev_max_ec_data =
> + __ATTR(max_ec_data, S_IRUGO, dev_attribute_show, NULL);
> static struct device_attribute dev_mean_ec_data =
> __ATTR(mean_ec_data, S_IRUGO, dev_attribute_show, NULL);
> #endif
> @@ -465,6 +467,8 @@ static ssize_t dev_attribute_show(struct device *dev,
> ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
> else if (attr == &dev_mean_ec_fastmap)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
> + else if (attr == &dev_max_ec_data)
> + ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
> else if (attr == &dev_mean_ec_data)
> ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
> #endif
> @@ -498,6 +502,7 @@ static struct attribute *ubi_dev_attrs[] = {
> #ifdef CONFIG_MTD_UBI_FASTMAP
> &dev_max_ec_fastmap.attr,
> &dev_mean_ec_fastmap.attr,
> + &dev_max_ec_data.attr,
> &dev_mean_ec_data.attr,
> #endif
> &dev_reserved_for_bad.attr,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute
2024-10-11 9:21 ` [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute Rickard Andersson
@ 2024-10-11 12:06 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:06 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> A mean erase counter gives a better understanding of the flash
> wear.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> Documentation/ABI/stable/sysfs-class-ubi | 7 +++++++
> 1 file changed, 7 insertions(+)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
> index a6b324014692..535a3e6dab12 100644
> --- a/Documentation/ABI/stable/sysfs-class-ubi
> +++ b/Documentation/ABI/stable/sysfs-class-ubi
> @@ -219,3 +219,10 @@ Description:
> Logical eraseblock size of this volume. Equivalent to logical
> eraseblock size of the device aligned on the volume alignment
> value.
> +
> +What: /sys/class/ubi/ubiX/mean_ec
> +Date: October 2024
> +KernelVersion: 6.X
> +Contact: linux-mtd@lists.infradead.org
> +Description:
> + Mean physical eraseblock erase counter value.
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area
2024-10-11 9:21 ` [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area Rickard Andersson
@ 2024-10-11 12:06 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:06 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> A mean erase counter gives a better understanding of the flash
> wear of the fastmap area.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
> index 535a3e6dab12..05a701b03a9a 100644
> --- a/Documentation/ABI/stable/sysfs-class-ubi
> +++ b/Documentation/ABI/stable/sysfs-class-ubi
> @@ -226,3 +226,11 @@ KernelVersion: 6.X
> Contact: linux-mtd@lists.infradead.org
> Description:
> Mean physical eraseblock erase counter value.
> +
> +What: /sys/class/ubi/ubiX/mean_ec_fastmap
> +Date: October 2024
> +KernelVersion: 6.X
> +Contact: linux-mtd@lists.infradead.org
> +Description:
> + Mean physical eraseblock erase counter value for the fastmap
> + area.
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 08/10] ubi: Add max erase counter sysfs attribute for fastmap area
2024-10-11 9:21 ` [PATCH v2 08/10] ubi: Add max " Rickard Andersson
@ 2024-10-11 12:06 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:06 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> A max erase counter specifically for the fastmap area gives a better
> understanding of the flash wear.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
> index 05a701b03a9a..62c93fda0bc4 100644
> --- a/Documentation/ABI/stable/sysfs-class-ubi
> +++ b/Documentation/ABI/stable/sysfs-class-ubi
> @@ -78,6 +78,14 @@ Contact: Artem Bityutskiy <dedekind@infradead.org>
> Description:
> Maximum physical eraseblock erase counter value.
>
> +What: /sys/class/ubi/ubiX/max_ec_fastmap
> +Date: October 2024
> +KernelVersion: 6.X
> +Contact: linux-mtd@lists.infradead.org
> +Description:
> + Maximum physical eraseblock erase counter value for a block
> + in the fastmap area.
> +
> What: /sys/class/ubi/ubiX/max_vol_count
> Date: July 2006
> KernelVersion: 2.6.22
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area
2024-10-11 9:21 ` [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area Rickard Andersson
@ 2024-10-11 12:08 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:08 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Data area includes all blocks except for the fastmap area.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
> index 62c93fda0bc4..100e1c0698a3 100644
> --- a/Documentation/ABI/stable/sysfs-class-ubi
> +++ b/Documentation/ABI/stable/sysfs-class-ubi
> @@ -242,3 +242,11 @@ Contact: linux-mtd@lists.infradead.org
> Description:
> Mean physical eraseblock erase counter value for the fastmap
> area.
> +
> +What: /sys/class/ubi/ubiX/mean_ec_data
> +Date: October 2024
> +KernelVersion: 6.X
> +Contact: linux-mtd@lists.infradead.org
> +Description:
> + Mean physical eraseblock erase counter value for data area.
> + Data area includes all blocks except for the fastmap area.
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 10/10] ubi: Add max erase counter sysfs attribute for data area
2024-10-11 9:21 ` [PATCH v2 10/10] ubi: Add max " Rickard Andersson
@ 2024-10-11 12:08 ` Zhihao Cheng
0 siblings, 0 replies; 20+ messages in thread
From: Zhihao Cheng @ 2024-10-11 12:08 UTC (permalink / raw)
To: Rickard Andersson, richard, linux-mtd, rickard314.andersson; +Cc: kernel
在 2024/10/11 17:21, Rickard Andersson 写道:
> Data area includes all blocks except for the fastmap area.
>
> Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
> ---
> Documentation/ABI/stable/sysfs-class-ubi | 8 ++++++++
> 1 file changed, 8 insertions(+)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/Documentation/ABI/stable/sysfs-class-ubi b/Documentation/ABI/stable/sysfs-class-ubi
> index 100e1c0698a3..ff453557b0db 100644
> --- a/Documentation/ABI/stable/sysfs-class-ubi
> +++ b/Documentation/ABI/stable/sysfs-class-ubi
> @@ -86,6 +86,14 @@ Description:
> Maximum physical eraseblock erase counter value for a block
> in the fastmap area.
>
> +What: /sys/class/ubi/ubiX/max_ec_data
> +Date: October 2024
> +KernelVersion: 6.X
> +Contact: linux-mtd@lists.infradead.org
> +Description:
> + Max physical eraseblock erase counter value for data area.
> + Data area includes all blocks except for the fastmap area.
> +
> What: /sys/class/ubi/ubiX/max_vol_count
> Date: July 2006
> KernelVersion: 2.6.22
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-10-11 12:17 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
2024-10-11 9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
2024-10-11 12:02 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 03/10] ubi: Expose max " Rickard Andersson
2024-10-11 12:03 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 04/10] ubi: Expose mean erase counter for data " Rickard Andersson
2024-10-11 12:04 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 05/10] ubi: Expose max " Rickard Andersson
2024-10-11 12:04 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 08/10] ubi: Add max " Rickard Andersson
2024-10-11 12:06 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area Rickard Andersson
2024-10-11 12:08 ` Zhihao Cheng
2024-10-11 9:21 ` [PATCH v2 10/10] ubi: Add max " Rickard Andersson
2024-10-11 12:08 ` Zhihao Cheng
2024-10-11 12:01 ` [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox