From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAhon-0000IJ-GO for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:58:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAhoj-0006pz-AP for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:58:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAhoj-0006pp-59 for qemu-devel@nongnu.org; Thu, 02 Jul 2015 12:58:29 -0400 Date: Thu, 2 Jul 2015 17:58:23 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150702165823.GE2226@work-vm> References: <1435855010-30882-1-git-send-email-jjherne@linux.vnet.ibm.com> <1435855010-30882-2-git-send-email-jjherne@linux.vnet.ibm.com> <55956A2E.4020806@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55956A2E.4020806@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 1/5] cpu: Provide vcpu throttling interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: quintela@redhat.com, dgilbert@redhat.com, qemu-devel@nongnu.org, borntraeger@de.ibm.com, "Jason J. Herne" , amit.shah@redhat.com, afaerber@suse.de * Paolo Bonzini (pbonzini@redhat.com) wrote: > > > On 02/07/2015 18:36, Jason J. Herne wrote: > > +static void cpu_throttle_thread(void *opaque) > > +{ > > + double pct = (double)throttle_percentage/100; > > + double throttle_ratio = pct / (1 - pct); > > + long sleeptime_ms = (long)(throttle_ratio * CPU_THROTTLE_TIMESLICE); > > + > > + if (!throttle_percentage) { > > + return; > > + } > > + > > + qemu_mutex_unlock_iothread(); > > + g_usleep(sleeptime_ms * 1000); /* Convert ms to us for usleep call */ > > + qemu_mutex_lock_iothread(); > > +} > > + > > +static void cpu_throttle_timer_tick(void *opaque) > > +{ > > + CPUState *cpu; > > + > > + /* Stop the timer if needed */ > > + if (!throttle_percentage) { > > + return; > > + } > > + CPU_FOREACH(cpu) { > > + async_run_on_cpu(cpu, cpu_throttle_thread, NULL); > > + } > > + > > + timer_mod(throttle_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL_RT) + > > + CPU_THROTTLE_TIMESLICE); > > +} > > This could cause callbacks to pile up I think. David, do you have any > idea how to fix it? I don't know the timer code well enough. Dave > > Paolo -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK