On Wed, Jan 05, 2022 at 04:01:07PM -0800, Darrick J. Wong wrote: > On Thu, Jan 06, 2022 at 09:48:29AM +1100, Dave Chinner wrote: > > + > > + might_sleep(); > > > > list_replace_init(&ioend->io_list, &tmp); > > + segments = ioend->io_segments; > > iomap_finish_ioend(ioend, error); > > > > while (!list_empty(&tmp)) { > > + if (segments > 32768) { > > + cond_resched(); > > + segments = 0; > > + } > > ioend = list_first_entry(&tmp, struct iomap_ioend, io_list); > > list_del_init(&ioend->io_list); > > + segments += ioend->io_segments; > > iomap_finish_ioend(ioend, error); > > } > > I wonder, should we take one more swing at cond_resched at the end of > the function so that we can return to the caller having given the system > at least one chance to reschedule? That's for the caller of xfs_finish_ioends() to deal with as it loops over each set of merged ioends and does it's own processing. i.e. that's what the cond_resched() I added to the XFS endio processing code here provides: > > void > > xfs_end_io( > > struct work_struct *work) > > @@ -157,6 +170,7 @@ xfs_end_io( > > list_del_init(&ioend->io_list); > > iomap_ioend_try_merge(ioend, &tmp); > > xfs_end_ioend(ioend); > > + cond_resched(); > > } > > } Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx