diff options
author | Peter Chubb <peter.chubb@nicta.com.au> | 2012-04-20 15:32:30 +1000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-04-24 09:50:31 -0500 |
commit | cf36b31db209a261ee3bc2737e788e1ced0a1bec (patch) | |
tree | 331593a1b14358cba1b72dd622971274e58c77d5 | |
parent | dfe47e7029e117f65a14c0948021654f7f7d5d05 (diff) | |
download | qemu-cf36b31db209a261ee3bc2737e788e1ced0a1bec.zip qemu-cf36b31db209a261ee3bc2737e788e1ced0a1bec.tar.gz qemu-cf36b31db209a261ee3bc2737e788e1ced0a1bec.tar.bz2 |
Limit ptimer rate to something achievable
If a guest sets very short timeouts, and asks for a timer to be reloaded on
timeout, QEMU can go to 100%CPU utilisation and become unresponsive,
as it is spending all its time generating timeout interrupts. On real
hardware this doesn't matter, as the interrupts are just coalesced,
and the effect is to have the interrupt asserted all the time.
This patch is a band-aid, that prevents timeouts less than 10
microseconds from being set. 10 microseconds is a limit that was
determined empirically on a variety of machines as the shortest that
allowed QEMU to pick up a control-a c sequence to get at the monitor.
Reported-by: Anna Lyons <anna.lyons@nicta.com.au>
Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | hw/ptimer.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/ptimer.c b/hw/ptimer.c index de7d664..bc0b3f8 100644 --- a/hw/ptimer.c +++ b/hw/ptimer.c @@ -180,6 +180,19 @@ void ptimer_set_freq(ptimer_state *s, uint32_t freq) count = limit. */ void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload) { + /* + * Artificially limit timeout rate to something + * achievable under QEMU. Otherwise, QEMU spends all + * its time generating timer interrupts, and there + * is no forward progress. + * About ten microseconds is the fastest that really works + * on the current generation of host machines. + */ + + if (limit * s->period < 10000 && s->period) { + limit = 10000 / s->period; + } + s->limit = limit; if (reload) s->delta = limit; |