From: Chao Yu <chao@kernel.org>
To: qixiaoyu <qxy65535@gmail.com>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: xiongping1@xiaomi.com, qixiaoyu1@xiaomi.com,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age
Date: Wed, 1 Feb 2023 20:57:33 +0800 [thread overview]
Message-ID: <938a8e61-4e47-1acc-938c-c90d213d2c86@kernel.org> (raw)
In-Reply-To: <Y9pZqOMBipT2NZk0@mi-HP-ProDesk-680-G4-MT>
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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-02-01 12:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 12:58 [f2fs-dev] [PATCH 1/2] f2fs: fix wrong calculation of block age qixiaoyu1
2023-01-13 12:58 ` [f2fs-dev] [PATCH 2/2] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-01-16 3:08 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age qixiaoyu1
2023-01-16 3:08 ` [f2fs-dev] [PATCH 2/2 v2] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-01-28 3:35 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age Chao Yu
2023-01-29 11:18 ` qixiaoyu
2023-02-01 12:23 ` qixiaoyu
2023-02-01 12:57 ` Chao Yu [this message]
2023-02-01 14:04 ` qixiaoyu
2023-02-02 8:20 ` [f2fs-dev] [PATCH 1/2 v3] " qixiaoyu1
2023-02-02 8:20 ` [f2fs-dev] [PATCH 2/2 v3] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-02-03 8:31 ` Chao Yu
2023-02-04 9:06 ` qixiaoyu
2023-02-04 9:43 ` [f2fs-dev] [PATCH 2/2 v4] " qixiaoyu1
2023-02-07 12:31 ` Chao Yu
2023-02-07 18:39 ` Jaegeuk Kim
2023-02-03 6:11 ` [f2fs-dev] [PATCH 1/2 v3] f2fs: fix wrong calculation of block age Chao Yu
2023-02-06 3:40 ` patchwork-bot+f2fs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=938a8e61-4e47-1acc-938c-c90d213d2c86@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=qixiaoyu1@xiaomi.com \
--cc=qxy65535@gmail.com \
--cc=xiongping1@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).