KVM: Convert kvm_lock to raw_spinlock
PATCH 1/2 KVM: Convert kvm_lock to raw_spinlock
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/mmu.c | 4 ++-- arch/x86/kvm/x86.c | 4 ++-- virt/kvm/kvm_main.c | 36 ++++++++++++++++++------------------ 4 files changed, 23 insertions(+), 23 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -85,7 +85,7 @@#define ASYNC_PF_PER_VCPU 64 -extern spinlock_t kvm_lock; +extern raw_spinlock_t kvm_lock;extern struct list_head vm_list;struct kvm_vcpu ;
arch/x86/kvm/mmu.c +2 -2
@@ -3587,7 +3587,7 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)if (nr_to_scan ==0 ) goto out; -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_for_each_entry (kvm, &vm_list, vm_list) {int idx, freed_pages;
@@ -3610,7 +3610,7 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)if (kvm_freed)list_move_tail (&kvm_freed->vm_list, &vm_list); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock); out:return percpu_counter_read_positive (&kvm_total_used_mmu_pages);
arch/x86/kvm/x86.c +2 -2
@@ -4578,7 +4578,7 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long vasmp_call_function_single (freq->cpu, tsc_khz_changed, freq,1 ); -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_for_each_entry (kvm, &vm_list, vm_list) {kvm_for_each_vcpu (i, vcpu, kvm) {if (vcpu->cpu != freq->cpu)
@@ -4588,7 +4588,7 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va send_ipi =1 ; } } -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);if (freq->old < freq->new && send_ipi) {/*
virt/kvm/kvm_main.c +18 -18
@@ -69,7 +69,7 @@ MODULE_LICENSE("GPL");* kvm->lock --> kvm->slots_lock --> kvm->irq_lock */ -DEFINE_SPINLOCK (kvm_lock); +DEFINE_RAW_SPINLOCK (kvm_lock);LIST_HEAD (vm_list);static cpumask_var_t cpus_hardware_enabled;
@@ -471,9 +471,9 @@ static struct kvm *kvm_create_vm(void)mutex_init (&kvm->irq_lock);mutex_init (&kvm->slots_lock);atomic_set (&kvm->users_count,1 ); -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_add (&kvm->vm_list, &vm_list); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);return kvm;
@@ -546,9 +546,9 @@ static void kvm_destroy_vm(struct kvm *kvm)struct mm_struct *mm = kvm->mm;kvm_arch_sync_events (kvm); -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_del (&kvm->vm_list); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);kvm_free_irq_routing (kvm);for (i =0 ; i <KVM_NR_BUSES ; i++)kvm_io_bus_destroy (kvm->buses[i]);
@@ -2130,9 +2130,9 @@ static void hardware_enable_nolock(void *junk)static void hardware_enable (void *junk) { -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);hardware_enable_nolock (junk); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock); }static void hardware_disable_nolock (void *junk)
@@ -2147,9 +2147,9 @@ static void hardware_disable_nolock(void *junk)static void hardware_disable (void *junk) { -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);hardware_disable_nolock (junk); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock); }static void hardware_disable_all_nolock (void )
@@ -2163,16 +2163,16 @@ static void hardware_disable_all_nolock(void)static void hardware_disable_all (void ) { -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);hardware_disable_all_nolock (); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock); }static int hardware_enable_all (void ) {int r =0 ; -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock); kvm_usage_count++;if (kvm_usage_count ==1 ) {
@@ -2185,7 +2185,7 @@ static int hardware_enable_all(void) } } -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);return r; }
@@ -2347,10 +2347,10 @@ static int vm_stat_get(void *_offset, u64 *val)struct kvm *kvm; *val =0 ; -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_for_each_entry (kvm, &vm_list, vm_list) *val += *(u32 *)((void *)kvm + offset); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);return 0 ; }
@@ -2364,12 +2364,12 @@ static int vcpu_stat_get(void *_offset, u64 *val)int i; *val =0 ; -spin_lock (&kvm_lock); +raw_spin_lock (&kvm_lock);list_for_each_entry (kvm, &vm_list, vm_list)kvm_for_each_vcpu (i, vcpu, kvm) *val += *(u32 *)((void *)vcpu + offset); -spin_unlock (&kvm_lock); +raw_spin_unlock (&kvm_lock);return 0 ; }
@@ -2410,7 +2410,7 @@ static int kvm_suspend(struct sys_device *dev, pm_message_t state)static int kvm_resume (struct sys_device *dev) {if (kvm_usage_count) { -WARN_ON (spin_is_locked (&kvm_lock)); +WARN_ON (raw_spin_is_locked (&kvm_lock));hardware_enable_nolock (NULL ); }return 0 ;
Signature · 1 line
1.7.1
Quoted 3 lines · Jan Kiszka
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
Please add a code comment documenting what data under this lock requires it to be a raw spinlock.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 7 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
Please add a code comment documenting what data under this lock requires it to be a raw spinlock.
Or better, put it in Documentation/kvm/locking.txt, which we'll try to grow to cover all locks.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
Quoted 7 lines
Quoted 3 lines
Please add a code comment documenting what data under this lock requires it to be a raw spinlock.
Or better, put it in
Documentation/kvm/locking.txt, which we'll try to grow to cover all locks.
Something like
[Documentation/kvm/locking.txt]
KVM Lock Overview
-----------------
1. Spin locks
1.1 tsc_write_lock
Type: raw
Arch: x86
Protects: kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
tsc offset in vmcb
Comment: 'raw' because updating the tsc offsets must not be preempted
...
?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 25 lines · Jan Kiszka
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
Quoted 7 lines
Quoted 3 lines
Please add a code comment documenting what data under this lock requires it to be a raw spinlock.
Or better, put it in
Documentation/kvm/locking.txt, which we'll try to grow to cover all locks.Something like
[
Documentation/kvm/locking.txt]
KVM Lock Overview
-----------------1. Spin locks
1.1
tsc_write_lock
Quoted 8 lines
Type: raw
Arch: x86
Protects: kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset}
tsc offset in vmcb
Comment: 'raw' because updating the tsc offsets must not be preempted
...?
Yes. I wouldn't sort them by type though, that changes from time to time.
Signature · 1 line
error compiling committee.c: too many arguments to function
Avi Kivity
AppliedQuoted 3 lines · Jan Kiszka
Code under this lock requires non-preemptibility. Ensure this also over -rt by converting it to raw spinlock.
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function