Message ID | 20191009032124.10541-18-david@fromorbit.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm, xfs: non-blocking inode reclaim | expand |
On Wed, Oct 09, 2019 at 02:21:15PM +1100, Dave Chinner wrote: > From: Dave Chinner <dchinner@redhat.com> > > We have a number of reasons for blocking kswapd in XFS inode > reclaim, mainly all to do with the fact that memory reclaim has no > feedback mechanisms to throttle on dirty slab objects that need IO > to reclaim. > > As a result, we currently throttle inode reclaim by issuing IO in > the reclaim context. The unfortunate side effect of this is that it > can cause long tail latencies in reclaim and for some workloads this > can be a problem. > > Now that the shrinkers finally have a method of telling kswapd to > back off, we can start the process of making inode reclaim in XFS > non-blocking. The first thing we need to do is not block kswapd, but > so that doesn't cause immediate serious problems, make sure inode > writeback is always underway when kswapd is running. > > As we don't block kswapd now, we don't have to worry about reclaim > scans taking long delays due to IO being issued and waited for. > Hence while direct reclaim gets delayed by IO, kswapd will not and > so it will keep pushing the AIL to clean inodes. Hence direct > reclaim doesn't need to push the AIL anymore as kswapd will do it > reliably now. > > Signed-off-by: Dave Chinner <dchinner@redhat.com> > --- Reviewed-by: Brian Foster <bfoster@redhat.com> > fs/xfs/xfs_icache.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c > index 944add5ff8e0..edcc3f6bb3bf 100644 > --- a/fs/xfs/xfs_icache.c > +++ b/fs/xfs/xfs_icache.c > @@ -1378,11 +1378,22 @@ xfs_reclaim_inodes_nr( > struct xfs_mount *mp, > int nr_to_scan) > { > - /* kick background reclaimer and push the AIL */ > + int sync_mode = SYNC_TRYLOCK; > + > + /* kick background reclaimer */ > xfs_reclaim_work_queue(mp); > - xfs_ail_push_all(mp->m_ail); > > - return xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan); > + /* > + * For kswapd, we kick background inode writeback. For direct > + * reclaim, we issue and wait on inode writeback to throttle > + * reclaim rates and avoid shouty OOM-death. > + */ > + if (current_is_kswapd()) > + xfs_ail_push_all(mp->m_ail); > + else > + sync_mode |= SYNC_WAIT; > + > + return xfs_reclaim_inodes_ag(mp, sync_mode, &nr_to_scan); > } > > /* > -- > 2.23.0.rc1 >
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 944add5ff8e0..edcc3f6bb3bf 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -1378,11 +1378,22 @@ xfs_reclaim_inodes_nr( struct xfs_mount *mp, int nr_to_scan) { - /* kick background reclaimer and push the AIL */ + int sync_mode = SYNC_TRYLOCK; + + /* kick background reclaimer */ xfs_reclaim_work_queue(mp); - xfs_ail_push_all(mp->m_ail); - return xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan); + /* + * For kswapd, we kick background inode writeback. For direct + * reclaim, we issue and wait on inode writeback to throttle + * reclaim rates and avoid shouty OOM-death. + */ + if (current_is_kswapd()) + xfs_ail_push_all(mp->m_ail); + else + sync_mode |= SYNC_WAIT; + + return xfs_reclaim_inodes_ag(mp, sync_mode, &nr_to_scan); } /*