diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2011-09-12 08:10:22 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-09-25 12:52:44 -0400 |
commit | 9bc5791d4aa78b72abd76f506c0a391a54abc4d1 (patch) | |
tree | 40523d6fd982a91d8c9f1a0741085439d36e6143 /arch/x86/kvm/lapic.c | |
parent | bd80158aff71a80292f96d9baea1a65bc0ce87b3 (diff) |
KVM: x86: Add module parameter for lapic periodic timer limit
Certain guests, specifically RTOSes, request faster periodic timers than
what we allow by default. Add a module parameter to adjust the limit for
non-standard setups. Also add a rate-limited warning in case the guest
requested more.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r-- | arch/x86/kvm/lapic.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 4b53b811d1c1..2fb20caae5d8 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -68,6 +68,9 @@ | |||
68 | #define VEC_POS(v) ((v) & (32 - 1)) | 68 | #define VEC_POS(v) ((v) & (32 - 1)) |
69 | #define REG_POS(v) (((v) >> 5) << 4) | 69 | #define REG_POS(v) (((v) >> 5) << 4) |
70 | 70 | ||
71 | static unsigned int min_timer_period_us = 500; | ||
72 | module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR); | ||
73 | |||
71 | static inline u32 apic_get_reg(struct kvm_lapic *apic, int reg_off) | 74 | static inline u32 apic_get_reg(struct kvm_lapic *apic, int reg_off) |
72 | { | 75 | { |
73 | return *((u32 *) (apic->regs + reg_off)); | 76 | return *((u32 *) (apic->regs + reg_off)); |
@@ -677,8 +680,16 @@ static void start_apic_timer(struct kvm_lapic *apic) | |||
677 | * scheduler. | 680 | * scheduler. |
678 | */ | 681 | */ |
679 | if (apic_lvtt_period(apic)) { | 682 | if (apic_lvtt_period(apic)) { |
680 | if (apic->lapic_timer.period < NSEC_PER_MSEC/2) | 683 | s64 min_period = min_timer_period_us * 1000LL; |
681 | apic->lapic_timer.period = NSEC_PER_MSEC/2; | 684 | |
685 | if (apic->lapic_timer.period < min_period) { | ||
686 | pr_info_ratelimited( | ||
687 | "kvm: vcpu %i: requested %lld ns " | ||
688 | "lapic timer period limited to %lld ns\n", | ||
689 | apic->vcpu->vcpu_id, apic->lapic_timer.period, | ||
690 | min_period); | ||
691 | apic->lapic_timer.period = min_period; | ||
692 | } | ||
682 | } | 693 | } |
683 | 694 | ||
684 | hrtimer_start(&apic->lapic_timer.timer, | 695 | hrtimer_start(&apic->lapic_timer.timer, |