lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <y2yqlycoihdszskhm57idjmzmllj3qvppp27tqqylwfi3uqrwe@qcsmimh5vv73>
Date: Tue, 22 Apr 2025 14:39:29 +0200
From: Carlos Maiolino <cem@...nel.org>
To: Hans Holmberg <Hans.Holmberg@....com>
Cc: "linux-xfs@...r.kernel.org" <linux-xfs@...r.kernel.org>, 
	hch <hch@....de>, "linux@...ck-us.net" <linux@...ck-us.net>, 
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "oe-kbuild-all@...ts.linux.dev" <oe-kbuild-all@...ts.linux.dev>
Subject: Re: [PATCH] XFS: fix zoned gc threshold math for 32-bit arches

On Tue, Apr 22, 2025 at 12:31:01PM +0000, Hans Holmberg wrote:
> On 22/04/2025 13:42, cem@...nel.org wrote:
> > From: Carlos Maiolino <cem@...nel.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@...el.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202504181233.F7D9Atra-lkp@intel.com/
> > Signed-off-by: Carlos Maiolino <cmaiolino@...hat.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?

Uff, yes, I wrote it to use as a divisor initially, changed my mind and forgot
to fix the definition. I'll send a V2, thanks for spotting it. Only remainder
must be a s32.


> 
> > +	threshold = threshold * mp->m_zonegc_low_space +
> > +		    remainder * div_s64(mp->m_zonegc_low_space, 100);
> > +
> > +	if (available < threshold)
> >  		return true;
> >
> >  	return false;
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