From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEexj-0003TQ-LM for qemu-devel@nongnu.org; Mon, 13 Jul 2015 10:44:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEexg-000544-Qt for qemu-devel@nongnu.org; Mon, 13 Jul 2015 10:44:07 -0400 Received: from e18.ny.us.ibm.com ([129.33.205.208]:36438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEexg-00053F-Lh for qemu-devel@nongnu.org; Mon, 13 Jul 2015 10:44:04 -0400 Received: from /spool/local by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 13 Jul 2015 10:44:02 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 5DFC338C8051 for ; Mon, 13 Jul 2015 10:44:00 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t6DEi0TU47972356 for ; Mon, 13 Jul 2015 14:44:00 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t6DEhxCM000936 for ; Mon, 13 Jul 2015 10:44:00 -0400 Message-ID: <55A3CEAF.6030504@linux.vnet.ibm.com> Date: Mon, 13 Jul 2015 10:43:59 -0400 From: "Jason J. Herne" MIME-Version: 1.0 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> In-Reply-To: <55956A2E.4020806@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 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: Paolo Bonzini , afaerber@suse.de, amit.shah@redhat.com, dgilbert@redhat.com, borntraeger@de.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org On 07/02/2015 12:43 PM, Paolo Bonzini 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? > > Paolo > > > I'm not sure how callbacks can pile up here. If the vcpus are running then their thread's will execute the callbacks. If they are not running then the use of QEMU_CLOCK_VIRTUAL_RT will prevent the callbacks from stacking because the timer is not running, right? -- -- Jason J. Herne (jjherne@linux.vnet.ibm.com)