From: Joerg Roedel Subject: [PATCH] kvm: iommu: Add cond_resched to legacy device assignment code Date: Tue, 16 Dec 2014 16:47:26 +0100 Message-ID: <1418744846-12868-1-git-send-email-joro@8bytes.org> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel To: Gleb Natapov , Paolo Bonzini Return-path: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org From: Joerg Roedel 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 --- virt/kvm/iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index c1e6ae9..ac427e8 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c @@ -137,7 +137,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot) gfn += page_size >> PAGE_SHIFT; - + cond_resched(); } return 0; @@ -311,6 +311,8 @@ static void kvm_iommu_put_pages(struct kvm *kvm, kvm_unpin_pages(kvm, pfn, unmap_pages); gfn += unmap_pages; + + cond_resched(); } } -- 1.9.1