2014-10-02 12:50:12

by Tanya Brokhman

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

Hi Richard,

Sorry it took me some time to answer, got per-occupied with some urgent
staff.

On 9/28/2014 1:54 PM, Richard Weinberger wrote:
> Am 28.09.2014 12:46, schrieb Tanya Brokhman:
>> On 9/28/2014 11:54 AM, Richard Weinberger wrote:
>>> Am 28.09.2014 10:48, schrieb Tanya Brokhman:
>>>>>> @@ -424,6 +440,8 @@ struct ubi_fm_sb {
>>>>>> __be32 used_blocks;
>>>>>> __be32 block_loc[UBI_FM_MAX_BLOCKS];
>>>>>> __be32 block_ec[UBI_FM_MAX_BLOCKS];
>>>>>> + __be32 block_rc[UBI_FM_MAX_BLOCKS];
>>>>>> + __be64 block_let[UBI_FM_MAX_BLOCKS];
>>>>>
>>>>> Doesn't this break the fastmap on-disk layout?
>>>>
>>>> What do you mean "break"? I verified fastmap feature is working. the whole read-disturb depends on it so I tested this thoroughly.
>>>
>>> Did you write a fastmap with your changes applied and then an attach using a fastmap implementation *without*
>>> you changes?
>>> I bet it will not work because the disk layout is now different.
>>
>> you're right, it wont work. I did a set of attach/detach tests to verify fastmap, but of course with my changes.
>>
>>> Linux is not the only user of fastmap. We need to be very careful here.
>>
>> Could you please elaborate here? I'm not sure I understand the use case you're referring to.
>
> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
> to scanning mode but it will be slow and the customer unhappy.
>

Ok, I understand the problem now. I wanted to discuss a possible
solution before implementing it:
We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION =
1 and any other is not supported. We can use that; Add another fm
version (UBI_FM_FMT_VERSION_RD = 2) and then decide according to it.
Meaning, if during attach process we find fm superblock we check it's
version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan.
The next fastmap will be written with the new layout (and new version
number) so second boot will attach from fastmap without any issues.

>
> Thanks,
> //richard
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>

Thanks,
Tanya Brokhman
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation


2014-10-02 13:24:23

by Richard Weinberger

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

Am 02.10.2014 14:50, schrieb Tanya Brokhman:
>> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
>> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
>> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
>> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
>> to scanning mode but it will be slow and the customer unhappy.
>>
>
> Ok, I understand the problem now. I wanted to discuss a possible solution before implementing it:
> We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION = 1 and any other is not supported. We can use that; Add another fm version (UBI_FM_FMT_VERSION_RD = 2) and
> then decide according to it. Meaning, if during attach process we find fm superblock we check it's version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan. The next
> fastmap will be written with the new layout (and new version number) so second boot will attach from fastmap without any issues.

Yes, if we change the fastmap on-disk layout we need to change UBI_FM_FMT_VERSION.
Then other fastmap implementations will notice the change and can hopefully recover.
Implementations which do not evaluate UBI_FM_FMT_VERSION deserve breaking. ;-)

That said, I'll not block a layout change but we have to be sure that it is *really* needed.
I'm currently heavily working on fastmap and my local queue with fastmap fixes keeps growing.
If I find a horror bug which needs a fastmap layout change I want to change the layout only once,
not twice.

Thanks,
//richard

2014-10-02 13:36:21

by Richard Weinberger

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

Am 02.10.2014 14:50, schrieb Tanya Brokhman:
> Hi Richard,
>
> Sorry it took me some time to answer, got per-occupied with some urgent staff.
>
> On 9/28/2014 1:54 PM, Richard Weinberger wrote:
>> Am 28.09.2014 12:46, schrieb Tanya Brokhman:
>>> On 9/28/2014 11:54 AM, Richard Weinberger wrote:
>>>> Am 28.09.2014 10:48, schrieb Tanya Brokhman:
>>>>>>> @@ -424,6 +440,8 @@ struct ubi_fm_sb {
>>>>>>> __be32 used_blocks;
>>>>>>> __be32 block_loc[UBI_FM_MAX_BLOCKS];
>>>>>>> __be32 block_ec[UBI_FM_MAX_BLOCKS];
>>>>>>> + __be32 block_rc[UBI_FM_MAX_BLOCKS];
>>>>>>> + __be64 block_let[UBI_FM_MAX_BLOCKS];
>>>>>>
>>>>>> Doesn't this break the fastmap on-disk layout?
>>>>>
>>>>> What do you mean "break"? I verified fastmap feature is working. the whole read-disturb depends on it so I tested this thoroughly.
>>>>
>>>> Did you write a fastmap with your changes applied and then an attach using a fastmap implementation *without*
>>>> you changes?
>>>> I bet it will not work because the disk layout is now different.
>>>
>>> you're right, it wont work. I did a set of attach/detach tests to verify fastmap, but of course with my changes.
>>>
>>>> Linux is not the only user of fastmap. We need to be very careful here.
>>>
>>> Could you please elaborate here? I'm not sure I understand the use case you're referring to.
>>
>> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
>> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
>> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
>> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
>> to scanning mode but it will be slow and the customer unhappy.
>>
>
> Ok, I understand the problem now. I wanted to discuss a possible solution before implementing it:
> We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION = 1 and any other is not supported. We can use that; Add another fm version (UBI_FM_FMT_VERSION_RD = 2) and
> then decide according to it. Meaning, if during attach process we find fm superblock we check it's version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan. The next
> fastmap will be written with the new layout (and new version number) so second boot will attach from fastmap without any issues.

BTW: I think I've found a way such that your change will not break anything.
Keep UBI_FM_FMT_VERSION=1, but claim one field in ubi_fm_sb to indicate a fastmap subversion or extension.
Create new data structures which carry all the information you need and place them at the end of the fastmap.

An old implementation will not evaluate ubi_fm_sb->extension and therefore will not use the additional info
you've placed at the end of the fastmap.

A new implementation will evaluate ubi_fm_sb->extension and notice that this fastmap carries the "read disturb infrastructure"
extension info at it's end and can use it...

Not nice, not perfect but could work. 8-)

