diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/kvm_host.h | 39 | ||||
| -rw-r--r-- | include/linux/vtime.h | 2 |
2 files changed, 30 insertions, 11 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 2c497ab0d03d..4fe2396401da 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/rcupdate.h> | 22 | #include <linux/rcupdate.h> |
| 23 | #include <linux/ratelimit.h> | 23 | #include <linux/ratelimit.h> |
| 24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 25 | #include <linux/irqflags.h> | ||
| 25 | #include <asm/signal.h> | 26 | #include <asm/signal.h> |
| 26 | 27 | ||
| 27 | #include <linux/kvm.h> | 28 | #include <linux/kvm.h> |
| @@ -740,15 +741,36 @@ static inline int kvm_deassign_device(struct kvm *kvm, | |||
| 740 | } | 741 | } |
| 741 | #endif /* CONFIG_IOMMU_API */ | 742 | #endif /* CONFIG_IOMMU_API */ |
| 742 | 743 | ||
| 743 | static inline void kvm_guest_enter(void) | 744 | static inline void guest_enter(void) |
| 744 | { | 745 | { |
| 745 | BUG_ON(preemptible()); | ||
| 746 | /* | 746 | /* |
| 747 | * This is running in ioctl context so we can avoid | 747 | * This is running in ioctl context so we can avoid |
| 748 | * the call to vtime_account() with its unnecessary idle check. | 748 | * the call to vtime_account() with its unnecessary idle check. |
| 749 | */ | 749 | */ |
| 750 | vtime_account_system_irqsafe(current); | 750 | vtime_account_system(current); |
| 751 | current->flags |= PF_VCPU; | 751 | current->flags |= PF_VCPU; |
| 752 | } | ||
| 753 | |||
| 754 | static inline void guest_exit(void) | ||
| 755 | { | ||
| 756 | /* | ||
| 757 | * This is running in ioctl context so we can avoid | ||
| 758 | * the call to vtime_account() with its unnecessary idle check. | ||
| 759 | */ | ||
| 760 | vtime_account_system(current); | ||
| 761 | current->flags &= ~PF_VCPU; | ||
| 762 | } | ||
| 763 | |||
| 764 | static inline void kvm_guest_enter(void) | ||
| 765 | { | ||
| 766 | unsigned long flags; | ||
| 767 | |||
| 768 | BUG_ON(preemptible()); | ||
| 769 | |||
| 770 | local_irq_save(flags); | ||
| 771 | guest_enter(); | ||
| 772 | local_irq_restore(flags); | ||
| 773 | |||
| 752 | /* KVM does not hold any references to rcu protected data when it | 774 | /* KVM does not hold any references to rcu protected data when it |
| 753 | * switches CPU into a guest mode. In fact switching to a guest mode | 775 | * switches CPU into a guest mode. In fact switching to a guest mode |
| 754 | * is very similar to exiting to userspase from rcu point of view. In | 776 | * is very similar to exiting to userspase from rcu point of view. In |
| @@ -761,12 +783,11 @@ static inline void kvm_guest_enter(void) | |||
| 761 | 783 | ||
| 762 | static inline void kvm_guest_exit(void) | 784 | static inline void kvm_guest_exit(void) |
| 763 | { | 785 | { |
| 764 | /* | 786 | unsigned long flags; |
| 765 | * This is running in ioctl context so we can avoid | 787 | |
| 766 | * the call to vtime_account() with its unnecessary idle check. | 788 | local_irq_save(flags); |
| 767 | */ | 789 | guest_exit(); |
| 768 | vtime_account_system_irqsafe(current); | 790 | local_irq_restore(flags); |
| 769 | current->flags &= ~PF_VCPU; | ||
| 770 | } | 791 | } |
| 771 | 792 | ||
| 772 | /* | 793 | /* |
diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 5368af9bdf06..bb50c3ca0d79 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h | |||
| @@ -6,7 +6,6 @@ struct task_struct; | |||
| 6 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | 6 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
| 7 | extern void vtime_task_switch(struct task_struct *prev); | 7 | extern void vtime_task_switch(struct task_struct *prev); |
| 8 | extern void vtime_account_system(struct task_struct *tsk); | 8 | extern void vtime_account_system(struct task_struct *tsk); |
| 9 | extern void vtime_account_system_irqsafe(struct task_struct *tsk); | ||
| 10 | extern void vtime_account_idle(struct task_struct *tsk); | 9 | extern void vtime_account_idle(struct task_struct *tsk); |
| 11 | extern void vtime_account_user(struct task_struct *tsk); | 10 | extern void vtime_account_user(struct task_struct *tsk); |
| 12 | extern void vtime_account(struct task_struct *tsk); | 11 | extern void vtime_account(struct task_struct *tsk); |
| @@ -20,7 +19,6 @@ static inline bool vtime_accounting_enabled(void) { return true; } | |||
| 20 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ | 19 | #else /* !CONFIG_VIRT_CPU_ACCOUNTING */ |
| 21 | static inline void vtime_task_switch(struct task_struct *prev) { } | 20 | static inline void vtime_task_switch(struct task_struct *prev) { } |
| 22 | static inline void vtime_account_system(struct task_struct *tsk) { } | 21 | static inline void vtime_account_system(struct task_struct *tsk) { } |
| 23 | static inline void vtime_account_system_irqsafe(struct task_struct *tsk) { } | ||
| 24 | static inline void vtime_account_user(struct task_struct *tsk) { } | 22 | static inline void vtime_account_user(struct task_struct *tsk) { } |
| 25 | static inline void vtime_account(struct task_struct *tsk) { } | 23 | static inline void vtime_account(struct task_struct *tsk) { } |
| 26 | static inline bool vtime_accounting_enabled(void) { return false; } | 24 | static inline bool vtime_accounting_enabled(void) { return false; } |
