projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e09fefd
)
KVM: use heuristic for fast VCPU lookup by id
author
David Hildenbrand
<
[email protected]
>
Thu, 5 Nov 2015 08:55:08 +0000
(09:55 +0100)
committer
Christian Borntraeger
<
[email protected]
>
Mon, 30 Nov 2015 11:47:04 +0000
(12:47 +0100)
Usually, VCPU ids match the array index. So let's try a fast
lookup first before falling back to the slow iteration.
Suggested-by: Christian Borntraeger <
[email protected]
>
Reviewed-by: Dominik Dingel <
[email protected]
>
Reviewed-by: Christian Borntraeger <
[email protected]
>
Signed-off-by: David Hildenbrand <
[email protected]
>
Signed-off-by: Christian Borntraeger <
[email protected]
>
include/linux/kvm_host.h
patch
|
blob
|
history
diff --git
a/include/linux/kvm_host.h
b/include/linux/kvm_host.h
index 29119193a19fc603bc616dfce4a3ca9d588f1332..a754fc08e194d90287c9abc6793cb3866407d04c 100644
(file)
--- a/
include/linux/kvm_host.h
+++ b/
include/linux/kvm_host.h
@@
-472,6
+472,11
@@
static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id)
struct kvm_vcpu *vcpu;
int i;
+ if (id < 0 || id >= KVM_MAX_VCPUS)
+ return NULL;
+ vcpu = kvm_get_vcpu(kvm, id);
+ if (vcpu && vcpu->vcpu_id == id)
+ return vcpu;
kvm_for_each_vcpu(i, vcpu, kvm)
if (vcpu->vcpu_id == id)
return vcpu;