From patchwork Fri Sep 27 12:12:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rakic X-Patchwork-Id: 13814296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5D49CDD1AE for ; Fri, 27 Sep 2024 13:26:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suAzF-0005vn-U9; Fri, 27 Sep 2024 09:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1su9pj-00040R-97 for qemu-devel@nongnu.org; Fri, 27 Sep 2024 08:12:27 -0400 Received: from mail-db8eur05on20700.outbound.protection.outlook.com ([2a01:111:f403:2614::700] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1su9pg-0001OH-G5 for qemu-devel@nongnu.org; Fri, 27 Sep 2024 08:12:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=R/B1AKCk3gloLtJlQPfUK9ts8x/tRarica2QekCfmNXp1t3eeD8gqBioL2NlZopWtIi0uW+w4OL3LRSSqn+aIDg2CWW09pDpjIvy1kXGqvGBX7h2d71ZG4fwdgGM/HxJp7b1vVqOCLGt/hlUE2ByLKAXt00MUN8CmcOIHo/dmOMdmKwGZusH/MFS/err1AwiY2NBgMl/7dhuhY3QoKWZnJlfQOXT4606Oo0EHWGiVyrR+U/5ZV8GtPldV1ORUCxEgzVyEzwTZhKoYvsqaQlosO2Hn8VnQpaDK0ldf4c3EGi7lpTWOF0PyO++lvGhdPb0UQ82QfdgACg+zwIny/1Azg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k2+QTR9mUH+zXO5msczgYFd7iKvZ39oTTgXaZLsCQLk=; b=y2w72+poo7htYUAmestEXNHwu2rH9i6qg9jPKOyf9iA+zyIH29bUJDJ+Hu7cdbYkrvj/DFfw8aw6sjIR1rOJb9wBf0ShbVeH8qTgGVzupakJnwqTjTuAVyaBJ1oZew2nu6x5tXTEkEdBtkAcjLwKoWoxAywpqPnu979kt2oM0ZWnzsc0lLm0Ki/aMKMlGwb7F4bLOPOY2n5meIZ/MAvhAZGXOn2Nr80rqDRAvWH1X4ZptUswWrC/6wxl8F5jy3tRTnVFDqvXjNWyoGWkPjSLd7uu2lb7L9YRmh2mYY2yuKbF3uWwBhGT9XS0PXEN7eZfSzIMlN69AYpge7ZRnq2z7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k2+QTR9mUH+zXO5msczgYFd7iKvZ39oTTgXaZLsCQLk=; b=BqRTsE/K2tYCOGJhuQKh+jWlsaqiOnotK1PyzwjiBk4bM7U+B2cqUEq9ZmxvsCJfcgE47CUgUMpN35RrM9kWzvAxXskM86qgLN+IaNS6Zlg7GE62frD8bsOEt1nTT9yj4DUoJKgJunY34xsEKUSYco9RoA6TNcz3XRxyzPGUYnY4JMsOgGordXFy1ax9n/A6iWkuhE7G9K0iWNm3JAg7XOfH2CQHpgmeXxLnK//o63f7SZGMOLcYLiWJEIbxFCgwHgHxy+75eexQxChQMMbgHrmFcCn6A+M+dmUs3U6ukN8PIlEoqRUUkT+chNSZRQjHBFMIgFSZDc/UtIG2NpHewQ== Received: from PA4PR09MB4864.eurprd09.prod.outlook.com (2603:10a6:102:ed::17) by GV1PR09MB6906.eurprd09.prod.outlook.com (2603:10a6:150:1ab::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.20; Fri, 27 Sep 2024 12:12:17 +0000 Received: from PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024]) by PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024%7]) with mapi id 15.20.8005.021; Fri, 27 Sep 2024 12:12:17 +0000 From: Aleksandar Rakic To: "qemu-devel@nongnu.org" CC: Djordje Todorovic , "cfu@mips.com" Subject: [PATCH 6/8] Revert use of clock_gettime for benchmarking Thread-Topic: [PATCH 6/8] Revert use of clock_gettime for benchmarking Thread-Index: AQHbENXwCSxMwStOOE+aS0fRSePVgA== Date: Fri, 27 Sep 2024 12:12:17 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR09MB4864:EE_|GV1PR09MB6906:EE_ x-ms-office365-filtering-correlation-id: 7298f89a-11a0-46c3-7adf-08dcdeeda134 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|366016|1800799024|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?d7Dt7nvq+V+/ADBWf0trAUquzQ?= =?iso-8859-1?q?vuV0I0Vxf7Fo4PHZvlR7xpom4CEXG83gWKc8VuL8nQwFFFfbBfe398/LFhUp?= =?iso-8859-1?q?rHElApB9mgCEd8inW/Jo8YKbjBiU1l9Vny0WDBYPXbGavz8zl6Qr8TquSCUW?= =?iso-8859-1?q?j1wZVCTrWWsSIznus8XEziiPrZ9jXEJdsHYstjua06GjqtdSEYo66aFsCxCY?= =?iso-8859-1?q?TlGPELjJnvc/Y7WwiNmz6NY8PGtspPbQ4USv+6umTWRJ2RX4iq6oyeGWT3Eq?= =?iso-8859-1?q?OPgLcknjPje/Vjj9OGd8CFciguIMXAZkDrKQEaVhiCnz5Xc8hBXO4fkQsZQg?= =?iso-8859-1?q?ZhEcVZgowfpqppDPSbsIFgHV4nEj61dUzoJqoKzfWmojrnpDhDjEP3exjKcm?= =?iso-8859-1?q?3HxiwKBDqElx+sAQmnk4VsYaZIjph/9YukN7j9/oSefSaUG+c6WcyPashmQo?= =?iso-8859-1?q?pjBqWn9gvnOan9uGeI8SYEvyjq9cdM2JHIQsT53hQsDC1RsGH3SP0bif8jA5?= =?iso-8859-1?q?v9lxTzkuj3SZmgJ/Sgc5EsBFImeXmFxO3n6v1ySIrEB0RIAxCQoTGRsjr8hP?= =?iso-8859-1?q?e+sMAwPKDH4BG+BJDecE9CXbwlqzqD4LKtR/ZTx5WHxyqtptABJmUww/6WDZ?= =?iso-8859-1?q?eQ+PqlmBXy52b70TOe/sk6lALoIxiEUT3wivXvd03B1NlCsYJxC9q+OjIkJm?= =?iso-8859-1?q?+O7inCVtp95XucJmNwGDBcNV4aAISiTg4hpejSbM98QSSZ3unL4BJMTKLHu5?= =?iso-8859-1?q?jSxH5fVUBBULBUJUCUqNbNuTjiROs5PCzmsW4k5vMhLtadsZrbY2hn3blxcR?= =?iso-8859-1?q?EH8z35OhHGDmVCcAkwMzW/1F7wmZ93TAM2M4ld4jFWWb4S0adQJiLMC0NPsi?= =?iso-8859-1?q?dg7tN2I2cBPVzzoJrO3v4Ek5JOO6mZP3YYJeQEtDECfD8Jex1xd3rQSYOGWm?= =?iso-8859-1?q?9hhJcP+hf7J3CQb/SJAmxEcyBWsFbMYHDLzEMEYRPFq7F2Cm1CVyh00ip0pt?= =?iso-8859-1?q?vvfxQAq/e5Ae0rT5RpUlJXITVdsAFodVaZ506g2m/VkZP2EUF16BVDq+H6xo?= =?iso-8859-1?q?eX/nqUlveqdm7GKpV9wFm9J20jRzt0vn/r6tLNWwTX9UeYM3AExdOlwOkXtv?= =?iso-8859-1?q?4AxGsYUy0mWWUa/DvVL3bikf+GSSDvIQenzKdw2ckcTlBZPlljU7WwM1uv6r?= =?iso-8859-1?q?wrwTZvgT3poZZV+L0DMOg6hZ+vieOqotV//ShRQFad1M6DVDOzjycRIRIhyH?= =?iso-8859-1?q?2tAgSagG3sXAS4XXC0BMMQTJQH3rO/asqsr60uzfTSCBesg4ddFhtUy7TZnA?= =?iso-8859-1?q?jYY5wIjSq495Rkt/14k2ABECN1tROGolery7rSqBGsReV4fXemU3u2ZUJy5q?= =?iso-8859-1?q?dG7mhc3y/N+u/WV2vxtFpBiM2nKt8iStqd9qTq/B3DQtA9eor51v+GCPwKJd?= =?iso-8859-1?q?w4jEN30+YIsFe3BQR8YRQ9SQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR09MB4864.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?VnnyblhtwPUPkPB0wWbQu1g?= =?iso-8859-1?q?kDqepe08zdHymvMVjPeOR29nhd4SZvYnVstxuco9pGLCtS7495ZkE9EPJwjM?= =?iso-8859-1?q?FThWiNCMvUBiKFJNxoJ5qdXPSRfUm0dYk1dPLklAH6dp0HwfzCLYh89tgKf7?= =?iso-8859-1?q?6Quesje/f2cnMnpyzihLWx+0cv0MyeT2mTtlS0AIMZQFxFDxEHmdp+3b9211?= =?iso-8859-1?q?U/+fhhpsb7t/iGfB5SgVqjv02JsHIMxFEtxiNIGpa7fIo8/5M1aBXJIEE4oU?= =?iso-8859-1?q?lnQ6UQmc6otAExQw+sx2UezkdkCUg0KICF1QGcBXN8ApKZR9cUeDAgejL4N4?= =?iso-8859-1?q?4R/JN+q8Ppofvpu41R0sqblBLwWZopZRkOzYXSpo0A53hoqOx3sqmV8eE6d5?= =?iso-8859-1?q?eIO3hgcfc0AjZ/H+8pnqMOonGdflM6JlLv0pwM6ETBywfzX3CNrG/bmxmL7M?= =?iso-8859-1?q?Z4PicvpMBFIzrNerf66vYT/QvZGOkohVy8zE8nWea1aCC9qcARhUWnoSZy3m?= =?iso-8859-1?q?M3QTf0zmvTMnLtC+BjPBCFsYngpFABxRg0zeegLQlb20bBOoqR8hm/h8182c?= =?iso-8859-1?q?P/5EctDE2ls3wsYany7n2clHItsEPFFG/qjsNUzHxzaQKBjvGKmfy4+OwETJ?= =?iso-8859-1?q?OeB6NdEgj5KTPUpJQsxdAzgk+6yQ0dhrAmp9ARyq8C2ijxXloyqoNb7eHcKq?= =?iso-8859-1?q?NO1nOuhoV2z8cpGMBWnIMc0uY/wrwc/vod/3dGr/bQajTPRQDkftDjCyvJyr?= =?iso-8859-1?q?RQEtsNl/uK3Mv8ERSefqqZPGRHDcxGB800Qoeepcax7DnJnTN0ucvB8m8fFI?= =?iso-8859-1?q?YuasfzuJ2mSfhPJORftLli9pGnRtxFIpfbbWMYqtjeRuRFspPS9HJM5L8HcN?= =?iso-8859-1?q?3iS/6sQUvnCTDR9ZYDGUp9pYA5tREbZ3unisM6Q2A/nhmkvhwg1qRyWD79ZZ?= =?iso-8859-1?q?WK+i7toCC6aI1advpFpicideaX0hlQwMOhx4twg8N7DNZmo/P92rzknuJo5v?= =?iso-8859-1?q?hh01bJ1sOIEd2O9pCr/+s9yz+MYBti1xazHegV7igB03oWH86l7D8DBSlRVf?= =?iso-8859-1?q?OweVqcqAWVUNkI+cs+hIUGUoZ/jdIQhlkyHp//mJFdNLH7S9HcmRUyf+i3Ob?= =?iso-8859-1?q?2ZPMbek57XqFhQY3LllLANibKK6LYFtOF/HBW01qKdMCe51k5awW2zNWqycl?= =?iso-8859-1?q?UOZRdu4KoTbuo1bRxdrnhVt/Bji0wpO0ZCIIkUc9/Yz2a5OC1SOHEQZ6skAf?= =?iso-8859-1?q?JP1praYagryrZnn+POSeoQFL8nq2MYW9xAzUqRPvvYGh1acIQHnaIHt8BfSx?= =?iso-8859-1?q?of/trBKYZ4NiqPz/9pYkcWj+cfirALOzGzh+ThWzBL7U/blhBrE/7o4nr5US?= =?iso-8859-1?q?784D2HooC1qQIkEW+soZ7onBC7fquht+aa99Sasx3mstAgq0lehMdiKcbkgN?= =?iso-8859-1?q?7/UrPfV9Aw5DqMCc6ShqXdtrXJumJJv6BaMwUS+OiRePEEJmc5GORM8KRPOe?= =?iso-8859-1?q?c8/eaJrOqkiI2goJQ9RzToLbEZSfg4EGEYfYfqar4RukgDsND45+P79yOeZT?= =?iso-8859-1?q?F7Qhdk44ryuDCvsQbTBHMpWM/5m9Pl6+LIDjYU6OEju+02thBRsROrlJhZvE?= =?iso-8859-1?q?Cru+vDGJ8TqCyAIc0WWXCCjTD2gJ6tJklp+6zew=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR09MB4864.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7298f89a-11a0-46c3-7adf-08dcdeeda134 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2024 12:12:17.2672 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: g7ZUz48v1NYRDfx2Wo92FNkJ2PUfbGOH5mo1Bz4X0zCGDPCq0uMGAUSJYTNqYd2HwIRJfs63l/FhJsuQlp5EHSisVteh+9sNWZYflnfJBR4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR09MB6906 Received-SPF: pass client-ip=2a01:111:f403:2614::700; envelope-from=aleksandar.rakic@htecgroup.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 27 Sep 2024 09:25:48 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This patch reverts the commit (with SHA 50290c002c045280f8defad911901e16bfb52884 from https://github.com/MIPS/gnutools-qemu) that breaks for mingw builds, where clock_gettime and CLOCK_MONOTONIC are not available. Cherry-picked d57c735e1af1ca719dbd0c3a904ad70c9c31cbb7 from https://github.com/MIPS/gnutools-qemu Signed-off-by: Faraz Shahbazker Signed-off-by: Aleksandar Rakic --- qemu-io-cmds.c | 77 +++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index e2fab57183..a846746553 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -259,21 +259,20 @@ static void cvtstr(double value, char *str, size_t size) -static struct timespec tsub(struct timespec t1, struct timespec t2) +static struct timeval tsub(struct timeval t1, struct timeval t2) { - t1.tv_nsec -= t2.tv_nsec; - if (t1.tv_nsec < 0) { - t1.tv_nsec += NANOSECONDS_PER_SECOND; + t1.tv_usec -= t2.tv_usec; + if (t1.tv_usec < 0) { + t1.tv_usec += 1000000; t1.tv_sec--; } t1.tv_sec -= t2.tv_sec; return t1; } -static double tdiv(double value, struct timespec tv) +static double tdiv(double value, struct timeval tv) { - double seconds = tv.tv_sec + (tv.tv_nsec / 1e9); - return value / seconds; + return value / ((double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0)); } #define HOURS(sec) ((sec) / (60 * 60)) @@ -286,27 +285,29 @@ enum { VERBOSE_FIXED_TIME = 0x2, }; -static void timestr(struct timespec *tv, char *ts, size_t size, int format) +static void timestr(struct timeval *tv, char *ts, size_t size, int format) { - double frac_sec = tv->tv_nsec / 1e9; + double usec = (double)tv->tv_usec / 1000000.0; if (format & TERSE_FIXED_TIME) { if (!HOURS(tv->tv_sec)) { - snprintf(ts, size, "%u:%05.2f", - (unsigned int) MINUTES(tv->tv_sec), - SECONDS(tv->tv_sec) + frac_sec); + snprintf(ts, size, "%u:%02u.%02u", + (unsigned int) MINUTES(tv->tv_sec), + (unsigned int) SECONDS(tv->tv_sec), + (unsigned int) (usec * 100)); return; } format |= VERBOSE_FIXED_TIME; /* fallback if hours needed */ } if ((format & VERBOSE_FIXED_TIME) || tv->tv_sec) { - snprintf(ts, size, "%u:%02u:%05.2f", + snprintf(ts, size, "%u:%02u:%02u.%02u", (unsigned int) HOURS(tv->tv_sec), (unsigned int) MINUTES(tv->tv_sec), - SECONDS(tv->tv_sec) + frac_sec); + (unsigned int) SECONDS(tv->tv_sec), + (unsigned int) (usec * 100)); } else { - snprintf(ts, size, "%05.2f sec", frac_sec); + snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000)); } } @@ -467,7 +468,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len) } } -static void print_report(const char *op, struct timespec *t, int64_t offset, +static void print_report(const char *op, struct timeval *t, int64_t offset, int64_t count, int64_t total, int cnt, bool Cflag) { char s1[64], s2[64], ts[64]; @@ -707,7 +708,7 @@ static const cmdinfo_t read_cmd = { static int read_f(BlockBackend *blk, int argc, char **argv) { - struct timespec t1, t2; + struct timeval t1, t2; bool Cflag = false, qflag = false, vflag = false; bool Pflag = false, sflag = false, lflag = false, bflag = false; int c, cnt, ret; @@ -825,13 +826,13 @@ static int read_f(BlockBackend *blk, int argc, char **argv) buf = qemu_io_alloc(blk, count, 0xab, flags & BDRV_REQ_REGISTERED_BUF); - clock_gettime(CLOCK_MONOTONIC, &t1); + gettimeofday(&t1, NULL); if (bflag) { ret = do_load_vmstate(blk, buf, offset, count, &total); } else { ret = do_pread(blk, buf, offset, count, flags, &total); } - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("read failed: %s\n", strerror(-ret)); @@ -904,7 +905,7 @@ static const cmdinfo_t readv_cmd = { static int readv_f(BlockBackend *blk, int argc, char **argv) { - struct timespec t1, t2; + struct timeval t1, t2; bool Cflag = false, qflag = false, vflag = false; int c, cnt, ret; char *buf; @@ -964,9 +965,9 @@ static int readv_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - clock_gettime(CLOCK_MONOTONIC, &t1); + gettimeofday(&t1, NULL); ret = do_aio_readv(blk, &qiov, offset, flags, &total); - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); @@ -1047,7 +1048,7 @@ static const cmdinfo_t write_cmd = { static int write_f(BlockBackend *blk, int argc, char **argv) { - struct timespec t1, t2; + struct timeval t1, t2; bool Cflag = false, qflag = false, bflag = false; bool Pflag = false, zflag = false, cflag = false, sflag = false; BdrvRequestFlags flags = 0; @@ -1190,7 +1191,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv) } } - clock_gettime(CLOCK_MONOTONIC, &t1); + gettimeofday(&t1, NULL); if (bflag) { ret = do_save_vmstate(blk, buf, offset, count, &total); } else if (zflag) { @@ -1200,7 +1201,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv) } else { ret = do_pwrite(blk, buf, offset, count, flags, &total); } - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("write failed: %s\n", strerror(-ret)); @@ -1260,7 +1261,7 @@ static const cmdinfo_t writev_cmd = { static int writev_f(BlockBackend *blk, int argc, char **argv) { - struct timespec t1, t2; + struct timeval t1, t2; bool Cflag = false, qflag = false; BdrvRequestFlags flags = 0; int c, cnt, ret; @@ -1317,9 +1318,9 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - clock_gettime(CLOCK_MONOTONIC, &t1); + gettimeofday(&t1, NULL); ret = do_aio_writev(blk, &qiov, offset, flags, &total); - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("writev failed: %s\n", strerror(-ret)); @@ -1355,15 +1356,15 @@ struct aio_ctx { BlockAcctCookie acct; int pattern; BdrvRequestFlags flags; - struct timespec t1; + struct timeval t1; }; static void aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; - struct timespec t2; + struct timeval t2; - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { @@ -1394,9 +1395,9 @@ out: static void aio_read_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; - struct timespec t2; + struct timeval t2; - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); @@ -1537,7 +1538,7 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - clock_gettime(CLOCK_MONOTONIC, &ctx->t1); + gettimeofday(&ctx->t1, NULL); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_READ); blk_aio_preadv(blk, ctx->offset, &ctx->qiov, ctx->flags, aio_read_done, @@ -1692,7 +1693,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - clock_gettime(CLOCK_MONOTONIC, &ctx->t1); + gettimeofday(&ctx->t1, NULL); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_WRITE); @@ -2159,7 +2160,7 @@ static const cmdinfo_t discard_cmd = { static int discard_f(BlockBackend *blk, int argc, char **argv) { - struct timespec t1, t2; + struct timeval t1, t2; bool Cflag = false, qflag = false; int c, ret; int64_t offset, bytes; @@ -2200,9 +2201,9 @@ static int discard_f(BlockBackend *blk, int argc, char **argv) return -EINVAL; } - clock_gettime(CLOCK_MONOTONIC, &t1); + gettimeofday(&t1, NULL); ret = blk_pdiscard(blk, offset, bytes); - clock_gettime(CLOCK_MONOTONIC, &t2); + gettimeofday(&t2, NULL); if (ret < 0) { printf("discard failed: %s\n", strerror(-ret));