From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXslA-00078j-EV for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:18:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXsl7-0006Ey-66 for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:18:36 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:52849) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsl7-0006El-0Y for qemu-devel@nongnu.org; Fri, 04 Sep 2015 11:18:33 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 Sep 2015 09:18:32 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 7B21719D804A for ; Fri, 4 Sep 2015 09:09:24 -0600 (MDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t84FITU441943062 for ; Fri, 4 Sep 2015 08:18:29 -0700 Received: from d03av03.boulder.ibm.com (localhost [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t84FITQ1019582 for ; Fri, 4 Sep 2015 09:18:29 -0600 Message-ID: <55E9B622.7040708@linux.vnet.ibm.com> Date: Fri, 04 Sep 2015 11:17:54 -0400 From: "Jason J. Herne" MIME-Version: 1.0 References: <1441118763-17510-1-git-send-email-jjherne@linux.vnet.ibm.com> <1441118763-17510-2-git-send-email-jjherne@linux.vnet.ibm.com> <55E6173F.5000800@redhat.com> In-Reply-To: <55E6173F.5000800@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 1/5] cpu: Provide vcpu throttling interface Reply-To: jjherne@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , afaerber@suse.de, amit.shah@redhat.com, dgilbert@redhat.com, borntraeger@de.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com On 09/01/2015 05:23 PM, Eric Blake wrote: > 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 >> Reviewed-by: Matthew Rosato >> --- >> 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). > You are 100% correct here. This comment is a relic of an older version. Nice find :) I'll update the docs and incorporate your suggestions. -- -- Jason J. Herne (jjherne@linux.vnet.ibm.com)