From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaU82-00013W-Nh for qemu-devel@nongnu.org; Mon, 19 Nov 2012 11:23:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaU7w-0004qh-Ba for qemu-devel@nongnu.org; Mon, 19 Nov 2012 11:23:22 -0500 Received: from mail-pb0-f45.google.com ([209.85.160.45]:42899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaU7w-0004qd-5T for qemu-devel@nongnu.org; Mon, 19 Nov 2012 11:23:16 -0500 Received: by mail-pb0-f45.google.com with SMTP id mc8so3443579pbc.4 for ; Mon, 19 Nov 2012 08:23:15 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 19 Nov 2012 17:23:00 +0100 Message-Id: <1353342180-20392-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] migration: fix rate limiting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: owasserm@redhat.com, quintela@redhat.com buffered_rate_limit is called to prevent the RAM migration callback from putting too much data in the buffer. So it has to check against the amount of data currently in the buffer, not against the amount of data that has been transferred so far. s->bytes_xfer is used to communicate between successive calls of buffered_put_buffer. Buffered_rate_tick resets it every now and then to prevent moving too much buffered data to the socket at once. However, its value does not matter for the producer of the data. Here is the result for migrating an idle guest with 3GB of memory and ~360MB of non-zero memory: migrate_set_speed Before After ------------------------------------------------------------ default (32MB/sec) ~3 sec ~13 sec infinite (10GB/sec) ~3 sec ~3 sec Note that before this patch, QEMU is transferring of 100 MB/sec despite the rate limiting. Signed-off-by: Paolo Bonzini --- buffered_file.c | 2 +- 1 file modificato, 1 inserzione(+). 1 rimozione(-) diff --git a/buffered_file.c b/buffered_file.c index bd0f61d..46cd591 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -193,7 +193,7 @@ static int buffered_rate_limit(void *opaque) if (s->freeze_output) return 1; - if (s->bytes_xfer > s->xfer_limit) + if (s->buffer_size > s->xfer_limit) return 1; return 0; -- 1.7.12.1