Thanks,
//richard

2014-10-02 13:42:54

by Tanya Brokhman

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

On 10/2/2014 4:24 PM, Richard Weinberger wrote:
> Am 02.10.2014 14:50, schrieb Tanya Brokhman:
>>> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
>>> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
>>> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
>>> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
>>> to scanning mode but it will be slow and the customer unhappy.
>>>
>>
>> Ok, I understand the problem now. I wanted to discuss a possible solution before implementing it:
>> We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION = 1 and any other is not supported. We can use that; Add another fm version (UBI_FM_FMT_VERSION_RD = 2) and
>> then decide according to it. Meaning, if during attach process we find fm superblock we check it's version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan. The next
>> fastmap will be written with the new layout (and new version number) so second boot will attach from fastmap without any issues.
>
> Yes, if we change the fastmap on-disk layout we need to change UBI_FM_FMT_VERSION.
> Then other fastmap implementations will notice the change and can hopefully recover.
> Implementations which do not evaluate UBI_FM_FMT_VERSION deserve breaking. ;-)

good. will work on the fix and upload a new set when ready&tested.

>
> That said, I'll not block a layout change but we have to be sure that it is *really* needed.

In order to support read-disturb, I think its really needed. There is no
other way to save read counter per PEB but in fastmap.

> I'm currently heavily working on fastmap and my local queue with fastmap fixes keeps growing.
> If I find a horror bug which needs a fastmap layout change I want to change the layout only once,
> not twice.
>

How do you test all of your fastmap fixes? Some of them are not easy to
reproduce (the pq saving for example). Besides heavy stability testing,
I was testing my changes manually by a lot of dbg prints in the code and
analyzing the logs manually. Not the optimal way....

> Thanks,
> //richard
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>

Thanks,
Tanya Brokhman
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

2014-10-02 14:05:56

by Richard Weinberger

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

Am 02.10.2014 15:42, schrieb Tanya Brokhman:
> On 10/2/2014 4:24 PM, Richard Weinberger wrote:
>> Am 02.10.2014 14:50, schrieb Tanya Brokhman:
>>>> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
>>>> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
>>>> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
>>>> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
>>>> to scanning mode but it will be slow and the customer unhappy.
>>>>
>>>
>>> Ok, I understand the problem now. I wanted to discuss a possible solution before implementing it:
>>> We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION = 1 and any other is not supported. We can use that; Add another fm version (UBI_FM_FMT_VERSION_RD = 2) and
>>> then decide according to it. Meaning, if during attach process we find fm superblock we check it's version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan. The next
>>> fastmap will be written with the new layout (and new version number) so second boot will attach from fastmap without any issues.
>>
>> Yes, if we change the fastmap on-disk layout we need to change UBI_FM_FMT_VERSION.
>> Then other fastmap implementations will notice the change and can hopefully recover.
>> Implementations which do not evaluate UBI_FM_FMT_VERSION deserve breaking. ;-)
>
> good. will work on the fix and upload a new set when ready&tested.
>
>>
>> That said, I'll not block a layout change but we have to be sure that it is *really* needed.
>
> In order to support read-disturb, I think its really needed. There is no other way to save read counter per PEB but in fastmap.

The question is, do we really need all this values on-flash?
You could create a simple sysfs or ioctl() interface to pass these values to userspace.
Then you can hack up an userspace daemon which monitors the counters and triggers a check if needed.
The daemon can also store the counter into a flat file. If think you don't need exact counters,
there it does not hurt if the daemon does not store the most current values at a power cut.

Thanks,
//richard

2014-10-02 14:11:16

by Tanya Brokhman

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

