Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 128ca093 authored by Joerg Roedel's avatar Joerg Roedel Committed by Paolo Bonzini
Browse files

kvm: iommu: Add cond_resched to legacy device assignment code



When assigning devices to large memory guests (>=128GB guest
memory in the failure case) the functions to create the
IOMMU page-tables for the whole guest might run for a very
long time. On non-preemptible kernels this might cause
Soft-Lockup warnings. Fix these by adding a cond_resched()
to the mapping and unmapping loops.

Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 82268083
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -138,7 +138,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)


		gfn += page_size >> PAGE_SHIFT;
		gfn += page_size >> PAGE_SHIFT;



		cond_resched();
	}
	}


	return 0;
	return 0;
@@ -306,6 +306,8 @@ static void kvm_iommu_put_pages(struct kvm *kvm,
		kvm_unpin_pages(kvm, pfn, unmap_pages);
		kvm_unpin_pages(kvm, pfn, unmap_pages);


		gfn += unmap_pages;
		gfn += unmap_pages;

		cond_resched();
	}
	}
}
}