From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUNpn-0001Dn-1G for qemu-devel@nongnu.org; Mon, 22 Apr 2013 16:59:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUNpk-0003j4-6x for qemu-devel@nongnu.org; Mon, 22 Apr 2013 16:59:34 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:60231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUNpk-0003i3-1L for qemu-devel@nongnu.org; Mon, 22 Apr 2013 16:59:32 -0400 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Apr 2013 14:59:30 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id EB23B19D8041 for ; Mon, 22 Apr 2013 14:59:21 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3MKxPtR096990 for ; Mon, 22 Apr 2013 14:59:26 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3MKxGF0015979 for ; Mon, 22 Apr 2013 14:59:16 -0600 Message-ID: <5175A4A1.7070307@linux.vnet.ibm.com> Date: Mon, 22 Apr 2013 16:59:13 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <1366579081-6857-1-git-send-email-mrhines@linux.vnet.ibm.com> <1366579081-6857-5-git-send-email-mrhines@linux.vnet.ibm.com> <51759B89.5040107@redhat.com> In-Reply-To: <51759B89.5040107@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 04/12] rdma: introduce qemu_get_max_size() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: aliguori@us.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com On 04/22/2013 04:20 PM, Eric Blake wrote: > On 04/21/2013 03:17 PM, mrhines@linux.vnet.ibm.com wrote: >> From: "Michael R. Hines" >> >> This functions allows you to perform your own per-QEMUFileOps >> calculation for the value of 'max_size'. >> >> For RDMA, this calculation artificially limits migration throughput >> and needs to be done differently for high-throughput links. >> >> Signed-off-by: Michael R. Hines >> --- >> >> +size_t qemu_get_max_size(QEMUFile *f, uint64_t transferred_bytes, >> + uint64_t time_spent, uint64_t max_downtime) >> +{ >> + if (time_spent) { >> + mbps = (((double) transferred_bytes * 8.0) / >> + ((double) time_spent / 1000.0)) / 1000.0 / 1000.0; >> + } else { >> + mbps = -1.0; >> + } >> + >> + if (f->ops->get_max_size) { >> + return f->ops->get_max_size(f, f->opaque, >> + transferred_bytes, time_spent, max_downtime); >> + } >> + >> + return ((double) (transferred_bytes / time_spent)) * >> + max_downtime / 1000000; > Cast to double is too late; you've already suffered from integer > division truncation when you compute (transferred_bytes/time_spent). > Good catch, thank you.