On 09/01/2015 08:45 AM, Jason J. Herne wrote:
Provide a method to throttle guest cpu execution. CPUState is augmented with
timeout controls and throttle start/stop functions. To throttle the guest cpu
the caller simply has to call the throttle set function and provide a percentage
of throttle time.
Signed-off-by: Jason J. Herne <address@hidden>
Reviewed-by: Matthew Rosato <address@hidden>
---
cpus.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/qom/cpu.h | 43 ++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+)
+/**
+ * cpu_throttle_set:
+ * @new_throttle_pct: Percent of sleep time to running time.
I don't think you mean the ratio of sleep time to running time, as much
as sleep time to overall time.
That is, 10% should mean "sleep 1ms and run 9ms out of every 10ms
total", and not "sleep 1ms after every 10ms run, for 90.9% duty cycle".
+ * Valid range is 1 to 99.
+ *
+ * Throttles all vcpus by forcing them to sleep for the given percentage of
+ * time. A throttle_percentage of 50 corresponds to a 50% duty cycle roughly.
+ * (example: 10ms sleep for every 10ms awake).
50% can be a bit ambiguous (not obvious whether a higher percentage
means more sleep or more time awake); it might be better to pick a
different number, such as:
A throttle_percentage of 25 corresponds to a 75% duty cycle (example:
10ms sleep for every 30ms awake).
if the percentage really is [1 - duty cycle] (which I suspect), or:
A throttle_percentage of 25 corresponds to a 80% duty cycle (example:
10ms sleep for every 40ms awake).
(if I'm wrong, and you really meant percentage of sleep time to running
time).