Skip to contentSkip to conversation

kvm: iommu: Add cond_resched to legacy device assignment code

PATCH Superseded Joerg Roedel 4 participants 5 messages Dec 16, 2014 – Dec 17, 2014 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: iommu: Add cond_resched to legacy device assignment code

From: Joerg Roedel <[email protected]>

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.

---
 virt/kvm/iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/iommu.c +3 -1
index c1e6ae9..ac427e8 100644
@@ -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();
 	}
 }
 
Signature · 1 line
1.9.1
#1 lore raw

virt/kvm/iommu.c

Quoted 18 lines · Joerg Roedel

From: Joerg Roedel <[email protected]>

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.

---
  virt/kvm/iommu.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
virt/kvm/iommu.c +0 -0
index c1e6ae9..ac427e8 100644

This file is already gone after one latest commit c274e03af705, "kvm: x86: move assigned-dev.c and iommu.c to arch/x86/" is introduced, so you need to pull your tree firstly :)

Tiejun

Quoted 19 lines
virt/kvm/iommu.c +3 -1
@@ -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();
  	}
  }
 
#2 lore raw
Quoted 9 lines · Tiejun

virt/kvm/iommu.c

Quoted 4 lines · Joerg Roedel
virt/kvm/iommu.c +0 -0
index c1e6ae9..ac427e8 100644

This file is already gone after one latest commit c274e03af705, "kvm: x86: move assigned-dev.c and iommu.c to arch/x86/" is introduced, so you need to pull your tree firstly :)

Hmm, I based the patch on kvm/master, where the file is still present. What is the branch to base kvm patches on these days?

Joerg

maintainer
#3 lore raw
Quoted 6 lines · Joerg Roedel
Quoted 4 lines
Quoted 4 lines

This file is already gone after one latest commit c274e03af705, "kvm: x86: move assigned-dev.c and iommu.c to arch/x86/" is introduced, so you need to pull your tree firstly :)

Hmm, I based the patch on kvm/master, where the file is still present. What is the branch to base kvm patches on these days?

kvm/master in the -rc period, kvm/next during the merge window and for the next release. But it's not a problem, I can sort it out.

Paolo

#4 lore raw
Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Joerg Roedel
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

This file is already gone after one latest commit c274e03af705, "kvm: x86: move assigned-dev.c and iommu.c to arch/x86/" is introduced, so you need to pull your tree firstly :)

Hmm, I based the patch on kvm/master, where the file is still present. What is the branch to base kvm patches on these days?

kvm/master in the -rc period, kvm/next during the merge window and for the next release. But it's not a problem, I can sort it out.

Great, thanks Paolo. So I will base my future patches on kvm/next.

Joerg