Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF_ERASE_MIN_SIZE设置不合理导致GC无法触发 #168

Open
PengLi3 opened this issue Sep 27, 2024 · 0 comments
Open

EF_ERASE_MIN_SIZE设置不合理导致GC无法触发 #168

PengLi3 opened this issue Sep 27, 2024 · 0 comments

Comments

@PengLi3
Copy link

PengLi3 commented Sep 27, 2024

EF_ERASE_MIN_SIZE=100, ENV_AREA_SIZE = 1000
我在flash中保存是的key/value,且每个扇区只能保存一对key/value, 当写入相同的key时,EF要将当前key/value所在的扇区标记为dirty状态,然后再将key写入新的扇区。扇区的dirty status保存在扇区开始offset=4的地方,因此EF要根据当前的key/value所在的地址计算出扇区的开始位置。EF中根据以下宏:
EF_ALIGN_DOWN(size, align) ((size) & ~((align) - 1))
来计算的。按照这个宏,假设key/value的地址是0x1A4, size=0x1A4, align = 0x64, 则计算出来的结果是0x184=388,显然这个结果不正确的,正确的结果应该是0x190=400, 这样EF就无法正确标记扇区的状态,从而无法触发GC。
当EF_ERASE_MIN_SIZE=128, ENV_AREA_SIZE = 64*1024时, 通过EF_ALIGN_DOWN可以得到正确的扇区起始地址。所以这里要求EF_ERASE_MIN_SIZE=2^n才能正确计算。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant