[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 35/44] block: Use QEMU_CLOCK_VIRTUAL for the acco
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PULL 35/44] block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode |
Date: |
Tue, 10 Nov 2015 16:08:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 10/11/2015 15:14, Stefan Hajnoczi wrote:
> From: Alberto Garcia <address@hidden>
>
> This patch switches to QEMU_CLOCK_VIRTUAL for the accounting code in
> qtest mode, and makes the latency of the operation constant. This way we
> can perform tests on the accounting code with reproducible results.
>
> Signed-off-by: Alberto Garcia <address@hidden>
> Message-id: address@hidden
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> block/accounting.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/block/accounting.c b/block/accounting.c
> index a941931..05a5c5f 100644
> --- a/block/accounting.c
> +++ b/block/accounting.c
> @@ -25,14 +25,20 @@
> #include "block/accounting.h"
> #include "block/block_int.h"
> #include "qemu/timer.h"
> +#include "sysemu/qtest.h"
>
> static QEMUClockType clock_type = QEMU_CLOCK_REALTIME;
> +static const int qtest_latency_ns = NANOSECONDS_PER_SECOND / 1000;
>
> void block_acct_init(BlockAcctStats *stats, bool account_invalid,
> bool account_failed)
> {
> stats->account_invalid = account_invalid;
> stats->account_failed = account_failed;
> +
> + if (qtest_enabled()) {
> + clock_type = QEMU_CLOCK_VIRTUAL;
> + }
> }
>
> void block_acct_cleanup(BlockAcctStats *stats)
> @@ -84,6 +90,10 @@ void block_acct_done(BlockAcctStats *stats,
> BlockAcctCookie *cookie)
> int64_t time_ns = qemu_clock_get_ns(clock_type);
> int64_t latency_ns = time_ns - cookie->start_time_ns;
>
> + if (qtest_enabled()) {
> + latency_ns = qtest_latency_ns;
> + }
> +
> assert(cookie->type < BLOCK_MAX_IOTYPE);
>
> stats->nr_bytes[cookie->type] += cookie->bytes;
> @@ -107,6 +117,10 @@ void block_acct_failed(BlockAcctStats *stats,
> BlockAcctCookie *cookie)
> int64_t time_ns = qemu_clock_get_ns(clock_type);
> int64_t latency_ns = time_ns - cookie->start_time_ns;
>
> + if (qtest_enabled()) {
> + latency_ns = qtest_latency_ns;
> + }
> +
> stats->total_time_ns[cookie->type] += latency_ns;
> stats->last_access_time_ns = time_ns;
>
>
Using QEMU_CLOCK_VIRTUAL makes sense but for the other part, could the
test instead use the null backend?
Paolo
- [Qemu-devel] [PULL 30/44] block: Allow configuring whether to account failed and invalid ops, (continued)
- [Qemu-devel] [PULL 30/44] block: Allow configuring whether to account failed and invalid ops, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 29/44] block: Add statistics for failed and invalid I/O operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 32/44] block: Add average I/O queue depth to BlockDeviceTimedStats, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 34/44] qemu-io: Account for failed, invalid and flush operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 31/44] block: Compute minimum, maximum and average I/O latencies, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 33/44] block: New option to define the intervals for collecting I/O statistics, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 35/44] block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode, Stefan Hajnoczi, 2015/11/10
- Re: [Qemu-devel] [PULL 35/44] block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode,
Paolo Bonzini <=
- [Qemu-devel] [PULL 37/44] nvme: Account for failed and invalid operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 36/44] iotests: Add test for the block device statistics, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 39/44] xen_disk: Account for failed and invalid operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 38/44] virtio-blk: Account for failed and invalid operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 42/44] macio: Account for failed operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 44/44] block: Update copyright of the accounting code, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 40/44] atapi: Account for failed and invalid operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 43/44] scsi-disk: Account for failed operations, Stefan Hajnoczi, 2015/11/10
- [Qemu-devel] [PULL 41/44] ide: Account for failed and invalid operations, Stefan Hajnoczi, 2015/11/10