From: Hans Holmberg <Hans.Holmberg@wdc.com>
To: "cem@kernel.org" <cem@kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Cc: hch <hch@lst.de>, "linux@roeck-us.net" <linux@roeck-us.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"oe-kbuild-all@lists.linux.dev" <oe-kbuild-all@lists.linux.dev>
Subject: Re: [PATCH] XFS: fix zoned gc threshold math for 32-bit arches
Date: Tue, 22 Apr 2025 12:31:01 +0000 [thread overview]
Message-ID: <fb6536ec-244f-4a90-949d-ddff7f15d18b@wdc.com> (raw)
In-Reply-To: <20250422114231.1012462-1-cem@kernel.org>
On 22/04/2025 13:42, cem@kernel.org wrote:
> From: Carlos Maiolino <cem@kernel.org>
>
> xfs_zoned_need_gc makes use of mult_frac() to calculate the threshold
> for triggering the zoned garbage collector, but, turns out mult_frac()
> doesn't properly work with 64-bit data types and this caused build
> failures on some 32-bit architectures.
>
> Fix this by essentially open coding mult_frac() in a 64-bit friendly
> way.
>
> Notice we don't need to bother with counters underflow here because
> xfs_estimate_freecounter() will always return a positive value, as it
> leverages percpu_counter_read_positive to read such counters.
>
> Fixes: 845abeb1f06a ("xfs: add tunable threshold parameter for triggering zone GC")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202504181233.F7D9Atra-lkp@intel.com/
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>
> fs/xfs/xfs_zone_gc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
> index 8c541ca71872..b0e8915ef733 100644
> --- a/fs/xfs/xfs_zone_gc.c
> +++ b/fs/xfs/xfs_zone_gc.c
> @@ -171,6 +171,7 @@ xfs_zoned_need_gc(
> struct xfs_mount *mp)
> {
> s64 available, free;
> + s32 threshold, remainder;
>
> if (!xfs_group_marked(mp, XG_TYPE_RTG, XFS_RTG_RECLAIMABLE))
> return false;
> @@ -183,7 +184,12 @@ xfs_zoned_need_gc(
> return true;
>
> free = xfs_estimate_freecounter(mp, XC_FREE_RTEXTENTS);
> - if (available < mult_frac(free, mp->m_zonegc_low_space, 100))
> +
> + threshold = div_s64_rem(free, 100, &remainder);
Hmm, shouldn't threshold be a s64?
> + threshold = threshold * mp->m_zonegc_low_space +
> + remainder * div_s64(mp->m_zonegc_low_space, 100);
> +
> + if (available < threshold)
> return true;
>
> return false;
next prev parent reply other threads:[~2025-04-22 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 11:42 cem
2025-04-22 12:31 ` Hans Holmberg [this message]
2025-04-22 12:39 ` Carlos Maiolino
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=fb6536ec-244f-4a90-949d-ddff7f15d18b@wdc.com \
--to=hans.holmberg@wdc.com \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=oe-kbuild-all@lists.linux.dev \
/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
all inboxes | Powered by JetHome®