On 10/2/2014 4:36 PM, Richard Weinberger wrote:
> Am 02.10.2014 14:50, schrieb Tanya Brokhman:
>> Hi Richard,
>>
>> Sorry it took me some time to answer, got per-occupied with some urgent staff.
>>
>> On 9/28/2014 1:54 PM, Richard Weinberger wrote:
>>> Am 28.09.2014 12:46, schrieb Tanya Brokhman:
>>>> On 9/28/2014 11:54 AM, Richard Weinberger wrote:
>>>>> Am 28.09.2014 10:48, schrieb Tanya Brokhman:
>>>>>>>> @@ -424,6 +440,8 @@ struct ubi_fm_sb {
>>>>>>>> __be32 used_blocks;
>>>>>>>> __be32 block_loc[UBI_FM_MAX_BLOCKS];
>>>>>>>> __be32 block_ec[UBI_FM_MAX_BLOCKS];
>>>>>>>> + __be32 block_rc[UBI_FM_MAX_BLOCKS];
>>>>>>>> + __be64 block_let[UBI_FM_MAX_BLOCKS];
>>>>>>>
>>>>>>> Doesn't this break the fastmap on-disk layout?
>>>>>>
>>>>>> What do you mean "break"? I verified fastmap feature is working. the whole read-disturb depends on it so I tested this thoroughly.
>>>>>
>>>>> Did you write a fastmap with your changes applied and then an attach using a fastmap implementation *without*
>>>>> you changes?
>>>>> I bet it will not work because the disk layout is now different.
>>>>
>>>> you're right, it wont work. I did a set of attach/detach tests to verify fastmap, but of course with my changes.
>>>>
>>>>> Linux is not the only user of fastmap. We need to be very careful here.
>>>>
>>>> Could you please elaborate here? I'm not sure I understand the use case you're referring to.
>>>
>>> Consider the case where you have a board with a fastmap enabled bootloader and a Linux OS.
>>> The bootloader does a fastmap attach and boots the kernel from UBI and the kernel it self has the rootfs
>>> on UBI too. If you install a new kernel with your changes applied it will write the fastmap in a different
>>> format and the bootloader will fail badly. In worst case the board bricks, in best case the bootloader can fall back
>>> to scanning mode but it will be slow and the customer unhappy.
>>>
>>
>> Ok, I understand the problem now. I wanted to discuss a possible solution before implementing it:
>> We have a "fastmap version" in fm_sb. At the moment UBI_FM_FMT_VERSION = 1 and any other is not supported. We can use that; Add another fm version (UBI_FM_FMT_VERSION_RD = 2) and
>> then decide according to it. Meaning, if during attach process we find fm superblock we check it's version, if it's != UBI_FM_FMT_VERSION_RD, we fall back to full scan. The next
>> fastmap will be written with the new layout (and new version number) so second boot will attach from fastmap without any issues.
>
> BTW: I think I've found a way such that your change will not break anything.
> Keep UBI_FM_FMT_VERSION=1, but claim one field in ubi_fm_sb to indicate a fastmap subversion or extension.
> Create new data structures which carry all the information you need and place them at the end of the fastmap.
>
> An old implementation will not evaluate ubi_fm_sb->extension and therefore will not use the additional info
> you've placed at the end of the fastmap.
>
> A new implementation will evaluate ubi_fm_sb->extension and notice that this fastmap carries the "read disturb infrastructure"
> extension info at it's end and can use it...
>
> Not nice, not perfect but could work. 8-)

Agree, it will work, but seems a bit ugly to me.... You really think it
will be better than add a new fm_version? I agree that breaking fm
layout is dangerous but it seems to me like the correct way to implement
this requirement. Saving all read-disturb data in "extensions" feels
like a hack.
That said, you're have much more experienced with ubi&fm then I do, so
I'll do as you see best.

>
> Thanks,
> //richard
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>


--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

2014-10-03 15:38:34

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

On Thu, 2014-10-02 at 16:05 +0200, Richard Weinberger wrote:
> The question is, do we really need all this values on-flash?

Good question, this is why I requested some kind of design description,
which would clearly explain the problem.

Just off-the top of my head, may be it could be enough to keep the
counters only in the UBI headers, may be it is enough to work with some
kind of averages. But it is hard to tell without clearly understanding
the problem we are solving.

2014-10-07 13:56:07

by Richard Weinberger

[permalink] [raw]
Subject: Re: [RFC/PATCH 1/5] mtd: ubi: Read disturb infrastructure

Am 02.10.2014 15:42, schrieb Tanya Brokhman:
> How do you test all of your fastmap fixes? Some of them are not easy to reproduce (the pq saving for example). Besides heavy stability testing, I was testing my changes manually by
> a lot of dbg prints in the code and analyzing the logs manually. Not the optimal way....

I'm currently implementing a test framework for fastmap.
Using it I've found many issues.
I hope I can release it soon, but first some legal issues have to be resolved.

Thanks,
//richard