Re: [PATCH v2 2/2] mm: fix arithmetic for max_prop_frac when setting max_ratio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/19/23 9:01 PM, Matthew Wilcox wrote:
> On Tue, Dec 19, 2023 at 01:58:21PM +0800, Jingbo Xu wrote:
>> On 12/19/23 12:06 PM, Matthew Wilcox wrote:
>>> On Tue, Dec 19, 2023 at 10:42:46AM +0800, Jingbo Xu wrote:
>>>>  	} else {
>>>>  		bdi->max_ratio = max_ratio;
>>>> -		bdi->max_prop_frac = (FPROP_FRAC_BASE * max_ratio) / 100;
>>>> +		bdi->max_prop_frac = div64_u64(FPROP_FRAC_BASE * max_ratio,
>>>> +					       100 * BDI_RATIO_SCALE);
>>>>  	}
>>>
>>> Why use div64_u64 here?
>>>
>>> FPROP_FRAC_BASE is an unsigned long.  max_ratio is an unsigned int, so
>>> the numerator is an unsigned long.  BDI_RATIO_SCALE is 10,000, so the
>>> numerator is an unsigned int.  There's no 64-bit arithmetic needed here.
>>
>> Yes, div64_u64() is actually not needed here. So it seems
>>
>> bdi->max_prop_frac = FPROP_FRAC_BASE * max_ratio / 100 / BDI_RATIO_SCALE;
>>
>> is adequate?
> 
> I'd rather spell that as:
> 
> 		bdi->max_prop_frac = (FPROP_FRAC_BASE * max_ratio) /
> 					(100 * BDI_RATIO_SCALE);
> 
> It's closer to how you'd write it out mathematically and so it reads
> more easily.  At least for me.

Thanks, I would send v3 soon.

-- 
Thanks,
Jingbo




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux