From patchwork Tue Nov 10 14:14:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 542390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42D71140213 for ; Wed, 11 Nov 2015 01:41:15 +1100 (AEDT) Received: from localhost ([::1]:60530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwA6j-0005Be-3b for incoming@patchwork.ozlabs.org; Tue, 10 Nov 2015 09:41:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw9i7-0002V4-0D for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:15:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw9i3-0005ur-5W for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:15:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw9i2-0005ua-WC for qemu-devel@nongnu.org; Tue, 10 Nov 2015 09:15:43 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 8CA78A4514; Tue, 10 Nov 2015 14:15:42 +0000 (UTC) Received: from localhost (ovpn-112-78.ams2.redhat.com [10.36.112.78]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAAEFfvw021617; Tue, 10 Nov 2015 09:15:41 -0500 From: Stefan Hajnoczi To: Date: Tue, 10 Nov 2015 14:14:21 +0000 Message-Id: <1447164879-6756-27-git-send-email-stefanha@redhat.com> In-Reply-To: <1447164879-6756-1-git-send-email-stefanha@redhat.com> References: <1447164879-6756-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Alberto Garcia , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 26/44] block: define 'clock_type' for the accounting code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alberto Garcia Its value is still QEMU_CLOCK_REALTIME, but having it in a variable will allow us to change its value easily in the future when running in qtest mode. Signed-off-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi Message-id: 547485eb841cf9e3b2770c96539ae9ae5996e214.1446044837.git.berto@igalia.com Signed-off-by: Stefan Hajnoczi --- block/accounting.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/accounting.c b/block/accounting.c index a423560..6f4c0f1 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -26,13 +26,15 @@ #include "block/block_int.h" #include "qemu/timer.h" +static QEMUClockType clock_type = QEMU_CLOCK_REALTIME; + void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type) { assert(type < BLOCK_MAX_IOTYPE); cookie->bytes = bytes; - cookie->start_time_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + cookie->start_time_ns = qemu_clock_get_ns(clock_type); cookie->type = type; } @@ -43,7 +45,7 @@ void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie) stats->nr_bytes[cookie->type] += cookie->bytes; stats->nr_ops[cookie->type]++; stats->total_time_ns[cookie->type] += - qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - cookie->start_time_ns; + qemu_clock_get_ns(clock_type) - cookie->start_time_ns; }