On 2023/2/1 20:23, qixiaoyu wrote:
How about updating as below to avoid lossing accuracy if new is less than 100?
return div_u64(new * (100 - LAST_AGE_WEIGHT), 100) +
div_u64(old * LAST_AGE_WEIGHT, 100);
Thanks,
We want to avoid overflow by doing the division first. To keep the accuracy, how
Alright,
about updating as below:
res = div_u64_rem(new, 100, &rem_new) * (100 - LAST_AGE_WEIGHT)
+ div_u64_rem(old, 100, &rem_old) * LAST_AGE_WEIGHT;
res += rem_new * (100 - LAST_AGE_WEIGHT) / 100 + rem_old *
LAST_AGE_WEIGHT / 100;
return res;
if (rem_new)
res += rem_new * (100 - LAST_AGE_WEIGHT) / 100;
if (rem_old)
res += rem_old * LAST_AGE_WEIGHT / 100;
Otherwise, it looks fine to me. :)
Thanks,
Thanks,
Friendly ping
}
/* This returns a new age and allocated blocks in ei */
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel