Received: from eggs.gnu.org ([2001:4830:134:3::10]:59213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyecG-0000hh-OD for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyecA-00089v-HC for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyec9-00089l-VL for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:26 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBAAZPxw013611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 05:35:25 -0500 From: Kevin Wolf Date: Wed, 10 Dec 2014 11:34:11 +0100 Message-Id: <1418207679-32260-46-git-send-email-kwolf@redhat.com> In-Reply-To: <1418207679-32260-1-git-send-email-kwolf@redhat.com> References: <1418207679-32260-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 45/73] block: do not use get_clock() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Paolo Bonzini Use the external qemu-timer API instead. No one else should be calling cpu_get_clock(), get_clock() and get_clock_realtime() directly; they are internal functions and they should be confined to qemu-timer.c and cpus.c (where the icount implementation resides). All accesses should go through qemu_clock_get_ns. Cc: kwolf@redhat.com Cc: stefanha@redhat.com Signed-off-by: Paolo Bonzini Message-id: 1417010463-3527-2-git-send-email-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/accounting.c | 6 ++++-- block/raw-posix.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/block/accounting.c b/block/accounting.c index edbb1cc..18102f0 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -24,6 +24,7 @@ #include "block/accounting.h" #include "block/block_int.h" +#include "qemu/timer.h" void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type) @@ -31,7 +32,7 @@ void block_acct_start(BlockAcctStats *stats, BlockAcctCookie *cookie, assert(type < BLOCK_MAX_IOTYPE); cookie->bytes = bytes; - cookie->start_time_ns = get_clock(); + cookie->start_time_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); cookie->type = type; } @@ -41,7 +42,8 @@ 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] += get_clock() - cookie->start_time_ns; + stats->total_time_ns[cookie->type] += + qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - cookie->start_time_ns; } diff --git a/block/raw-posix.c b/block/raw-posix.c index b1af77e..02e107f 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1922,7 +1922,7 @@ static int fd_open(BlockDriverState *bs) return 0; last_media_present = (s->fd >= 0); if (s->fd >= 0 && - (get_clock() - s->fd_open_time) >= FD_OPEN_TIMEOUT) { + (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_open_time) >= FD_OPEN_TIMEOUT) { qemu_close(s->fd); s->fd = -1; #ifdef DEBUG_FLOPPY @@ -1931,7 +1931,7 @@ static int fd_open(BlockDriverState *bs) } if (s->fd < 0) { if (s->fd_got_error && - (get_clock() - s->fd_error_time) < FD_OPEN_TIMEOUT) { + (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->fd_error_time) < FD_OPEN_TIMEOUT) { #ifdef DEBUG_FLOPPY printf("No floppy (open delayed)\n"); #endif @@ -1939,7 +1939,7 @@ static int fd_open(BlockDriverState *bs) } s->fd = qemu_open(bs->filename, s->open_flags & ~O_NONBLOCK); if (s->fd < 0) { - s->fd_error_time = get_clock(); + s->fd_error_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); s->fd_got_error = 1; if (last_media_present) s->fd_media_changed = 1; @@ -1954,7 +1954,7 @@ static int fd_open(BlockDriverState *bs) } if (!last_media_present) s->fd_media_changed = 1; - s->fd_open_time = get_clock(); + s->fd_open_time = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); s->fd_got_error = 0; return 0; } -- 1.8.3.1