[RFC] UBI statistics and bitrot interface
Zhihao Cheng
chengzhihao1 at huawei.com
Fri Feb 14 21:21:47 PST 2025
在 2025/2/15 12:58, Zhihao Cheng 写道:
> 在 2025/2/15 0:04, Ashley Herron 写道:
>>> IIRC, this patches have been part of our failed approach to support MLC
>>> NAND. One part was exposing a more or less sophisticated interface
>>> to userspace such that a NAND flash specific daemon can foster the chip.
>>>
>>>
>>> After some iterations, ubihealthd was born. But it does not use a
>>> statistics
>>> interface.
>>
>> Unfortunately ubihealthd wouldn't fit what we need.
>>
>>>
>>> What kind of metrics are you looking for?
>>> Maybe some eBPF/tracing magic will already serve you enough data points?
>>
>> The goal is to capture similar data as eMMC and UFS devices report
>> regarding
>> total bytes written to the block device. So I want to capture total
>> (payload)
>> bytes written by callers to the UBI layer, not including UBI overhead
>> (headers,
>> wear leveling). This is for the purpose of monitoring and identifying any
>> pattern of excessive writing on devices in operation that may effect its
>> lifetime.
>
>> We may want to monitor total writes to a UBI device over a 24 hour
>> periods or less, so only using erase counter monitoring doesn't give
>> us the
>> level of monitoring we require. We write to some UBI volumes using UBIFS
>> and others using UBI IO directly. I was planning to add (or request
>> you add) a
>> wc (write count) variable to the current struct with ec and rc in this
>> patchset.
>>
>
> I think ebpf/tracing will satisfy your requirements by hooking function
> ubi_eba_write_leb().
>
Following is an example code written in bpf, you can run 'bpftrace a.bt'
to get total written bytes(data + meta data[ubifs]) for each ubi device:
0
2048
0
2048
0
2048
@total_len[0]: 36864
@total_len[0]: 36864
a.bt
struct ubi_device {
char pad[0x340];
int ubi_num;
};
kprobe:ubi_eba_write_leb
{
$ubi_num = ((struct ubi_device *)arg0)->ubi_num;
$len = arg5;
print($ubi_num);
print($len);
@total_len[$ubi_num] += $len;
}
i:s:1
{
print(@total_len);
}
>> Cheers,
>> Ashley
>>
>> ______________________________________________________
>> Linux MTD discussion mailing list
>> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>> .
>>
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
More information about the linux-mtd
mailing list