Skip to content

Commit 128ca09

Browse files
joergroedelbonzini
authored andcommitted
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: Joerg Roedel <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8226808 commit 128ca09

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/iommu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
138138

139139
gfn += page_size >> PAGE_SHIFT;
140140

141-
141+
cond_resched();
142142
}
143143

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

308308
gfn += unmap_pages;
309+
310+
cond_resched();
309311
}
310312
}
311313

0 commit comments

Comments
 (0)