[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <43c2ce03-04ac-4da4-a9e2-7f1393939d14@huawei.com>
Date: Wed, 20 Aug 2025 18:06:22 +0800
From: Quanmin Yan <yanquanmin1@...wei.com>
To: SeongJae Park <sj@...nel.org>
CC: <akpm@...ux-foundation.org>, <damon@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<wangkefeng.wang@...wei.com>, <zuoze1@...wei.com>
Subject: Re: [RFC PATCH -next 16/16] mm/damon/core: handle quota->esz overflow
issues
Hi SJ,
在 2025/8/14 1:15, SeongJae Park 写道:
> On Wed, 13 Aug 2025 13:07:06 +0800 Quanmin Yan <yanquanmin1@...wei.com> wrote:
>
>> In the original quota enforcement implementation, the traffic
>> calculation multiplied A by 1000000 due to time unit conversion,
>> making it highly prone to overflow on 32-bit systems:
>>
>> damos_set_effective_quota
>> if (quota->total_charged_ns)
>> throughput = quota->total_charged_sz * 1000000 /
>> quota->total_charged_ns;
>>
>> Requiring total_charged_sz to be less than 4GB/1000000 is unreasonable.
>> Additionally, when overflow occurs and causes quota->esz to become
>> extremely small, the subsequent damos_apply_scheme logic permanently
>> sets sz to 0, while quota stop updating, ultimately leading to complete
>> functional failure:
>>
>> damos_apply_scheme
>> if (quota->esz && quota->charged_sz + sz > quota->esz)
>> sz = ALIGN_DOWN(quota->esz - quota->charged_sz, DAMON_MIN_REGION);
>>
>> Total charged stats use the unsigned long long data type to reduce
>> overflow risk, with data reset capability after overflow occurs.
> Thank you for finding this issue! I don't want to change the data type if
> possible, though. Could replacing the easily-overflowing throughput
> calculation with mult_frac() fix the issue?
Thank you for your guidance, it does work effectively. The relevant changes
have been included in patch #12 of the v2 series[1].
[1] https://lore.kernel.org/all/20250820080623.3799131-13-yanquanmin1@huawei.com/
Thanks, Quanmin Yan
Powered by blists - more mailing lists