On Wed, May 20, 2020 at 07:48:40AM +1000, Dave Chinner wrote: > From: Dave Chinner <dchinner@xxxxxxxxxx> > > Shaokun Zhang reported that XFs was using substantial CPU time in s/XFs/XFS/ > if (idelta) { > - error = xfs_mod_icount(mp, idelta); > - ASSERT(!error); > + percpu_counter_add_batch(&mp->m_icount, idelta, > + XFS_ICOUNT_BATCH); > + if (idelta < 0) > + ASSERT(__percpu_counter_compare(&mp->m_icount, 0, > + XFS_ICOUNT_BATCH) >= 0); > } > > if (ifreedelta) { > - error = xfs_mod_ifree(mp, ifreedelta); > - ASSERT(!error); > + percpu_counter_add(&mp->m_ifree, ifreedelta); > + if (ifreedelta < 0) > + ASSERT(percpu_counter_compare(&mp->m_ifree, 0) >= 0); I'd be tempted to just remove the ASSERTS entirely, as they are still pretty heavy handed for debug kernels. Otherwise looks good: Reviewed-by: Christoph Hellwig <hch@xxxxxx>