Reviewed-by: Paul E. McKenney <paulmck@xxxxxxxxxx> > --- > v1->v2: > > Merged up to vfio/next > > Moved the cond_resched() to a more appropriate place within the > loop, and added a comment about why it's there. > > Update to change log describing one of the consequences of not doing > this. > > drivers/vfio/vfio_iommu_type1.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 1136d7ac6b597..ad599b1601711 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -647,6 +647,13 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr, > > while (npage) { > if (!batch->size) { > + /* > + * Large mappings may take a while to repeatedly refill > + * the batch, so conditionally relinquish the CPU when > + * needed to avoid stalls. > + */ > + cond_resched(); > + > /* Empty batch, so refill it. */ > ret = vaddr_get_pfns(mm, vaddr, npage, dma->prot, > &pfn, batch); > -- > 2.47.1 >