[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZYEWyn5g/jG/ixMk@casper.infradead.org>
Date: Tue, 19 Dec 2023 04:06:34 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Jingbo Xu <jefflexu@...ux.alibaba.com>
Cc: shr@...kernel.io, akpm@...ux-foundation.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, joseph.qi@...ux.alibaba.com,
linux-fsdevel@...r.kernel.org, linux-block@...r.kernel.org
Subject: Re: [PATCH v2 2/2] mm: fix arithmetic for max_prop_frac when setting
max_ratio
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.
Powered by blists - more mailing lists