* [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches
@ 2025-04-22 12:54 cem
2025-04-22 12:58 ` Hans Holmberg
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: cem @ 2025-04-22 12:54 UTC (permalink / raw)
To: linux-xfs; +Cc: hch, Hans.Holmberg, linux, linux-kernel, oe-kbuild-all
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>
---
V2:
- threshold should be a s64, not s32
fs/xfs/xfs_zone_gc.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index 8c541ca71872..81c94dd1d596 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -170,7 +170,8 @@ bool
xfs_zoned_need_gc(
struct xfs_mount *mp)
{
- s64 available, free;
+ s64 available, free, threshold;
+ s32 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);
+ threshold = threshold * mp->m_zonegc_low_space +
+ remainder * div_s64(mp->m_zonegc_low_space, 100);
+
+ if (available < threshold)
return true;
return false;
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches
2025-04-22 12:54 [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches cem
@ 2025-04-22 12:58 ` Hans Holmberg
2025-04-22 13:54 ` Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Hans Holmberg @ 2025-04-22 12:58 UTC (permalink / raw)
To: cem@kernel.org, linux-xfs@vger.kernel.org
Cc: hch, linux@roeck-us.net, linux-kernel@vger.kernel.org,
oe-kbuild-all@lists.linux.dev
On 22/04/2025 14:55, 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>
> ---
> V2:
> - threshold should be a s64, not s32
>
> fs/xfs/xfs_zone_gc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
> index 8c541ca71872..81c94dd1d596 100644
> --- a/fs/xfs/xfs_zone_gc.c
> +++ b/fs/xfs/xfs_zone_gc.c
> @@ -170,7 +170,8 @@ bool
> xfs_zoned_need_gc(
> struct xfs_mount *mp)
> {
> - s64 available, free;
> + s64 available, free, threshold;
> + s32 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);
> + threshold = threshold * mp->m_zonegc_low_space +
> + remainder * div_s64(mp->m_zonegc_low_space, 100);
> +
> + if (available < threshold)
> return true;
>
> return false;
Thanks for fixing this up!
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches
2025-04-22 12:54 [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches cem
2025-04-22 12:58 ` Hans Holmberg
@ 2025-04-22 13:54 ` Christoph Hellwig
2025-04-22 13:56 ` Guenter Roeck
2025-04-22 14:09 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2025-04-22 13:54 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, Hans.Holmberg, linux, linux-kernel, oe-kbuild-all
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches
2025-04-22 12:54 [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches cem
2025-04-22 12:58 ` Hans Holmberg
2025-04-22 13:54 ` Christoph Hellwig
@ 2025-04-22 13:56 ` Guenter Roeck
2025-04-22 14:09 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2025-04-22 13:56 UTC (permalink / raw)
To: cem, linux-xfs; +Cc: hch, Hans.Holmberg, linux-kernel, oe-kbuild-all
On 4/22/25 05:54, 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>
Succesfully built openrisc:allmodconfig and parisc:allmodconfig with gcc 13.3.
Tested-by: Guenter Roeck <linux@roeck-us.net>
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches
2025-04-22 12:54 [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches cem
` (2 preceding siblings ...)
2025-04-22 13:56 ` Guenter Roeck
@ 2025-04-22 14:09 ` Carlos Maiolino
3 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2025-04-22 14:09 UTC (permalink / raw)
To: linux-xfs, cem; +Cc: hch, Hans.Holmberg, linux, linux-kernel, oe-kbuild-all
On Tue, 22 Apr 2025 14:54:54 +0200, cem@kernel.org wrote:
> 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.
>
> [...]
Applied to for-next, thanks!
[1/1] XFS: fix zoned gc threshold math for 32-bit arches
commit: bd7c19331913b955a7823e6315ca16bbcc65aeff
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-22 14:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 12:54 [PATCH V2] XFS: fix zoned gc threshold math for 32-bit arches cem
2025-04-22 12:58 ` Hans Holmberg
2025-04-22 13:54 ` Christoph Hellwig
2025-04-22 13:56 ` Guenter Roeck
2025-04-22 14:09 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox