From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsPO-0000Ma-9A for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:56:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXsPK-0003Gs-3w for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:56:06 -0400 Received: from e17.ny.us.ibm.com ([129.33.205.207]:40758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXsPK-0003G6-04 for qemu-devel@nongnu.org; Fri, 04 Sep 2015 10:56:02 -0400 Received: from /spool/local by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 Sep 2015 10:56:00 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id D5EA56E8041 for ; Fri, 4 Sep 2015 10:47:40 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t84EtmBY30998774 for ; Fri, 4 Sep 2015 14:55:56 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t84EtNGo012128 for ; Fri, 4 Sep 2015 10:55:24 -0400 Message-ID: <55E9B0C3.4080807@linux.vnet.ibm.com> Date: Fri, 04 Sep 2015 10:54:59 -0400 From: "Jason J. Herne" MIME-Version: 1.0 References: <1441118763-17510-1-git-send-email-jjherne@linux.vnet.ibm.com> <1441118763-17510-4-git-send-email-jjherne@linux.vnet.ibm.com> <55E6190B.8050501@redhat.com> In-Reply-To: <55E6190B.8050501@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 3/5] migration: Dynamic cpu throttling for auto-converge 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:30 PM, Eric Blake wrote: > On 09/01/2015 08:46 AM, Jason J. Herne wrote: >> Remove traditional auto-converge static 30ms throttling code and replace it >> with a dynamic throttling algorithm. >> >> Additionally, be more aggressive when deciding when to start throttling. >> Previously we waited until four unproductive memory passes. Now we begin >> throttling after only two unproductive memory passes. Four seemed quite >> arbitrary and only waiting for two passes allows us to complete the migration >> faster. >> >> Signed-off-by: Jason J. Herne >> Reviewed-by: Matthew Rosato >> --- >> arch_init.c | 88 ++++++++++++++++++--------------------------------- >> migration/migration.c | 4 +++ >> 2 files changed, 34 insertions(+), 58 deletions(-) > >> +static void mig_throttle_guest_down(void) >> +{ >> + MigrationState *s = migrate_get_current(); >> + uint64_t pct_initial = >> + s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INITIAL]; >> + uint64_t pct_icrement = >> + s->parameters[MIGRATION_PARAMETER_X_CPU_THROTTLE_INCREMENT]; >> + >> + /* We have not started throttling yet. Let's start it. */ >> + if (!cpu_throttle_active()) { >> + cpu_throttle_set(pct_initial); >> + } else { >> + /* Throttling already on, just increase the rate */ >> + cpu_throttle_set(cpu_throttle_get_percentage() + pct_icrement); > > What happens if the addition results in a percentage larger than 99? > cpu_throttle_set takes responsibility for upper/lower bounds capping. +void cpu_throttle_set(int new_throttle_pct) +{ + /* Ensure throttle percentage is within valid range */ + new_throttle_pct = MIN(new_throttle_pct, CPU_THROTTLE_PCT_MAX); + new_throttle_pct = MAX(new_throttle_pct, CPU_THROTTLE_PCT_MIN); + + atomic_set(&throttle_percentage, new_throttle_pct); + + timer_mod(throttle_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + + CPU_THROTTLE_TIMESLICE); +} + -- -- Jason J. Herne (jjherne@linux.vnet.ibm.com)