Received: from eggs.gnu.org ([2001:4830:134:3::10]:40420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8WOH-0003DC-TK for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:45:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8WO8-0006pk-Kn for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:45:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8WO8-0006pe-D5 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 09:45:12 -0500 Date: Wed, 29 Jan 2014 15:45:08 +0100 From: Stefan Hajnoczi Message-ID: <20140129144508.GH23531@stefanha-thinkpad.muc.redhat.com> References: <1390984843-2101-1-git-send-email-famz@redhat.com> <1390984843-2101-5-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1390984843-2101-5-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-iotests: Add 080 for IO throttling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org On Wed, Jan 29, 2014 at 04:40:43PM +0800, Fam Zheng wrote: > + def do_test_throttle(self, seconds=10, **limits): > + def check_limit(limit, num): > + # IO throttling algorithm is discrete, allow 10% error so the test > + # is more deterministic > + return limit == 0 or num < seconds * limit * 1.1 > + > + nsec_per_sec = 1000000000 > + > + limits['bps_max'] = 1 > + limits['iops_max'] = 1 > + > + # Enqueue many requests to throttling queue > + result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **limits) > + self.assert_qmp(result, 'return', {}) > + > + # Set vm clock to a known value > + ns = nsec_per_sec > + self.vm.qtest_cmd("clock_step %d" % ns) > + > + # Append many requests into the throttle queue > + # They drain bps_max and iops_max > + # The rest requests won't get executed until qtest clock is driven > + for i in range(1000): > + self.vm.hmp_qemu_io("drive0", "aio_read -a -q 0 512") > + self.vm.hmp_qemu_io("drive0", "aio_write -a -q 0 512") > + > + start_rd_bytes, start_rd_iops, start_wr_bytes, start_wr_iops = self.blockstats('drive0') > + > + ns += seconds * nsec_per_sec > + self.vm.qtest_cmd("clock_step %d" % ns) > + # wait for a while to let requests take off > + time.sleep(1) > + end_rd_bytes, end_rd_iops, end_wr_bytes, end_wr_iops = self.blockstats('drive0') > + > + rd_bytes = end_rd_bytes - start_rd_bytes > + rd_iops = end_rd_iops - start_rd_iops > + wr_bytes = end_wr_bytes - start_wr_bytes > + wr_iops = end_wr_iops - start_wr_iops > + > + assert check_limit(limits['bps'], rd_bytes) > + assert check_limit(limits['bps_rd'], rd_bytes) > + assert check_limit(limits['bps'], wr_bytes) > + assert check_limit(limits['bps_wr'], wr_bytes) > + assert check_limit(limits['iops'], rd_iops) > + assert check_limit(limits['iops_rd'], rd_iops) > + assert check_limit(limits['iops'], wr_iops) > + assert check_limit(limits['iops_wr'], wr_iops) > + > + def test_bps(self): > + self.do_test_throttle(**{ > + 'device': 'drive0', > + 'bps': 1000, > + 'bps_rd': 0, > + 'bps_wr': 0, > + 'iops': 0, > + 'iops_rd': 0, > + 'iops_wr': 0, > + }) > + > + def test_bps_rd(self): > + self.do_test_throttle(**{ > + 'device': 'drive0', > + 'bps': 0, > + 'bps_rd': 1000, > + 'bps_wr': 0, > + 'iops': 0, > + 'iops_rd': 0, > + 'iops_wr': 0, > + }) I guess you'll get more stable behavior with 1024 instead of 1000. The request themselves are 512 bytes. As a side note, I think we'll wait for all 1000 pending requests each time QEMU shuts down. Probably not a huge time waste but even 100 requests exceed the I/O limits you've specified. Perhaps using just 100 will make the test slightly faster.