From patchwork Wed Oct 21 14:58:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A348C55178 for ; Wed, 21 Oct 2020 15:12:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 89CD020BED for ; Wed, 21 Oct 2020 15:12:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="EroiWAVJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89CD020BED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFmd-0004De-LE for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:12:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaE-0005bm-LO; Wed, 21 Oct 2020 10:59:22 -0400 Received: from mail-am6eur05on2129.outbound.protection.outlook.com ([40.107.22.129]:44322 helo=EUR05-AM6-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 1kVFaC-00085Q-SJ; Wed, 21 Oct 2020 10:59:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iF3Aa14pZ2JdXJgvmH+q/az5NIFSVMIbgPJhumH88V8wovcWFDRjeK96DIX+loqJ8IL7UPGKuA7RS2eTWOuQoRhlazOf9miYZmPlRKCtFgJI+K1kbYfS3Of5Kmhepvz0DWcyiY0eNiqHxdVhThBAxdv6es7zVixypFIdcz0I3kC7vGh8x1lmnhJ3md7CRMf4US2wE4+Z5FhT8YyHbfs0/bCatCLYAn/XChsRAOvbhkSkkYLqpffadbOkUwh+f6Ggzw81K5kFWKNoczEkgdNr5FLy09Vr8eHo/ti1EUwFdowbb3xVz0pbe4O6EgSpvt11y3nQA+k7G8topjafDFviPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tH2aTS9trbgQmhNu9rEnjkjJNcjEs5av4nDYP4x782s=; b=EhyWNdFTrHYsRJBWFhegO6IYmhyzjm6Dw00qrz+CuZVAAtLq/fBrySVPjnXUkgMmGfjhyhQzAeDL9CjQ9GCJb9EUZM2MUI4BFUZAhqmDC6Hv20Naqq2WHFbNtgCC0CXvYJ4oe9UjDmTEqwfmOopMUbotc41fXwyQw2TEQ5lvDjCzRl96vgoJBkY3s4OriuyLcqmwy2BlLVNp4ozpgQkVmg1SGqYH/m8W81x9xXa0jnmB1AEBEDo2FB/gwBKR0m9biMU1IYKUdzDMWi3j20o3zys3L/uNn7N3i0NiQlVoTRb75L7oVB6Z9NaoCVh+Gj4pvsYFl4DMcHE6xfWFR28QRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tH2aTS9trbgQmhNu9rEnjkjJNcjEs5av4nDYP4x782s=; b=EroiWAVJSdSusOVU9IIGaRXjlrZWpy8CdocHjuorWvVpFowxct7ccZYjTaYY4IgrOw76yFyd3WPBx8wPIwq1YZMzGYlneKA7NKDyC81E0muwalZ0gZTFlHZ2v1X9EcAJNHB1py7zLgP1UQL7kIISu9S9MhhG+qhO6JxRUwFBoc8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3541.eurprd08.prod.outlook.com (2603:10a6:20b:51::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 14:59:14 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com, Alberto Garcia Subject: [PATCH v7 01/21] block: simplify comment to BDRV_REQ_SERIALISING Date: Wed, 21 Oct 2020 17:58:39 +0300 Message-Id: <20201021145859.11201-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4b43b6b-3da8-47ec-3cda-08d875d1dff3 X-MS-TrafficTypeDiagnostic: AM6PR08MB3541: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mPtc1R0dadnvFMydiH3SbIwPIGOQNifTqHrmENvcCbJv8vgw+WjVb0I93sAp7qNk4QaBsSSJ5+RsgWPV8WEM1CtynauFhPTMukQG0mfwmwwLIil7VOODj7t0sOBmxy2LxYOntVr55JqN2DQB0V06mFPFMiF76OGwlIXjt4/xw1v4qlaATLFyVp/bCXp0MsR3iRSsPK4GaINkifoBx52QMZsVghISpJEZNqQ3hBrTsBjHy3bw+8YSgB0qRwd+KumbpVlKC/mHr5ueHnLzSIN9CFySQIQZ62DhOBtqwIUDgE1H/H+Ll/+HTgMTx628+DN4FjUdmnKbVO/6sd5pKQJrJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39840400004)(366004)(346002)(376002)(396003)(136003)(6512007)(8936002)(83380400001)(52116002)(4326008)(478600001)(6486002)(6506007)(8676002)(186003)(16526019)(2616005)(956004)(66946007)(66556008)(66476007)(6916009)(36756003)(26005)(2906002)(86362001)(1076003)(5660300002)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: nBmoEalIZ6AxM2PynnVsRh+t9bDuPzZxjDOmsZvFDnR36fpN3Z02CFfCbZXNGrQwiP05UaQ0u2Iv7b2B/3raxZFlUIXxbRCoxQFlce0BLPZsYoLY60D76NqymMdAssj2/nXauqCdo184YTvoGohLV6AlB1RzMDlWyATwV47H9MPwz9z6EzL20HBs/9YDg2aLfgBp4OEoI4ue9l6nQdEXb11evMiDzxw8Un6/4GmsJIVnyw7TZVC8ay2qZbsnx0pI4O9jGIbW1ShjNqD29KArT1jh07+CY4+7QFj0aya3cwZTG6eyTzYA5yrlrEq4LM0NxInmLsHX7xLvbT1OxpFXeIoangdQ05+QqRtdEPQFtJsrp0Xqb4dnqbvyhp6B5EDlsQmNAd9CdKDbOEI4vdDsd+yjo9cCwdgNLy/RRH0ELa8NTvGXhO2JjHjG75PKW8GWkpvJL0L4UY4cnhq7932XhKCjitvhOpeu1UrPCzel0FufLrlbNnfupOd3IpJ/2CQsPOzNrEz4bLAj51+E6SsLgLuAnXFJx9ty7vp85gaZQxOdFYWib5SB7cz4/dJVa0tS8ifxPd26RS1okUgZ5KldI4myGnFoyZJWcmF/yszS/4IsykbUZlE+WNDgZZKk9Mo8CjxkGZdKzZnQwOsZVK3zzw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4b43b6b-3da8-47ec-3cda-08d875d1dff3 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:14.0313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x/UjMPq0qH/7CgnCRbzBOqfosfenc+X6oO1pjlcjx4xjTleP9ztGA4YjEyHWuY1j+mk1gdHdSZNy7zAxMCqLhEXenQ7azXqEslJUMQRT3mc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3541 Received-SPF: pass client-ip=40.107.22.129; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:14 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" 1. BDRV_REQ_NO_SERIALISING doesn't exist already, don't mention it. 2. We are going to add one more user of BDRV_REQ_SERIALISING, so comment about backup becomes a bit confusing here. The use case in backup is documented in block/backup.c, so let's just drop duplication here. 3. The fact that BDRV_REQ_SERIALISING is only for write requests is omitted. Add a note. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia --- include/block/block.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index d16c401cb4..f9ca42fd4b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -63,16 +63,7 @@ typedef enum { * content. */ BDRV_REQ_WRITE_UNCHANGED = 0x40, - /* - * BDRV_REQ_SERIALISING forces request serialisation for writes. - * It is used to ensure that writes to the backing file of a backup process - * target cannot race with a read of the backup target that defers to the - * backing file. - * - * Note, that BDRV_REQ_SERIALISING is _not_ opposite in meaning to - * BDRV_REQ_NO_SERIALISING. A more descriptive name for the latter might be - * _DO_NOT_WAIT_FOR_SERIALISING, except that is too long. - */ + /* Forces request serialisation. Use only with write requests. */ BDRV_REQ_SERIALISING = 0x80, /* Execute the request only if the operation can be offloaded or otherwise From patchwork Wed Oct 21 14:58:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7EBBC388F9 for ; Wed, 21 Oct 2020 15:12:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1F1D921741 for ; Wed, 21 Oct 2020 15:12:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LuLWCZQJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F1D921741 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFn4-0004RA-Tz for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaD-0005Y0-Tp; Wed, 21 Oct 2020 10:59:21 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaA-00085a-5M; Wed, 21 Oct 2020 10:59:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMmh1M8VRq9dGPHrneK/y9tfICXjdhmlNMvphiqNxPhxmaXfVHpVxgucIvsXnMllvxxKbFX6PeG2UaCpX7YF2nBc0UeSpM5T41/LjVIGgf91WD+ES5z/60GKPry+8ms8fqglYHA8PAIbEQ9iWyQusTqzATCq5divSRFbQx+KArDigkkov5axtCk+SrkSKm2K+dxXXT/ll4nz8WeDUdkgGYfZtnLo/1zSThkJwOwyBaSO0sXOWF+0hjObnL0zp4mMRQPl5hb8fmR3ZY6e0GGgrbS61gR+zadovHe1yHBvg+KO5YF+5aJRLXqRAGSJtganQK5qHQBvLhqxGJXSDUDI5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jGNUcLocWKe/OL1DUBR+lIeuAKrxBmAvNKomdyRZGQ=; b=emh4ahYWE9/loG6hzXY3Lcu7hgj27h+PzhgKITk1fMJrt9pKVNBp49h1QeE/1YlEET9YUjbJwtn9WOwX5MI8Z7d01/v3SnOdHrFLF7psEjyctfWmNGCbZZHw0jj/Bkn9R1u3FnT+hMEwE0SJRdhSFpH9S18klU6WvwNiCQWK6iyKkNWGm1iWxM6RbyanRYooU4mmSTwLXEh1GLLOp2YQIqJmQPz+YnLCoFPcXCvanMF440shVT/1Y+xc7J9J57nlGsY7QJ7Lv/XY00abRO6lTgHrttXlOXjuYLynV3edVuhYAxBGcj++Sg9ZUD/AqmOh7VpgeX7Yrl6wXHgQbGLgeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jGNUcLocWKe/OL1DUBR+lIeuAKrxBmAvNKomdyRZGQ=; b=LuLWCZQJJeFubs7Vwb4h/eL6Bgg/vIh9DqPUgJQ3IV/ZgFaeRTsmm4blnGBa1LWR3DflGYXeq9s5ViNI3Qch9uIf95aw6aA3Viu+8terSpNm/vo8jha7614nkLELJSjBnPFClDxlpKXtTncy8ulz/7E8/gXP09vxMJw00AGsyH8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com, Paolo Bonzini Subject: [PATCH v7 02/21] block/io.c: drop assertion on double waiting for request serialisation Date: Wed, 21 Oct 2020 17:58:40 +0300 Message-Id: <20201021145859.11201-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 155551bd-3a84-467d-bcca-08d875d1e075 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b6J6RikdZMB8uV19GKvUNi8uHRgtLqRsPaEkIVSzG50EIRBNsuR32nsbgjCqcJdxo1cMp2QIBZcoLN2hjnsUZYEOqOXRvKcRp2AI8z/1lbt+uLVZEjJKgq/4f+ObsVZOPZy0KDdkRu5e36LXbV3vZlePh/UXx6dbKgbOAS9O33N7rbI38C+C7ee5VY9rke67QKSDuqOOls/3Sw0vEU8GhHqKfZw7qSgOsFimwWMbX6BWGahMHLGlc41/zJxFBj25a6SMkB7B7c17cjvKDKG5gpc9KG0/3yMOZ/YFeltykUEfBWPvxSReCBRFubYu8YFBPs6v/tI6ydNcjoVuygw48A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8kpStbEuf+H6Oj1hgao8nSE8SpQl5eppWIcBRk0IZ8Iffk4PppryJEHWMMWa1g6+sHL8SIDN52I8u6dcfby0KvBYdcKpu+oDdHaGXulAm/dqE6FfTzTzNoph2l+Nt6HXJz0l+EHcbkOV1bFwuxcNwbe7l0qZdkDS7PLlhynR0JdNGsBH1z65wRVa748cbmMeoSxIHalp0dLdvoIPcnDi+qlxeJZtc9p51HiYuYToTLCtNXjgbkzPCP+AKMwq/X6REWT90rcYnDnXot7RbEoHzvWQXNe9QulB1i9k4gLF4w0QCxHvlkmFmDv3WwEjsWOhF6js2nmLHhu6DnzKloWTWSlrDoX1QGjpy6fTq7OQmYrr02mnQLrHN1XlRd2LbnNwNeQ4zBdnsjnK4l/k00Bi0zPVUDb04z7SgoSVGOupO1MvOf2WskvBwMk6A/dCIXXmQPo5ecByAhuz+3JK2e5Q6RYFnJoF5umwdUSThgLYGJ6F2e6xFgKdDG5prH1ICfVnN9mBRcnpteb6NU3xWN1oyxuk2+ExGr4n3WuiyDgzWQpC4CHor1R79TlygFqv4ktMs42nxr2JMAPPTHcgpqdULVfsibNZRvK0Sv8llKcgIchHf+UhmqXMxh/ViPaUVGZj1y9VxEwYw1KcteIheYIrEg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 155551bd-3a84-467d-bcca-08d875d1e075 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:14.9572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DHG4IW0lHOAPSIKrl6i7ak2tvX4ut3m9e+z/PCtg6vShivNF9FaVZpuvopI050j30Orxqo+7mCREEsvbXe9OxLdbNJqleRuEWse699mLj9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" The comments states, that on misaligned request we should have already been waiting. But for bdrv_padding_rmw_read, we called bdrv_mark_request_serialising with align = request_alignment, and now we serialise with align = cluster_size. So we may have to wait again with larger alignment. Note, that the only user of BDRV_REQ_SERIALISING is backup which issues cluster-aligned requests, so seems the assertion should not fire for now. But it's wrong anyway. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Paolo Bonzini --- block/io.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/block/io.c b/block/io.c index 54f0968aee..bf6d4d5e77 100644 --- a/block/io.c +++ b/block/io.c @@ -1784,7 +1784,6 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, BdrvTrackedRequest *req, int flags) { BlockDriverState *bs = child->bs; - bool waited; int64_t end_sector = DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SIZE); if (bs->read_only) { @@ -1796,15 +1795,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - waited = bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); - /* - * For a misaligned request we should have already waited earlier, - * because we come after bdrv_padding_rmw_read which must be called - * with the request already marked as serialising. - */ - assert(!waited || - (req->offset == req->overlap_offset && - req->bytes == req->overlap_bytes)); + bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } From patchwork Wed Oct 21 14:58:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ACEAC388F9 for ; Wed, 21 Oct 2020 15:07:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9F97620727 for ; Wed, 21 Oct 2020 15:07:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="TNgaf5dm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F97620727 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFiN-0005QJ-Kk for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:07:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaG-0005ht-RI; Wed, 21 Oct 2020 10:59:24 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaE-00086M-P5; Wed, 21 Oct 2020 10:59:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8rPuJlOKG8dyI9iVQ9l96pqqJ0MW4eva/e6CZd8HZ3PlJ9kZ4d0xfYOFxFO+auHoaCUoFvZhDBlsaKyXy8IeuqspTrqY8xPi5zICWqADlx8oTsEZ43GRRBkeZ1Y1oCkgLEgrczhDQgaehMqVMex1oOFeObEBigLKvKHmELREGkL3om9rh2pwNKl7iMS7aAxVhViNSVkhoAKQNV2fNq11ivc/6RkkN/54BRhaN9v7MdBkeklhAeEU4wXvUlp42elBBo2nDOFrE4ZvfyM/vSw90Nd2wSJEF8CSxgUfEIxMnGF43R/OS/mvRvJXwkKrM/WdrHqxfMUX1ApdO+MU+hmoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QcwjL2naG5md/UpCH2nH39vXfGJyfFAGa2NvQWAG5V4=; b=XdB/vrol/oRPfKRtpcsvR1Be0oJkPFSntc7pBht+lXdojeJsd4EylWZcrF6QkNHbEyXlCaxCAk0shD12udGQ3u2ylMdss/5BIDqwpBw8bA1efKG/ChAaLCLyymfEsS8SWE7C1Q6WvcyV6raF9XsNo/PeEjifMYEU7pjC0fpeL3UVfpV00E0zbIa1chjBlBzTvZPbtsPs246zOGxCu4zh+1dKON6WvaJ5azCz1I5WPrY8NbIjbi+6/vTa6/mdegVSafrE6dWAcxR+Uj03Ww4Kw2DfhwFJKmtmCCyyBdd8JnLmeB/kiza5a5W+KeJDxtmE98fzINarwgE9S1Q4cplZ/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QcwjL2naG5md/UpCH2nH39vXfGJyfFAGa2NvQWAG5V4=; b=TNgaf5dmOjvGBzHKz3ah27EuoM0Wsu7kyglNNz7PsmEHaKvNzN9cc+pT1b6WtnVXU2DHx+mSGGC6C5ZD9VN/zw8O7BtuKhLiMlCuEODpKoZQo90buJhlTJHW1Gc78AQpGHcamwiwTyLyCRPk5c8k6DFpBVfjFOkf9zMH7WHuDUc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 03/21] block/io: split out bdrv_find_conflicting_request Date: Wed, 21 Oct 2020 17:58:41 +0300 Message-Id: <20201021145859.11201-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9e13ea53-ac80-4265-297d-08d875d1e0fe X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: exPYuWq9dDUtrjfVEWiWaST3vIDS4x4+vkSj6kGLWnrvk5fe/ECYMP9MlHLMofEUT19OqGfOt/7fHQuimHBwYiuRVcmbLq7Np6wKkCH1ciPdHVsPrgTFmOfKbD+meHVb7+ql0MGkmAB4dqvQZ+S0dqovaLWWLy9B74h+GiYC+NzetmHl/x7Mw0KO2TCOUk4Iy4NwHyzaIpB9C7/Yqf87qXsAHnFmesIkyJOB+f85I9OR7pUv0jPwJ7M/6l1qE2fofud6yoqr5GhPDhKwQz6aQWHGno4ScYZow5Del1ipA0vryvdHG0XMldZItWUrPSYTCVrI/PyOMI+rJ9cB2OFzLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dGYoZJkSroLGEidPRZ00GzBfyBel1u6+7r5hU77VDCSEBKA5BV3rY/Ow2IERAApyxlFbxzzQsr3N4dEYlGH6rZhV6yhV/Cho52OM/crmYwHRcsKcgdowBYWqdebJTTL2o7SwCSIiuPn8zQVB2z1VFjD3UPeDephpA6vOo+H/6bbOF4M7iTlPx8+++MHm5c/qcNlhmP+M0nLT86M0tcjB+xTyfKMJCRFQwWmK/TEuz4PmAR8ojTP+idcuitIMuPHNTyw+5aw7uZ8HmgoicHL3Nx2inxdEIiNzGIw5CHACTBKKuTXkhm6Tu7oA/wQX4hDomZ5LyhZdcvBP49KCvsgzwJvIkbh4Cyu2Wd+rh5KfSyaNWJ9wIm/nNOY+BJ1niw0Srpu2Oof34JBFeb95IiW4nWo9NeyaaBVMBnnTRCwASYmBy2U81JsYdRNnIzGchOJdpz5U9nIIoZ6LdcPiSB6xGh6IiSZp5zHqmZgD2iBN2r2Mdbf7gKIg1ZekBwxvywDXsgAOosO/Yo9qWio4hLxS+GZQqBSdZkB1am2D+VkUpnVxrBkYFAblxz5r72m8q504UAlJmfB2Zn0OC71AJgWy6+NiA9UiGjqnl2af6aECC0nn2QZxdPgRd7h7PuCZgQC8XzD7307RqXIBYmzywhcSfA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e13ea53-ac80-4265-297d-08d875d1e0fe X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:15.8065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WeB/DMVBWnnYwys0HiVwZvY+fj57RdF/yQz6Dru5QM1Oe1d9zdLO1wryvqEIy3ewZqS3omPDNZscTMDL+q7uHY+M9ASlBxHltweKpH474A0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" To be reused in separate. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi --- block/io.c | 71 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/block/io.c b/block/io.c index bf6d4d5e77..c2d9b1f849 100644 --- a/block/io.c +++ b/block/io.c @@ -728,43 +728,54 @@ static bool tracked_request_overlaps(BdrvTrackedRequest *req, return true; } +/* Called with self->bs->reqs_lock held */ +static BdrvTrackedRequest * +bdrv_find_conflicting_request(BdrvTrackedRequest *self) +{ + BdrvTrackedRequest *req; + + QLIST_FOREACH(req, &self->bs->tracked_requests, list) { + if (req == self || (!req->serialising && !self->serialising)) { + continue; + } + if (tracked_request_overlaps(req, self->overlap_offset, + self->overlap_bytes)) + { + /* + * Hitting this means there was a reentrant request, for + * example, a block driver issuing nested requests. This must + * never happen since it means deadlock. + */ + assert(qemu_coroutine_self() != req->co); + + /* + * If the request is already (indirectly) waiting for us, or + * will wait for us as soon as it wakes up, then just go on + * (instead of producing a deadlock in the former case). + */ + if (!req->waiting_for) { + return req; + } + } + } + + return NULL; +} + static bool coroutine_fn bdrv_wait_serialising_requests_locked(BlockDriverState *bs, BdrvTrackedRequest *self) { BdrvTrackedRequest *req; - bool retry; bool waited = false; - do { - retry = false; - QLIST_FOREACH(req, &bs->tracked_requests, list) { - if (req == self || (!req->serialising && !self->serialising)) { - continue; - } - if (tracked_request_overlaps(req, self->overlap_offset, - self->overlap_bytes)) - { - /* Hitting this means there was a reentrant request, for - * example, a block driver issuing nested requests. This must - * never happen since it means deadlock. - */ - assert(qemu_coroutine_self() != req->co); - - /* If the request is already (indirectly) waiting for us, or - * will wait for us as soon as it wakes up, then just go on - * (instead of producing a deadlock in the former case). */ - if (!req->waiting_for) { - self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); - self->waiting_for = NULL; - retry = true; - waited = true; - break; - } - } - } - } while (retry); + while ((req = bdrv_find_conflicting_request(self))) { + self->waiting_for = req; + qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + self->waiting_for = NULL; + waited = true; + } + return waited; } From patchwork Wed Oct 21 14:58:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BED14C388F9 for ; Wed, 21 Oct 2020 15:07:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CEEAB20BED for ; Wed, 21 Oct 2020 15:07:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="LjBk6EFN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEEAB20BED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFhm-0004wd-OF for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:07:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaF-0005eK-Jx; Wed, 21 Oct 2020 10:59:23 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaD-00085a-S6; Wed, 21 Oct 2020 10:59:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qtc/Hhg3uG/nbWJDtesaN/Hea54DbU+0J4+5E4AfPyhQ11mx1CuGhuWQRbq/YBQNwtY4SFzbMHZJjG4wk189TfC2jWNWb+HRtylmxfOF3tLz9ooa0cH/G+ZVpgFbSSzHVsVA/jBWKlSD7INuyYM/kWawVgC/PE/KEfQcv3hlh1OXDJQKRXEy2E7j1ZNXVJtq3bN2D+9fk5ECCxKIxIAWDv7f/Hg+GTQRDVMXiwxxM5WH9R9O1G2kpTAtcE5WKARgjybMpLaeqjTaWJjNfTGWl0I6CWmXZckGTx9/LUmymaaA7dHEi3MUsRMRAbgp5T7NAtdgBU/bsP85Z8NBlO//xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zf/LmbYuMhBReqWOOKVX8Uhmh/n39p9Hx7Rhe29Odqw=; b=YhtUzq1kUDzQJAS4PidcjYMYCF0mrE9pOWco7sDlafejw9F1ODjxVDl5rEIa0M9PVeT6oJqDMh7xpC9pwuWkTu0S0dAQwDFQcr7QSQqRCthElLrTJWQdmMDtRXbhsEvy2w9YFLyn5FC5WK9FJZWBV+TSeCtIfUg8bRibSOriMdVINTmUFnfer8pnkfOyEeQ6dMVBDp6O1PlkA2/zhWiMwbqleBwIRLrvTzRniT5JPcca3zu+fIq0ZhQT5IA/1hjb1zv8bQvX+iG/5ZGYOfFGwZW2gmboQCX9AQ4hqY3gZ9OxgCNESUWQOo/4Vb9vKFhBPNE+dGVVhm3TgTgXAOvcyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zf/LmbYuMhBReqWOOKVX8Uhmh/n39p9Hx7Rhe29Odqw=; b=LjBk6EFNtGAIqt6Tb/OtdJmunVtITMyCBWFSmsvxEGPyJsWwY003M8AjJngW9Z9MV9HosbMP1L4tMgCfRYUXnJuHc+1MJAzDMzGzj4K03OO8kzIPkleQ9KFoP+wdfSE47TJxxihd78iX1ZiBYHO4WD8UPQf0nmpSOIYKTlxT9oY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:16 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 04/21] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg Date: Wed, 21 Oct 2020 17:58:42 +0300 Message-Id: <20201021145859.11201-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3aa26421-6589-450a-0a7a-08d875d1e17b X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k+nHUfyEjdY88aB6cp6fRXBlc8pMzzGflyguwfczgDJUy74odQ72mqhL+5iXW+EXR+NZNaojrwup6vNYqK96pmTwxelX/mXuiT8UKkkDuiUQGfPY7/j7J95uiqXuvoYyvla8L5XoDls51AHB/s23bOKRx96T2rh0cMs1rk8YIRqs4i+S41k0OnZtVtE2TL4m/edhsGH8/Mlm15D0Rl2D60Jf6v1wWCKBjk50LLIZKNeXa7uZy1J05IsYZdwr7HmTa5HR3yBrpzJu9aeSVz1dAvpiIypJ0Q0di6w50zg/6l6IBq13q+qsPFdejrfiQsM2N1euqSxVlckg8lNdrbmrRA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(45080400002)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4JWjo33z4pJ7uPDVX6lSs46wAFZGaRkcowfq7HukvIJS52YT/iJC23QS9RImDnZgpA6LJ9wPB38q+tP8LrQsJHZyZcUqmCmOIkih9N9iPQaZDJ0UAmzyqgHkX369CN6KnEbiJ/7Ziv8WuX86NvPFI8EGvU9YMAZFSxiCU7sHzdutmC+lKwTJcT0JjcVCHIPRf8l3PWfzdje2/YgPNI+7pb1GIg4p57QiPjDi/s1sCuFW5+wVSk3a95owxY64X22saPivYmXms3zz61FaYQIXfZ8RDYRZBIaW9TGJlh0pACUc+FnbZ2Ihs1cj0eULsK4dNH1kvT/lBlOjQH8N7RjqGXGQhe+MDl3aLrdULT4N31AjffXDEXPLkuWmiRiDH1UVgNK6WspHGT7Jiu9E61gJvYaMbbGj/nHwe5kcjf1J6CBJ4hf432H7WL0COzLfbUlgC7o4U5E42AHcovB9c0IPw33kiqm/k16wS/63oG3SjnplxAPnc/WVKBrEbK678pmDB8JZjsvrjT1IGaFAY3RJgF/YiMMRePhrTtcbtVwnmD/QH4o/wKD1g+l+o8n3DFEVFic3mWzkDlpqX0N7ZpTyWdyqlqAByu2DhU1l0HyQCKlDlCYPsp5kv6+cph37tO+FOphGf/XMw6rS90Be6f4SWg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aa26421-6589-450a-0a7a-08d875d1e17b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:16.5701 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MLsnSxQd0RQlNei/ktWOpI5CrmTxTsxilBO2Nm4GhW6r8EvQhD+PqZ8l2/IkKbAYwrtvDVQqbxGnzGR/msfmq+XasyLzpnPXWbmpVBQKIQ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" bs is linked in req, so no needs to pass it separately. Most of tracked-requests API doesn't have bs argument. Actually, after this patch only tracked_request_begin has it, but it's for purpose. While being here, also add a comment about what "_locked" is. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi --- block/io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index c2d9b1f849..5c1a1b388b 100644 --- a/block/io.c +++ b/block/io.c @@ -762,16 +762,16 @@ bdrv_find_conflicting_request(BdrvTrackedRequest *self) return NULL; } +/* Called with self->bs->reqs_lock held */ static bool coroutine_fn -bdrv_wait_serialising_requests_locked(BlockDriverState *bs, - BdrvTrackedRequest *self) +bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) { BdrvTrackedRequest *req; bool waited = false; while ((req = bdrv_find_conflicting_request(self))) { self->waiting_for = req; - qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock); + qemu_co_queue_wait(&req->wait_queue, &self->bs->reqs_lock); self->waiting_for = NULL; waited = true; } @@ -795,7 +795,7 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(bs, req); + waited = bdrv_wait_serialising_requests_locked(req); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; } @@ -877,7 +877,7 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self } qemu_co_mutex_lock(&bs->reqs_lock); - waited = bdrv_wait_serialising_requests_locked(bs, self); + waited = bdrv_wait_serialising_requests_locked(self); qemu_co_mutex_unlock(&bs->reqs_lock); return waited; From patchwork Wed Oct 21 14:58:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 514CFC55178 for ; Wed, 21 Oct 2020 15:09:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 937F820BED for ; Wed, 21 Oct 2020 15:09:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="qdS48w4t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 937F820BED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFk3-0008MX-Fs for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaI-0005n4-KP; Wed, 21 Oct 2020 10:59:26 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaG-00085a-AJ; Wed, 21 Oct 2020 10:59:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TbDyhYt4ivaH1OpFNXMUEI44ep956FMgBj2EvacG9nbvSnAdPjRQRZ0YbwRYMwU7TqWrLAkHF5l1YuTPrpuLTZq/mCzR5DtYaWNX5Ez9zNj2oRu0m15pAI3jL/ecVYGEpJCI2ql32mtocCWhtRcN9VmMGLjUpZB+51lwlZKNVhf27AzzOemrKQhjztv1MLIn+t/cM9FpnpILc71GoRNzSqWgWb9l4GTfFuweoxgdu9lXi5NnI3QsosJjRD1Z/YNxkcM6JU/qgk1glD2E/DJMfTq1pAQwEkmz5WzxfZsgCOEAm0ZImNcwmhbuXVRARKslqN/tc1maCSupKNgoHv8Z2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=687hmuyWvjwZgQ+nk9PUlLDrOovkaiK6JIJv01VVUMA=; b=NEAd/hUt8rNeucTs924x3KMy5sE33ryL29yWE8k4gteSm0rFicQX6XS9G/CnXUp0k3kvhTlqh0fd+tAH6RPUujAssp81WdxmXz5R0jsVcqVh8t/hfr/aY1+uMKLVyxjDaBUz38IpxLJGeBv12slndvVhsYChYJo/xCvoqnXlRlDA2i0V27py00RfuL3fptzc6hFMcn19iLkxFCX15+o8ZVOE0UBqirVFzbvYYl2CuUeR4jvc/tRrkUZ+F1ZxybLsEEczKzPDITx7p0HH7HEA9izau6JWURNwyl8jW7+lJLpPEaqI8QkGwzYunr3Peu6kqCk8Va0duqPH9DdIO5gvEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=687hmuyWvjwZgQ+nk9PUlLDrOovkaiK6JIJv01VVUMA=; b=qdS48w4tjrsJi/5iiaIgX4tRv60kfBy3q5rkKQVuVSHpKzQhMqpZFnirf5O7eJYADoKg429YmwaeNKN3uGRUvjsxAm7BCYmlp8s2MJGueidIz+wctVviY6f2Vy+2zGR9atpyyajGC6JHpd3NlL0dXZZumzoeZmdPWOCp6e07xXE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:17 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:17 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 05/21] block: bdrv_mark_request_serialising: split non-waiting function Date: Wed, 21 Oct 2020 17:58:43 +0300 Message-Id: <20201021145859.11201-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7067125f-4d9f-462d-2586-08d875d1e1f2 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: be/7dvBSVnYT3pshXU8XzSXpVhwrQC90k33tLyWpL0gfvpMJaH1lZs/4aAjT6yPo5DTCii+SI9OwPEx8eMWY67+HTNyu5fWUb7647JZQsiXx3/vbdpGplip1911Y/sIeofu1tpFa4CKk08lXV/RpqRt4KS0GfDeaNFySDniQPdD+LAJ4W9hSih9N0SnmCvqPYnSaQQM+DzIyMkieG1+p6u7Y4G2bEsC8XqFbtK4QgaLi+GIKeFOe8CYpYS+30xVho/dSEEQEMGTV51W/h64t91AFdxXkw4ZDMLM/k4HuBHNFGfewUUYMzj21I63RVK4cgS29auAsk3U+iIpvdpGZ0A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jF+1M2XdLJjUGkVGPaQK+3IzLw5+aH/U74sSjAs6uaSlxpcm4iopgJ5M1aWOLHtQlTRbg2ecJxZfDVZrfolJmfu7BockoBCTTHipcneT100b772I/TJlawcAyswQ9F4o5sEi/t3ycCMYbjWmBk0VVJGFs9nNE8S2NzeyjDGyYgIIwjKxfYfYBxlv52vUKTgjRO4ttL0T9xbgDjwt5PGbpsx1cQr6KrwhUthZmNUXc2ZeLvG8/q2uN0cbOP/uKwjSd3AcZAa+tvNWC6Ez5iGFNFNKVFVia9G86UmPGKk+Z0n/Rm9wYdcgRddi8/vI7mfQpWO/+aW8g4KsReKMHmFbX8eHdzVl8jaH56DgU/xGu8qX3J9y4/mYq+7p9OCFnZq5NO4m12VAFJGUiIBSucy6FQbeCGVkSujSM/YJ4rMtJBthIHG2ndKEOiELVquMvDMkUSrshXaARISFy6U94g5C6whrkRh06p1WzSKTWFezrpTxt8UrZYl+9hKroBv88qoqikaJJIvbFczcsByqVGeJjqMqDYoBZdnJ91oEBD98Z4siqhwC7EMav9kysgocuIur7LWBaXZzgL/nPhZtahmdQglT9z0DN30R78WPGdTju6OcDfBzcS1G46k5NqljL6bX/MATNTSj2jPqt+VoyYdvOg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7067125f-4d9f-462d-2586-08d875d1e1f2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:17.3397 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iDJEgl+22iPuiC5dzLDSBEIp9KcvjfNxMHk92uO6QMQGbcoSv12fFgcEC7k/jwJvXHmXd94j54IURnY9usLBTSbIVd9f86uqny/l8WErImM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" We'll need a separate function, which will only "mark" request serialising with specified align but not wait for conflicting requests. So, it will be like old bdrv_mark_request_serialising(), before merging bdrv_wait_serialising_requests_locked() into it. To reduce the possible mess, let's do the following: Public function that does both marking and waiting will be called bdrv_make_request_serialising, and private function which will only "mark" will be called tracked_request_set_serialising(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block_int.h | 3 ++- block/file-posix.c | 2 +- block/io.c | 35 +++++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 38cad9d15c..887b0668d8 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1052,7 +1052,8 @@ extern unsigned int bdrv_drain_all_count; void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent); void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent); -bool coroutine_fn bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align); +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align); BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs); int get_tmp_filename(char *filename, int size); diff --git a/block/file-posix.c b/block/file-posix.c index c63926d592..37d9266f6a 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2953,7 +2953,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, req->bytes = end - req->offset; req->overlap_bytes = req->bytes; - bdrv_mark_request_serialising(req, bs->bl.request_alignment); + bdrv_make_request_serialising(req, bs->bl.request_alignment); } #endif diff --git a/block/io.c b/block/io.c index 5c1a1b388b..24ff8d804b 100644 --- a/block/io.c +++ b/block/io.c @@ -779,15 +779,14 @@ bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self) return waited; } -bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) +/* Called with req->bs->reqs_lock held */ +static void tracked_request_set_serialising(BdrvTrackedRequest *req, + uint64_t align) { - BlockDriverState *bs = req->bs; int64_t overlap_offset = req->offset & ~(align - 1); uint64_t overlap_bytes = ROUND_UP(req->offset + req->bytes, align) - overlap_offset; - bool waited; - qemu_co_mutex_lock(&bs->reqs_lock); if (!req->serialising) { qatomic_inc(&req->bs->serialising_in_flight); req->serialising = true; @@ -795,9 +794,6 @@ bool bdrv_mark_request_serialising(BdrvTrackedRequest *req, uint64_t align) req->overlap_offset = MIN(req->overlap_offset, overlap_offset); req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes); - waited = bdrv_wait_serialising_requests_locked(req); - qemu_co_mutex_unlock(&bs->reqs_lock); - return waited; } /** @@ -883,6 +879,21 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self return waited; } +bool coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req, + uint64_t align) +{ + bool waited; + + qemu_co_mutex_lock(&req->bs->reqs_lock); + + tracked_request_set_serialising(req, align); + waited = bdrv_wait_serialising_requests_locked(req); + + qemu_co_mutex_unlock(&req->bs->reqs_lock); + + return waited; +} + static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, size_t size) { @@ -1395,7 +1406,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child, * with each other for the same cluster. For example, in copy-on-read * it ensures that the CoR read and write operations are atomic and * guest writes cannot interleave between them. */ - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -1806,7 +1817,7 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(flags & ~BDRV_REQ_MASK)); if (flags & BDRV_REQ_SERIALISING) { - bdrv_mark_request_serialising(req, bdrv_get_cluster_size(bs)); + bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); } else { bdrv_wait_serialising_requests(req); } @@ -1972,7 +1983,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child, padding = bdrv_init_padding(bs, offset, bytes, &pad); if (padding) { - bdrv_mark_request_serialising(req, align); + bdrv_make_request_serialising(req, align); bdrv_padding_rmw_read(child, req, &pad, true); @@ -2086,7 +2097,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, } if (bdrv_pad_request(bs, &qiov, &qiov_offset, &offset, &bytes, &pad)) { - bdrv_mark_request_serialising(&req, align); + bdrv_make_request_serialising(&req, align); bdrv_padding_rmw_read(child, &req, &pad, false); } @@ -3139,7 +3150,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact, * new area, we need to make sure that no write requests are made to it * concurrently or they might be overwritten by preallocation. */ if (new_bytes) { - bdrv_mark_request_serialising(&req, 1); + bdrv_make_request_serialising(&req, 1); } if (bs->read_only) { error_setg(errp, "Image is read-only"); From patchwork Wed Oct 21 14:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EBE8C388F9 for ; Wed, 21 Oct 2020 15:14:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8E46D2224E for ; Wed, 21 Oct 2020 15:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ulti7Xy8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E46D2224E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFpC-0007Gw-G8 for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:14:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaJ-0005pD-6H; Wed, 21 Oct 2020 10:59:27 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaH-00086M-Ad; Wed, 21 Oct 2020 10:59:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=boJZ6yjjWJD/BEo1z+goyjFdX4dF5uAlmBawPYB/WmQU99v+zTX+Ik79YzeoOUKHggD+RTjfWpx0QReCwHoqkOGNuMqCbY9+8FdZf1HmBZzbCjKiyZurcrxoKsm7pBHxjtqFxmgISAgFtJtPEiXzWNOYluU8DFNW8ZJZW0pCjrzor45s3i+5SXaesWjfsJPkmNQdAo/xAHJl6k6FkthfOrKoiX0bwEkzliSAzLIwXcDG/PLBq8XBhgETrGNu4Ptt/qWrDRwlyKBfHJKhbGQ6cEdzuVwLTedMQCFaHaaUgzQXOuOrwPcOXLOHbsy7LuBesQK5nqQIz1WeAMIwzphrpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0WXMohePJA/Q4N4eZzbyc/6FDPwjFlN7LE+ifLcBsMs=; b=MlSFrE1Af9Zs+Y3mPl6rDWDamME5pEFaFbrl/EVZZkp32Uz3oUntXW5ezZTQBKJVEuXSMcHLdQm3nzXuuSNb7B2my/bPyTVeeGZ2E1a4y74oYlte83xS27K8f4mkYXkY5mtVwgOpWahC+c2TAnr3BPl4w6fo02+hfzMQmHt4nvg/Io5lCTrNa1YJQ5PWoM4X8vXSrUVpMvhlBaYXVaoZsbs/zFZ6cjXwkVkqdcWgaZqtX8msMLZ0YCDpwkuXkx6K4yL3w2y1rsbv8XLLGgW2jjXWIrJATq7/O8QseotPM9eWwHg3De6x6J/9CuQ+3iHYLb9e8+uNyElytzg8OmiKZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0WXMohePJA/Q4N4eZzbyc/6FDPwjFlN7LE+ifLcBsMs=; b=ulti7Xy8M6Dx493k6RRjg7nKKTy9OjWItO7GGMY58YRcbK81xt45tWdKqvJ5YKgA0d59cg3NP5mjpIxI/Qc2Yl1EklBVDAlySfZmd2+3Wdzkqy0JM33DoMSj6ZJWM/fAxec97tUBS3sx+D/ZDNN6PRCXFbrnWrRzztLU9p7bkMo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:18 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 06/21] block: introduce BDRV_REQ_NO_WAIT flag Date: Wed, 21 Oct 2020 17:58:44 +0300 Message-Id: <20201021145859.11201-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c015f124-b5ee-49fc-36c5-08d875d1e266 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ts2D4mkCxuQ5dlqTSdQ5oabvC0p/KPXM6XMZr9+xxWz9eQR1GZrUEiYWyN1U1rjHLECpSxVAiyWsuNxSotMRXuZO63ab+9UFHk1N9Xe9Vy9wj32v2pT4G366M6iSlsxhYAXQRktgFh/VDJVrZbR5+maWO8KdQepecFYSzF7ovdfW1MfWYR6EuXcQV0KqWucKCtDEj/0yUgwDGK2LgKhmY8zQpxxZTazQSGTeJE7/peN/0CDF0LwmzMNLaldYfr+caJ9CQWtR74FMJwF0LBILi8BOqsu7+9mje3NcBupz+dJAkJMSmu28y5ua4FdE9ow8XDekL1mzcGLLO1qdGUWXvA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KToEKnNmuIfNiZS/JQQPnxmkoG8a+Gm1mlTZUq6dxxk32WEG6Mgnv2/pu8mFy0bSIBwKqKlVjstV9xYW8LMqbWSaKY6vretBFwz0Ck8j+xkAdhy65ZdvGBRUDALRZ9ppUHz3Ccn4Q7JaLXCjQ/Ezx3q7uW8ryMtLyQqQScwbk0enE67McHWKQRsygiEDLSsJFyk2YqH2+PteyuBjeraiNHMMx5X0GIQTDCWxAq2tMVXKbllYYDyT3cGXlG8Oak18/7dZaeH1pFpGXLaMewbthPcBPdd+etOWdhUnmR7QOQPwHZ6fgxc4QiRbykHwpoY2S1XMsc+hXl+QygxVRx19llOwRxMdOevuO7/P4r1eqlSi5NCEQHB4MJsasp+E3gHFOrfjj1e5SAq9+zJfyM1YOVZuYJz5rbJmfgGMKpG1A8PvmBCbGBrA9DPDLBgf3Nm0b65elQkxw1/gZQrOD8gUpG2qYQeXh9Yl8IAXQ1xNwZcpzcSaBu9hERjDeexT0/r5YQ4UN5p/J5ehTBUzyTe2aLa3+iD+Dd8qie/ABQcuo0cRlDuD/f3082+FfVLvOc2RF0m9jpSXoRSMIZBwbgwuPo9yZljfSE6qhNljMMq8c3Md8Egcry+p1/8drvcfoSPdAgYOQt2ixbj4FViahW8DUQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c015f124-b5ee-49fc-36c5-08d875d1e266 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:18.1163 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LFa4knuO80ZD/cGuhvTc2H/fiLCz1VaWh3UHnelmGJH+A5MXuwXjzsjQUF0oKAnComx5M2SvOfdhj6SBgqzEV4yNYpKbT8T1wtKSxzy63bU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Add flag to make serialising request no wait: if there are conflicting requests, just return error immediately. It's will be used in upcoming preallocate filter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- include/block/block.h | 9 ++++++++- block/io.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index f9ca42fd4b..8a37f9fb01 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -77,8 +77,15 @@ typedef enum { * written to qiov parameter which may be NULL. */ BDRV_REQ_PREFETCH = 0x200, + + /* + * If we need to wait for other requests, just fail immediately. Used + * only together with BDRV_REQ_SERIALISING. + */ + BDRV_REQ_NO_WAIT = 0x400, + /* Mask of valid flags */ - BDRV_REQ_MASK = 0x3ff, + BDRV_REQ_MASK = 0x7ff, } BdrvRequestFlags; typedef struct BlockSizes { diff --git a/block/io.c b/block/io.c index 24ff8d804b..504b656f87 100644 --- a/block/io.c +++ b/block/io.c @@ -1815,9 +1815,18 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, uint64_t bytes, assert(!(bs->open_flags & BDRV_O_INACTIVE)); assert((bs->open_flags & BDRV_O_NO_IO) == 0); assert(!(flags & ~BDRV_REQ_MASK)); + assert(!((flags & BDRV_REQ_NO_WAIT) && !(flags & BDRV_REQ_SERIALISING))); if (flags & BDRV_REQ_SERIALISING) { - bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs)); + QEMU_LOCK_GUARD(&bs->reqs_lock); + + tracked_request_set_serialising(req, bdrv_get_cluster_size(bs)); + + if ((flags & BDRV_REQ_NO_WAIT) && bdrv_find_conflicting_request(req)) { + return -EBUSY; + } + + bdrv_wait_serialising_requests_locked(req); } else { bdrv_wait_serialising_requests(req); } From patchwork Wed Oct 21 14:58:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B2E7C388F9 for ; Wed, 21 Oct 2020 15:17:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B20A22177B for ; Wed, 21 Oct 2020 15:17:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="SvqiCEqx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B20A22177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFs3-0002fL-GF for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:17:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaL-0005vT-2P; Wed, 21 Oct 2020 10:59:29 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaJ-00085a-Am; Wed, 21 Oct 2020 10:59:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYfcZN38Mda6xfAI1a8Yl7pQwqc3GdOCGqwn0EV3Hn4NA6zT5h+1CmdAVfYrE+hSwQx7n5BUWVV9suNtd1Kthi1JNsRTLOpvE8ttAAksPVJ9dKAjW/WeIN3iP8DXcDnzUtvAU6UWvHCUZJD4Uk1VjXVmLiXRjryD1jSVqFB+vacwpkKG9FwIMYaUMygOMIGrZf/5PkT3eiKI7r3ffnBuJSA43DLf4wNWHhq6vlBSTqohE/9YKIUx9mBvMLcTWRzxg/U65VMBKu86qoqnjz1QOpg8STa6YVpvV0SHsXlG35ZNyAe4aZxy0u++8nNaGZlpvUuIlhPv0sWQTlITaOWq7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WRM09K46Sm9w2OXUgAXBZcu9+8TO9U9eGahMz8wpPjY=; b=QzeWLO4J1sQ1VvCInwNkjZ8DP4xxjXW9zB1G5trfjWOD8mVMaNA54UGIi6nYs8QlSEA7kR8BSwH7k0HJvDpRfFJGFIztEjmih7mPTmu847mTWRGm794KFln7dqN06ui8Dpf5omgdFrkwTUJbrfbt5PPqB1y56O8r4gl49wxoygse8H9ip/pMlFqI9ZCFKczE/poxsrkcC4hzjeXgO6uKktZxG+joUGYOuaDUaH5WG/s5vW16Opedd88/yPEPaVpGuq3qGor/DMOXQ8w+QjH1/FPTH8b6zqSK/99VRw9X6Jj1tiodR0y7nQjspBURUIXwuKRd/zg1STOY2DNyxsRs8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WRM09K46Sm9w2OXUgAXBZcu9+8TO9U9eGahMz8wpPjY=; b=SvqiCEqxbphODQMWCDZrEJK+o5r6BnckCC+F8vyjPx4vv4X9mZSFfK4Xerac8XdJAPc8wSOD0R0KRUT7iEqbpTRh9I9vCkLmmv/Obf+xJbCItOdkFiQkS5J0M9kyJruOnwFHNIIGLaijrxmba/RqKLCR5w3+TO6r8Fc34l7dBB4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:19 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 07/21] block: bdrv_check_perm(): process children anyway Date: Wed, 21 Oct 2020 17:58:45 +0300 Message-Id: <20201021145859.11201-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d5299bfc-104a-4c4c-78b7-08d875d1e2dd X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTMdm3NBw/fU0cpWXfFKe5DB/Imujr6MykdMTACqLg52XHG2bJuREXkt4XtcaNgHNYDI7hMf2rmR2XRSmUMH3OGBWEbfeYTQAXh74jtunPC0N25NAXw15KhkQZN6rohoSKG0Kg5irofQrWj3Ksrw6JAPtYN/Yl8+xrs5SiT5MAxRk3OU8bJD/MZEJvnzMyu8EaLYfdGcKBbtETmqCIyGH8JYvOPlFmiPsihF3tDOHvnIFOzHBOJSwbfbnK0kXbAvHH+fX60EW+0VO3QpGWSSjHCj94MRNdXaJdPavYs3PPFzXZUzXRnwQQctUWOLVkzxD5dA/BJPlT/sr+gsoo2ryg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cZyAVU3pqPpaKjrYSfvZuuEFndGK66CF6mqNs31TqaD3iJAyDEpV7ZOVxm7vIyWgf0POlvnDqzdmI2qyelTaWMajr9H+teFpbbMQ791GXtDigwKzSXm7nnNlUOo3mgSoXFZ9KCavQYOmmn5ORGcQMhKqo1b4EwLsCzhPTVbjVVs4y/vAg7sVrNaR9dD34UG83y2YRmA8pBJQwShOFf5qKr6WJPoXwgZm1vn+ufm98VM4CpO8qxI+x7GmTVD0sCKBFtATrQwc0KYoY5Q7Qjn9+ZJDj03SO/f7nUht5FIYj1m8qZokhVKthWUMYAesROkmIa3xs2QI9pCZ8H80cqAV6gqI+sK2UDQiUkJ2JmE8c0QX4HC5v1akPqDES9Uzh+NHTXAwHS/zkS0HxQ2+je5jIkEqoviuLM3iPFRKIA/LzRNvEt0AsUdkk7MFOFVxEslLsLCYo0qKC8O6atedhs/DucDGwrjXoGtUplJ0WelFZqfLZh1pob2MbsyVIJAlRe5G6JEv2HM3CWj/rVEHtTsQvQ8m/umEa3LT2bZw5CgQr1xrWUbDcqWZoyMaEGSHEOTLB8n/6qFdSatay2om0xZ38h0BL1LJBDI3i2PIKxLLF5RFhPniJbpER8fKhJU3XXrFzlZu3g2fWyvilnZBZwCQSQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5299bfc-104a-4c4c-78b7-08d875d1e2dd X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:18.9248 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J4fq/VftzF1RC2BuPjPag9BFF8eHvGfsX5pEXT3xhv/JKUipNOGx6cVBXcPi+p+DwRX21veKSdoHrJY2GSEBDpX6IveMbMF5NH/ll4xbkVw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Do generic processing even for drivers which define .bdrv_check_perm handler. It's needed for further preallocate filter: it will need to do additional action on bdrv_check_perm, but don't want to reimplement generic logic. The patch doesn't change existing behaviour: the only driver that implements bdrv_check_perm is file-posix, but it never has any children. Also, bdrv_set_perm() don't stop processing if driver has .bdrv_set_perm handler as well. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 430edf79bb..4f7c27aa6d 100644 --- a/block.c +++ b/block.c @@ -2048,8 +2048,11 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, } if (drv->bdrv_check_perm) { - return drv->bdrv_check_perm(bs, cumulative_perms, - cumulative_shared_perms, errp); + ret = drv->bdrv_check_perm(bs, cumulative_perms, + cumulative_shared_perms, errp); + if (ret < 0) { + return ret; + } } /* Drivers that never have children can omit .bdrv_child_perm() */ From patchwork Wed Oct 21 14:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60555C388F9 for ; Wed, 21 Oct 2020 15:15:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 77B7E2177B for ; Wed, 21 Oct 2020 15:15:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="pxvbDaIP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77B7E2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFpb-00080u-7z for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:15:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaO-00064K-3Y; Wed, 21 Oct 2020 10:59:32 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaJ-00086M-Na; Wed, 21 Oct 2020 10:59:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BifydPTyNkRXvcokruL92RFKxs7vxCFvBgZd17oKovC4AX9wk1iycJiCYB4Fq1dpG19BijO72kJXtGcscp2g8RmBqKDFM9JtYaHzE24UIeSzZJhvTZLtfHIFcdZ8DZgQR1tBrWW+FB466iX6JrC4NhiGBh5FHyuC/pyPw3J2uwv/yfQOvbCZv3EDAYGc87/s4P3AlkuDwJGtJj1NLZRIVUFa/8epKUI4KihcYRpm2q/qht0NkQox/HFIsmNqjBclRo9KvQ3fTYmt7eOhezWCYC7vC3XqzBSDd9CmbW865iexDm/XN5Vy21hvh8F9efla6NnsrWDD/nxLsnTAafBjeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bk9xnLRJEkaRCqwclW4RZ1jHwvcdggDXzWHxBtZNzEI=; b=hYzTTcC7H24YAANDQt6wPae1R7c7SW6hsYTVsVvp4XaRysINe3Y5Z22v/AAF+kwQnD4Od4aE6jZWGB70X4Z9W3llUhbx1HUrDYs+K2anYz5NoJ4mJArd4mtQwilYiTsBEcRudeMcd9VGuvpw94XhSLMvFJSKc6lpQ+cKrQ32DBtDpFCT/ER0oqinD75vBqu7pVdwTpml0NqP9p4a6tuMcb2UIkGwl/MNzzjMQ1jASsWgpWUx3yXwhHCk2DNk/lKZYG4Y0eypStVpHh6dzEOhP69Lmv+cGAB7LR11kFrVdTwRoKCqJa9fD7y4HkDB7Q4OSqfLD+9bC9A4fApmLq65rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bk9xnLRJEkaRCqwclW4RZ1jHwvcdggDXzWHxBtZNzEI=; b=pxvbDaIPRWfzQFD6dGBjKe7Dlm+TgQcSaLjRG6arSQG/RmNEd33mVRCmkiY+cHrOC5qBZmEbfuVtHbxIDTmBUmzZOZGwu5fLKjcSf28Ixy40eJ8G6oyAwBJioVh/tV/yo/2FV79C+lo02HiavHZQYhigb0yyEObjYinKyNzq/Jg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:19 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:19 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 08/21] block: introduce preallocate filter Date: Wed, 21 Oct 2020 17:58:46 +0300 Message-Id: <20201021145859.11201-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3bcd6d4-a95c-448e-6384-08d875d1e35d X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:64; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +LqXQGGhuPMaPnaqabkOFS2t84DJfhnGUDCAb8/GAhA9cM546bCmH312e9t5XJ+VXpEUmgYzXiSzEnSLTzEirHRX7qQfdwhocjuU9u4mvleU7gH9NXh0jI33yzax+Z5bYvb8VkUl0K5CkttJPGxqLJzzjrchwwPfkrx3hfxH3cHmnU+kaOFF4S8fbwnbjSIvatdXUIobg4sborNpLjCygHTLwskohCEv4H3mDTAR/ttARFAQvlaDxP1+b1Van7bHU8p0L9zOHvp1fhblwVVGDNC4tvWsciYS8atblXJhgYKAwt1mt+mMLlwhYnlVsTz32guzyhWIx0xWmUNBmVKEUiQplWyXh4XXSBlNPet38RGQ5g2KW1hC0AXFRwKZrr4t+GUiioYdAeZxbQRFOWw+7h424FETKCzK54gYRo1ySxTyPG2cKrqz86fzAGyQviOxzfqABH9VnwiPwaYf665bNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(30864003)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9fYJkC0OdzdsS8SOSS+vCKjEmZiCCrv69YP/U21JdRb/FYHyZl+n0nqO4vjmKhDjg+P+oJF36CZBd5mONhx5JJacIJ10+mwGZhch973LnLGctMmFyETyghU3z1oqBNfNoUPpVK3qsNBFlTdqDVPl6qL+73OzHmFj9XfngFMIVcdHXkp3yPdjliKOVVfJUt6FLX+RWilURBFJKFDdd7O4F2yTFdLGeSE43IzciPNH1Wuc7l2hczXFwJaNV8CSJ9nNaFe6gOElXDB8mtNNeQc7i48VeNQu8HgyrJcLwLNHnthezBM9l6dyOJ0Yvwm1tydQK4SUsDbjkadG+NkwtcOVqMhnJNQCvg/VEzmyDj3izur8z8aMQs6SZDangzYZgmGVI3A++PdazhZOpaT0dorYmshDzpRGlZ0TDDGnoGI0hNjv0IcFMUvl75MbVT0Ng+iTzKerde95hjJdKElY/LdQqWWbYzdA/TqDiDpZAxspbZepDtxxtwV10GLZuH2vWc2NpeNmodk6ZsHHGFAosdR7LtolhotXqxluxryu+C36OfDWl5M0ODDxt7jCzpF6FTe35+5/Owwe2IjdYgzH66qGlwnFkQ9XbMaXJlELU4+Er2bsnfTtWlgqBvDUJO6JaIW8v/BX5VyKH+rJ7WvRC4oJSg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3bcd6d4-a95c-448e-6384-08d875d1e35d X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:19.8746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SGHoqYCj7BumukfmHxZBtN5e0o//m2l9ZaBN2FX6USl5NuRuY5C35FpjL1Jc8hz7+gPA6iBSWMKBECh612WLLHhOUUWY1vYZr6v+Uo4yUzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" It's intended to be inserted between format and protocol nodes to preallocate additional space (expanding protocol file) on writes crossing EOF. It improves performance for file-systems with slow allocation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- docs/system/qemu-block-drivers.rst.inc | 26 ++ qapi/block-core.json | 20 +- block/preallocate.c | 559 +++++++++++++++++++++++++ block/meson.build | 1 + 4 files changed, 605 insertions(+), 1 deletion(-) create mode 100644 block/preallocate.c diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-block-drivers.rst.inc index b052a6d14e..60a064b232 100644 --- a/docs/system/qemu-block-drivers.rst.inc +++ b/docs/system/qemu-block-drivers.rst.inc @@ -952,3 +952,29 @@ on host and see if there are locks held by the QEMU process on the image file. More than one byte could be locked by the QEMU instance, each byte of which reflects a particular permission that is acquired or protected by the running block driver. + +Filter drivers +~~~~~~~~~~~~~~ + +QEMU supports several filter drivers, which don't store any data, but perform +some additional tasks, hooking io requests. + +.. program:: filter-drivers +.. option:: preallocate + + The preallocate filter driver is intended to be inserted between format + and protocol nodes and preallocates some additional space + (expanding the protocol file) when writing past the file’s end. This can be + useful for file-systems with slow allocation. + + Supported options: + + .. program:: preallocate + .. option:: prealloc-align + + On preallocation, align the file length to this value (in bytes), default 1M. + + .. program:: preallocate + .. option:: prealloc-size + + How much to preallocate (in bytes), default 128M. diff --git a/qapi/block-core.json b/qapi/block-core.json index ee5ebef7f2..e74669159c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2828,7 +2828,7 @@ 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', - 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', + 'preallocate', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, 'sheepdog', 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] } @@ -3097,6 +3097,23 @@ 'data': { 'aes': 'QCryptoBlockOptionsQCow', 'luks': 'QCryptoBlockOptionsLUKS'} } +## +# @BlockdevOptionsPreallocate: +# +# Filter driver intended to be inserted between format and protocol node +# and do preallocation in protocol node on write. +# +# @prealloc-align: on preallocation, align file length to this number, +# default 1048576 (1M) +# +# @prealloc-size: how much to preallocate, default 134217728 (128M) +# +# Since: 5.2 +## +{ 'struct': 'BlockdevOptionsPreallocate', + 'base': 'BlockdevOptionsGenericFormat', + 'data': { '*prealloc-align': 'int', '*prealloc-size': 'int' } } + ## # @BlockdevOptionsQcow2: # @@ -4002,6 +4019,7 @@ 'null-co': 'BlockdevOptionsNull', 'nvme': 'BlockdevOptionsNVMe', 'parallels': 'BlockdevOptionsGenericFormat', + 'preallocate':'BlockdevOptionsPreallocate', 'qcow2': 'BlockdevOptionsQcow2', 'qcow': 'BlockdevOptionsQcow', 'qed': 'BlockdevOptionsGenericCOWFormat', diff --git a/block/preallocate.c b/block/preallocate.c new file mode 100644 index 0000000000..bada72e1da --- /dev/null +++ b/block/preallocate.c @@ -0,0 +1,559 @@ +/* + * preallocate filter driver + * + * The driver performs preallocate operation: it is injected above + * some node, and before each write over EOF it does additional preallocating + * write-zeroes request. + * + * Copyright (c) 2020 Virtuozzo International GmbH. + * + * Author: + * Sementsov-Ogievskiy Vladimir + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "qemu/osdep.h" + +#include "qapi/error.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/units.h" +#include "block/block_int.h" + + +typedef struct PreallocateOpts { + int64_t prealloc_size; + int64_t prealloc_align; +} PreallocateOpts; + +typedef struct BDRVPreallocateState { + PreallocateOpts opts; + + /* + * Track real data end, to crop preallocation on close. If < 0 the status is + * unknown. + * + * @data_end is a maximum of file size on open (or when we get write/resize + * permissions) and all write request ends after it. So it's safe to + * truncate to data_end if it is valid. + */ + int64_t data_end; + + /* + * Start of trailing preallocated area which reads as zero. May be smaller + * than data_end, if user does over-EOF write zero operation. If < 0 the + * status is unknown. + * + * If both @zero_start and @file_end are valid, the region + * [@zero_start, @file_end) is known to be preallocated zeroes. If @file_end + * is not valid, @zero_start doesn't make much sense. + */ + int64_t zero_start; + + /* + * Real end of file. Actually the cache for bdrv_getlength(bs->file->bs), + * to avoid extra lseek() calls on each write operation. If < 0 the status + * is unknown. + */ + int64_t file_end; + + /* + * All three states @data_end, @zero_start and @file_end are guaranteed to + * be invalid (< 0) when we don't have both exclusive BLK_PERM_RESIZE and + * BLK_PERM_WRITE permissions on file child. + */ +} BDRVPreallocateState; + +#define PREALLOCATE_OPT_PREALLOC_ALIGN "prealloc-align" +#define PREALLOCATE_OPT_PREALLOC_SIZE "prealloc-size" +static QemuOptsList runtime_opts = { + .name = "preallocate", + .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), + .desc = { + { + .name = PREALLOCATE_OPT_PREALLOC_ALIGN, + .type = QEMU_OPT_SIZE, + .help = "on preallocation, align file length to this number, " + "default 1M", + }, + { + .name = PREALLOCATE_OPT_PREALLOC_SIZE, + .type = QEMU_OPT_SIZE, + .help = "how much to preallocate, default 128M", + }, + { /* end of list */ } + }, +}; + +static bool preallocate_absorb_opts(PreallocateOpts *dest, QDict *options, + BlockDriverState *child_bs, Error **errp) +{ + QemuOpts *opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); + + if (!qemu_opts_absorb_qdict(opts, options, errp)) { + return false; + } + + dest->prealloc_align = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_ALIGN, 1 * MiB); + dest->prealloc_size = + qemu_opt_get_size(opts, PREALLOCATE_OPT_PREALLOC_SIZE, 128 * MiB); + + qemu_opts_del(opts); + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, BDRV_SECTOR_SIZE)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to %llu", BDRV_SECTOR_SIZE); + return false; + } + + if (!QEMU_IS_ALIGNED(dest->prealloc_align, + child_bs->bl.request_alignment)) { + error_setg(errp, "prealloc-align parameter of preallocate filter " + "is not aligned to underlying node request alignment " + "(%" PRIi32 ")", child_bs->bl.request_alignment); + return false; + } + + return true; +} + +static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + /* + * s->data_end and friends should be initialized on permission update. + * For this to work, mark them invalid. + */ + s->file_end = s->zero_start = s->data_end = -EINVAL; + + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds, + BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, + false, errp); + if (!bs->file) { + return -EINVAL; + } + + if (!preallocate_absorb_opts(&s->opts, options, bs->file->bs, errp)) { + return -EINVAL; + } + + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); + + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & + bs->file->bs->supported_zero_flags); + + return 0; +} + +static void preallocate_close(BlockDriverState *bs) +{ + int ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end < 0) { + return; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return; + } + } + + if (s->data_end < s->file_end) { + ret = bdrv_truncate(bs->file, s->data_end, true, PREALLOC_MODE_OFF, 0, + NULL); + s->file_end = ret < 0 ? ret : s->data_end; + } +} + + +/* + * Handle reopen. + * + * We must implement reopen handlers, otherwise reopen just don't work. Handle + * new options and don't care about preallocation state, as it is handled in + * set/check permission handlers. + */ + +static int preallocate_reopen_prepare(BDRVReopenState *reopen_state, + BlockReopenQueue *queue, Error **errp) +{ + PreallocateOpts *opts = g_new0(PreallocateOpts, 1); + + if (!preallocate_absorb_opts(opts, reopen_state->options, + reopen_state->bs->file->bs, errp)) { + g_free(opts); + return -EINVAL; + } + + reopen_state->opaque = opts; + + return 0; +} + +static void preallocate_reopen_commit(BDRVReopenState *state) +{ + BDRVPreallocateState *s = state->bs->opaque; + + s->opts = *(PreallocateOpts *)state->opaque; + + g_free(state->opaque); + state->opaque = NULL; +} + +static void preallocate_reopen_abort(BDRVReopenState *state) +{ + g_free(state->opaque); + state->opaque = NULL; +} + +static coroutine_fn int preallocate_co_preadv_part( + BlockDriverState *bs, uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, size_t qiov_offset, int flags) +{ + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) +{ + return bdrv_co_pdiscard(bs->file, offset, bytes); +} + +static bool can_write_resize(uint64_t perm) +{ + return (perm & BLK_PERM_WRITE) && (perm & BLK_PERM_RESIZE); +} + +static bool has_prealloc_perms(BlockDriverState *bs) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(bs->file->perm)) { + assert(!(bs->file->shared_perm & BLK_PERM_WRITE)); + assert(!(bs->file->shared_perm & BLK_PERM_RESIZE)); + return true; + } + + assert(s->data_end < 0); + assert(s->zero_start < 0); + assert(s->file_end < 0); + return false; +} + +/* + * Call on each write. Returns true if @want_merge_zero is true and the region + * [offset, offset + bytes) is zeroed (as a result of this call or earlier + * preallocation). + * + * want_merge_zero is used to merge write-zero request with preallocation in + * one bdrv_co_pwrite_zeroes() call. + */ +static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset, + int64_t bytes, bool want_merge_zero) +{ + BDRVPreallocateState *s = bs->opaque; + int64_t end = offset + bytes; + int64_t prealloc_start, prealloc_end; + int ret; + + if (!has_prealloc_perms(bs)) { + /* We don't have state neither should try to recover it */ + return false; + } + + if (s->data_end < 0) { + s->data_end = bdrv_getlength(bs->file->bs); + if (s->data_end < 0) { + return false; + } + + if (s->file_end < 0) { + s->file_end = s->data_end; + } + } + + if (end <= s->data_end) { + return false; + } + + /* We have valid s->data_end, and request writes beyond it. */ + + s->data_end = end; + if (s->zero_start < 0 || !want_merge_zero) { + s->zero_start = end; + } + + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + return false; + } + } + + /* Now s->data_end, s->zero_start and s->file_end are valid. */ + + if (end <= s->file_end) { + /* No preallocation needed. */ + return want_merge_zero && offset >= s->zero_start; + } + + /* Now we want new preallocation, as request writes beyond s->data_end. */ + + prealloc_start = want_merge_zero ? MIN(offset, s->file_end) : s->file_end; + prealloc_end = QEMU_ALIGN_UP(end + s->opts.prealloc_size, + s->opts.prealloc_align); + + ret = bdrv_co_pwrite_zeroes( + bs->file, prealloc_start, prealloc_end - prealloc_start, + BDRV_REQ_NO_FALLBACK | BDRV_REQ_SERIALISING | BDRV_REQ_NO_WAIT); + if (ret < 0) { + s->file_end = ret; + return false; + } + + s->file_end = prealloc_end; + return want_merge_zero; +} + +static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int bytes, BdrvRequestFlags flags) +{ + bool want_merge_zero = + !(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK)); + if (handle_write(bs, offset, bytes, want_merge_zero)) { + return 0; + } + + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + +static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs, + uint64_t offset, + uint64_t bytes, + QEMUIOVector *qiov, + size_t qiov_offset, + int flags) +{ + handle_write(bs, offset, bytes, false); + + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, + flags); +} + +static int coroutine_fn +preallocate_co_truncate(BlockDriverState *bs, int64_t offset, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **errp) +{ + ERRP_GUARD(); + BDRVPreallocateState *s = bs->opaque; + int ret; + + if (s->data_end >= 0 && offset > s->data_end) { + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "failed to get file length"); + return s->file_end; + } + } + + if (prealloc == PREALLOC_MODE_FALLOC) { + /* + * If offset <= s->file_end, the task is already done, just + * update s->file_end, to move part of "filter preallocation" + * to "preallocation requested by user". + * Otherwise just proceed to preallocate missing part. + */ + if (offset <= s->file_end) { + s->data_end = offset; + return 0; + } + } else { + /* + * We have to drop our preallocation, to + * - avoid "Cannot use preallocation for shrinking files" in + * case of offset < file_end + * - give PREALLOC_MODE_OFF a chance to keep small disk + * usage + * - give PREALLOC_MODE_FULL a chance to actually write the + * whole region as user expects + */ + if (s->file_end > s->data_end) { + ret = bdrv_co_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, errp); + if (ret < 0) { + s->file_end = ret; + error_prepend(errp, "preallocate-filter: failed to drop " + "write-zero preallocation: "); + return ret; + } + s->file_end = s->data_end; + } + } + + s->data_end = offset; + } + + ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); + if (ret < 0) { + s->file_end = s->zero_start = s->data_end = ret; + return ret; + } + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = offset; + } + return 0; +} + +static int coroutine_fn preallocate_co_flush(BlockDriverState *bs) +{ + return bdrv_co_flush(bs->file->bs); +} + +static int64_t preallocate_getlength(BlockDriverState *bs) +{ + int64_t ret; + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0) { + return s->data_end; + } + + ret = bdrv_getlength(bs->file->bs); + + if (has_prealloc_perms(bs)) { + s->file_end = s->zero_start = s->data_end = ret; + } + + return ret; +} + +static int preallocate_check_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared, Error **errp) +{ + BDRVPreallocateState *s = bs->opaque; + + if (s->data_end >= 0 && !can_write_resize(perm)) { + /* + * Lose permissions. + * We should truncate in check_perm, as in set_perm bs->file->perm will + * be already changed, and we should not violate it. + */ + if (s->file_end < 0) { + s->file_end = bdrv_getlength(bs->file->bs); + if (s->file_end < 0) { + error_setg(errp, "Failed to get file length"); + return s->file_end; + } + } + + if (s->data_end < s->file_end) { + int ret = bdrv_truncate(bs->file, s->data_end, true, + PREALLOC_MODE_OFF, 0, NULL); + if (ret < 0) { + error_setg(errp, "Failed to drop preallocation"); + s->file_end = ret; + return ret; + } + s->file_end = s->data_end; + } + } + + return 0; +} + +static void preallocate_set_perm(BlockDriverState *bs, + uint64_t perm, uint64_t shared) +{ + BDRVPreallocateState *s = bs->opaque; + + if (can_write_resize(perm)) { + if (s->data_end < 0) { + s->data_end = s->file_end = s->zero_start = + bdrv_getlength(bs->file->bs); + } + } else { + /* + * We drop our permissions, as well as allow shared + * permissions (see preallocate_child_perm), anyone will be able to + * change the child, so mark all states invalid. We'll regain control if + * get good permissions back. + */ + s->data_end = s->file_end = s->zero_start = -EINVAL; + } +} + +static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c, + BdrvChildRole role, BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) +{ + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); + + if (can_write_resize(perm)) { + /* This should come by default, but let's enforce: */ + *nperm |= BLK_PERM_WRITE | BLK_PERM_RESIZE; + + /* + * Don't share, to keep our states s->file_end, s->data_end and + * s->zero_start valid. + */ + *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + } +} + +BlockDriver bdrv_preallocate_filter = { + .format_name = "preallocate", + .instance_size = sizeof(BDRVPreallocateState), + + .bdrv_getlength = preallocate_getlength, + .bdrv_open = preallocate_open, + .bdrv_close = preallocate_close, + + .bdrv_reopen_prepare = preallocate_reopen_prepare, + .bdrv_reopen_commit = preallocate_reopen_commit, + .bdrv_reopen_abort = preallocate_reopen_abort, + + .bdrv_co_preadv_part = preallocate_co_preadv_part, + .bdrv_co_pwritev_part = preallocate_co_pwritev_part, + .bdrv_co_pwrite_zeroes = preallocate_co_pwrite_zeroes, + .bdrv_co_pdiscard = preallocate_co_pdiscard, + .bdrv_co_flush = preallocate_co_flush, + .bdrv_co_truncate = preallocate_co_truncate, + + .bdrv_check_perm = preallocate_check_perm, + .bdrv_set_perm = preallocate_set_perm, + .bdrv_child_perm = preallocate_child_perm, + + .has_variable_length = true, + .is_filter = true, +}; + +static void bdrv_preallocate_init(void) +{ + bdrv_register(&bdrv_preallocate_filter); +} + +block_init(bdrv_preallocate_init); diff --git a/block/meson.build b/block/meson.build index 78e8b25232..9104e4d470 100644 --- a/block/meson.build +++ b/block/meson.build @@ -13,6 +13,7 @@ block_ss.add(files( 'block-copy.c', 'commit.c', 'copy-on-read.c', + 'preallocate.c', 'create.c', 'crypto.c', 'dirty-bitmap.c', From patchwork Wed Oct 21 14:58:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A54C3C388F9 for ; Wed, 21 Oct 2020 15:18:54 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0FBEE2177B for ; Wed, 21 Oct 2020 15:18:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="F8Yq/jr/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FBEE2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFt6-0004HZ-Sh for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:18:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaP-00067Z-65; Wed, 21 Oct 2020 10:59:33 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaL-00085a-Or; Wed, 21 Oct 2020 10:59:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KiKTGbuwSKknjjZUi2UkwvJRdMjiYMr1Rul5O1K3kWyjLJ7RyUW3+2ZhpNyjuo9Cuw1vzKNe8w4Iseo1U5qK3EuuaTGY3WFUJs6aOqrs1P+jsIvUKlBJqQIxm3f7ZCMDoKcz9dDfcAw3v6xBa1ky0FbR8xjo1tPGWebkhHrZ78UF3QhFyPp3wI+TKgCRcGznM5ETqllA41NJzGxcpRlXHxLLaLHbbDc34o7JjeTNxpqk/j0rILEb8k+4WZRHJVM9y67/cFdURgJBdHqevRjL6NflKw9fyBkL7cT3NQZHpJhSHPyr/PRV+calwC/MUe7mtI4J3ycMhLg4XSr+CRaeIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iCsMwp8on7gc4u06kqzDbEnADVRaXIT9MVKHZXcDDWI=; b=LQnPO4VhydCPBmHtdPFADLnJDVQccToA/3dFvY+ZI2Nm4u6OKPpriW0Ufqf6qw/hTrRbsHY8uxlgMnTRYQETGfq9fp75JY2+gPhrK53nKmNMuRqabmbSVo78+r6Berk6W4eP2fD0t1vH1fNQpmwHNkAht/Pny4n7QIVH0gSgR/1dCRaohJQ3Uyg7xaCSGiwCc/LVQG+HK+WNPTFVTp/VTX+dlZQK53weaWoBDd6UZMcNCYd0voA/hNAGkGqKHPO6CPc/rD90iaNMC1S0ADc/5/pTZPAJLQ4NsjspyJ5ly2KmGtOhrnjJNabV0VRQfwt42KJvh0gKmLDEywZ/aQZ9xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iCsMwp8on7gc4u06kqzDbEnADVRaXIT9MVKHZXcDDWI=; b=F8Yq/jr/q1/Wa9JF+B59sz4tkem1jPNh/6Hg9tW/as9Uwlk2DpKFb8RXI62rH2YaJ+wBOyEWPdHFWhBn1ut+rQ9K5K4MZ9oQK7ynGjb549o/YlNhKWoTavKJuF5v1QW8EQCH1utmDu71ZT0880AK+2utdivmGf2BapWUBXqzKFg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:20 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:20 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 09/21] qemu-io: add preallocate mode parameter for truncate command Date: Wed, 21 Oct 2020 17:58:47 +0300 Message-Id: <20201021145859.11201-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63ffadfa-f7f1-4006-6f41-08d875d1e3eb X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PoLVBgDrjX+I7+fj4JS7rX1z5uJ60Rtfn4lHlnELnSsnqs/XJIrT4w6fj96jBRoUANVOwgCND4DsbOyPPxhuQ3P4ET29/3/GoBBjKqZ+GhBA4FNdHLPkD77ejLKQ4jaAXw6waF8H/VTxmd2ExBNSO0E48C8JK+nixIoFUx31GaXBruJV7vc2gcjE56kSjUlkv8h3g5MhVzDCJWw+nu2krggZ4RooYDiuVIpza+xw9dXTWO3wFLzhceoALAveoswy6T2X+CzTJdC+A9gb8JDAJJfHx7OPwW1Yl4hfyaKXCviRLwvNatMj8u6xUgQczLIHk/IspaNWk2be0d41H+RKGA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 9cUe9dtkZHLfliJnfkaK4b+3RN2Q9z50AtudxyElveYyHMJuTiLq2P9j8A5hXNrz2KnJguRDJWXvlSXXrtclZrxgT5JoyiiQXk7yYKXZfsdbvmwdDM8PPLxEC7H3kkfCzN/8uEOolx9YVmXStS6umKOLZ3mW7yHQ+jKoEHvEk0rlpOpUnGRNb/e8FlD7pswcjhTCi1xZojruL7TXHn7kxcImXxyXqPpVVF06ObWsaLXNa0tzgBztIBoUZSsvTtD59Wj5OWKt9ntWDIGyobsEPnVD+pi7oF0JJ0JZ6Equ350tNmRELgosN/SUFTWbAvupdkdvhT1wEUV7+BXselHg7F4wBeMTJmA0lIiA4cm324HDcHMra5AkbnkMCwUKWF36vq27Bkc40/5F+WH06JFJxhJo9b28/WYdwneGYeYjFkYF0Jcl/GD6TsigX5NswpGin5NyvatD+nqZcop+k0KqSq0DWbtlU5ZmS0rTBLdhhwtOz0pOyQUvYlv2npZT9MTmisaAn1dyBHpgdMB1cJNHx8w5JAa3UEAhzSsSM7GM6VYQtXxwn/Mc37O4B7gwInegsgpSWBQrXDdcw+01jL8uPAA5SBDsebyduYOdE+zrM/OoOu/C+DQKkw1GKQ6VPNignnQFTiO97Fd5ugcd9aBBYQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63ffadfa-f7f1-4006-6f41-08d875d1e3eb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:20.6751 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DGhUmhLFFTHzle/amu3bH/B+uEY0x+ojOlxXR+H1kTRr0g3b/1k9hsWpVNQqHJNkEdbTD3JBVcvVNExFsP4TPvwe+soNSHbV7JkEjRbzLqE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" This will be used in further test. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- qemu-io-cmds.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 4153f1c0b0..97611969cb 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1698,13 +1698,42 @@ static const cmdinfo_t flush_cmd = { .oneline = "flush all in-core file state to disk", }; +static int truncate_f(BlockBackend *blk, int argc, char **argv); +static const cmdinfo_t truncate_cmd = { + .name = "truncate", + .altname = "t", + .cfunc = truncate_f, + .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, + .argmin = 1, + .argmax = 3, + .args = "[-m prealloc_mode] off", + .oneline = "truncates the current file at the given offset", +}; + static int truncate_f(BlockBackend *blk, int argc, char **argv) { Error *local_err = NULL; int64_t offset; - int ret; + int c, ret; + PreallocMode prealloc = PREALLOC_MODE_OFF; - offset = cvtnum(argv[1]); + while ((c = getopt(argc, argv, "m:")) != -1) { + switch (c) { + case 'm': + prealloc = qapi_enum_parse(&PreallocMode_lookup, optarg, + PREALLOC_MODE__MAX, NULL); + if (prealloc == PREALLOC_MODE__MAX) { + error_report("Invalid preallocation mode '%s'", optarg); + return -EINVAL; + } + break; + default: + qemuio_command_usage(&truncate_cmd); + return -EINVAL; + } + } + + offset = cvtnum(argv[optind]); if (offset < 0) { print_cvtnum_err(offset, argv[1]); return offset; @@ -1715,7 +1744,7 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) * exact=true. It is better to err on the "emit more errors" side * than to be overly permissive. */ - ret = blk_truncate(blk, offset, false, PREALLOC_MODE_OFF, 0, &local_err); + ret = blk_truncate(blk, offset, false, prealloc, 0, &local_err); if (ret < 0) { error_report_err(local_err); return ret; @@ -1724,17 +1753,6 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) return 0; } -static const cmdinfo_t truncate_cmd = { - .name = "truncate", - .altname = "t", - .cfunc = truncate_f, - .perm = BLK_PERM_WRITE | BLK_PERM_RESIZE, - .argmin = 1, - .argmax = 1, - .args = "off", - .oneline = "truncates the current file at the given offset", -}; - static int length_f(BlockBackend *blk, int argc, char **argv) { int64_t size; From patchwork Wed Oct 21 14:58:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 439D5C55178 for ; Wed, 21 Oct 2020 15:11:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7A1FB2224E for ; Wed, 21 Oct 2020 15:11:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="s+PmGkkl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A1FB2224E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFmH-0003e1-7z for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:11:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaR-0006E2-Bg; Wed, 21 Oct 2020 10:59:35 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaO-00086M-Lh; Wed, 21 Oct 2020 10:59:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=npqAiHkuEH85VpFIJMV+9n13eHLMVFoMEpiCQsowvOzOZod0pmW4VrWK8sEsIZH1hvX1mWY1vCUNX1Ze9FUretQYhyjDQNHWTS4ZEPW4j/H/ff1hFPXnU6MhTPwW9qdP8EWTSZa2S9J221ol3gsbsB3QPZNl2jw3HOOB1DNxgzEjEaBxLyIQX7KCtOi9eOJwuavWjFB6IjiGaGI1Ha+7biW1QXDU9oBo7DTXF8ab2izwY8PHQ7lpdggglYFXhZlOFl6MWidBd0DqXW80WoCVcPq4W7E3U4hC1T0R18IM+ykn/xwdtglMIYuzXYDkigl/MPEMkFYPR8tOitMDJ+tbEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Rw2wlyYIzYr8C8keOmOJrvsrrg+g73sKNyB+liX08M=; b=K20AKxFtRmHPcbh3bg/yuywj5cf/L/VADI6WfCbbX2gkfITSuxzIdVsW99YIeq87FrDyoZLVBff7Dc9fvIOyxBHkJVkp1MCnhb8p6H8xrO7cliuWNQ9zYeQAnsUB9s43nl2uW8QBA9rWBKiZ33+oKoKj0z3iXi6PmXnBr+vCSnynugppF/gLZw3yBQgnWuzVaMz1qgOF3iuAQkuUpDdXzWd27aTB28vHARYicIMHOFC+uUJcPaL/J5JVEynRLgR1LTnunIU8gllarrR6ikAZnytpKwWIzhCI0sH90vg8gXYDZa0wSSpM20pTXHudHkkQ3icMw0L2yhGvjSpAauJ07w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Rw2wlyYIzYr8C8keOmOJrvsrrg+g73sKNyB+liX08M=; b=s+PmGkklaeBuakxmynu9HgyvTy4Yf7WQhse65vM0q6JA8/47V08WxRgAwHbeP9X2IA5iU0qYvBK3stV1iYw2pF2r8J45PwWzttss26k8p+9B3q4C3ViJ+ZpWokjshAKDwTfMnFixZtcVwWCsAYdR2fKXzP9qCdeKJeqtx1ARZOs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:21 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:21 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 10/21] iotests: qemu_io_silent: support --image-opts Date: Wed, 21 Oct 2020 17:58:48 +0300 Message-Id: <20201021145859.11201-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4a57862-af3e-48e9-3993-08d875d1e469 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WrnA/N/jUUFmVFjEPHzIrfFQwVARmUCYELE/TzgN2LVpfUuZid5M09fEYCgd8RjxrT1ohP3CaexxGxk2me2OFmOICg2L200asv8+2o2it7wvtbpQ2otznozJD3gMFNbxyfg2TyqRQ4vqNyqQpk77OJwkSkfA6OY3B9byqGXMf6dphyJ4/9s4QO7+AeMBMwblWY7YTkZEUltsCK6OH1XkcG/x44t5Y3qjNncIqglZrr0u6wWAysUa9/OR0rr26fkfbgemw2rJQQe3vCxCT2c+12A6E6PZ11KZ2/naBpN2Y7uoUc/CKoLKF9YW2fwCDtfDa2kvQbXMf8tIQbZVeh7u5g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(4744005)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UsXcauNcIpnheQIuHoVNJicpO5U7zJjmURCWwmzMpp8GlLpeJCRm7vowsEIYbY4WfvbeYVMor7X6rBndahKo2pY7sBfp4JXf3wPRSkpYsiIR7tz7OrP9WaH/1l5GCNVtANflsdQOan2A16HXNRzcTStLPDoaSyeUDY6hmTjAMDVqfcJRaPY1f24+YPsOSiaKRtTIdsTQjyispFtJ+gxBgP55dJxXfBn6vzkAGNsvNT01FezPmQdIiHPobytVaAK6VHfdeaU4aSO3dQTGyiq1gAkavFym7QvLA95KIPu022m9FvGFwkAvQgZorpRtAqWhXiZTGsgXeSloRfw9ec5tIpcaez3Gn2KBCCOWCGSMb8Lx5AGhqalZZnJdmrxyHYLfLdN3mh4sfS3O6HmEz3c0BzygYjHlPGeftI7TR6KwLQE6um7KpDL770RQwRIJ1esmUX/Kw2icq7PvFhWWUgXOvERnijcTuRcNNWoHW5hVe5GRt3aH8GHwPvw6/7TTFfTlZe0pW/IQIVHAgQRvZismXs8rfdTz7QiV4ii4S2lSOm5UhYP7Zl8aD6aCSsRbSM4wDU8LLrlHIyhgCaqqLGuBac+wVUQ8j5Ir5Dqxhm3yTwXrL3Nf3xjlTMs92pki0ii0WXp9Mjhpf3EIUCY4pVWvJQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a57862-af3e-48e9-3993-08d875d1e469 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:21.4825 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XeqKvNLZm6+xOpQsmIhQ/VQmIMnUMtX08LeXYFiTiIKRFZtpsVhhWyW9Z9MJXlxJdykWv235N3wK8209DYGCgvrKVowBIseJ8j+9xr2qvUU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index f212cec446..0e3d1d0ba3 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -205,7 +205,12 @@ def qemu_io_log(*args): def qemu_io_silent(*args): '''Run qemu-io and return the exit code, suppressing stdout''' - args = qemu_io_args + list(args) + if '-f' in args or '--image-opts' in args: + default_args = qemu_io_args_no_fmt + else: + default_args = qemu_io_args + + args = default_args + list(args) exitcode = subprocess.call(args, stdout=open('/dev/null', 'w')) if exitcode < 0: sys.stderr.write('qemu-io received signal %i: %s\n' % From patchwork Wed Oct 21 14:58:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A185C388F9 for ; Wed, 21 Oct 2020 15:14:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6B2D82224E for ; Wed, 21 Oct 2020 15:14:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Rz/VEsZ3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B2D82224E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFow-0006dh-7s for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:14:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaT-0006KC-HJ; Wed, 21 Oct 2020 10:59:37 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaP-00085a-Vz; Wed, 21 Oct 2020 10:59:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FH1Ah0DQgkY54V8axLt46CzxrHJzNtmKlurp/csRr7n4fl3eZhG60GfEVMQJPilAlCY7wI4gXPfa68lRSRQBhHZ51w5KfoCKgtc7Po2kNBSOkCmL/RDE0AgC/OO5qDn3xQWhSh6quhiMJHYiID07CvZDwMxdGpDEloeiBr9ZDP7G7MixZZOJNjbU9qhCPawWNRyzg4QEh2AH7J+nXz5n08bXpjTBuHN/0Xlf13r9z6K3B/YligqX4NkJkAkt/qOQrytMzsUR3EqFm9tGkVjBIdOaJ2BAzyxK1RCHCOAuNiGTwgLTLXnNdJe6ucwPtZZWlPfdqJLSOnTBNwWolDRZWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oR0ONDRoF+5EK3YWXkG8xZVzxx8Bn9qVxrPG41lbUIo=; b=SdygHUUlfgwzzM0GTGs18IGcG8d96sRuGjQTRp973dnUGMBFv4ffGFHbhJYbWwQ0Lp9naTlWUZsLxuwanm93pXsY9sssIkDgMfG3Sajd0FF+/w3cl8j9XYju2++XoooFyZbPiz+fgENf6eWzFZ0zQU5dmNnwJxZ/EHs53bYkKtPHEDDYhOaw5gmkHHmyf3KqU9KMY9COPf3wS4iS6RHJIkYV0yzQa621epdY9BB7ASWY7BakOIIhYScfl8ErwwSM35vUrDju+A+Ehf/kuFVSzolpvJWXrQ+9k1maervT/okBNY6RIEjwqu2gKj8zmg5HiNocLhIPomfJUB+jSu/w6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oR0ONDRoF+5EK3YWXkG8xZVzxx8Bn9qVxrPG41lbUIo=; b=Rz/VEsZ3gC+IA2UbqHXDYsD1q+M5dq7R/IwIGEcm3kOVvt8bXkzD02CZDtTqgJ3nfe7iGQtR+6AurQQRFico77KLFBezt1IOll1z49ivmT9h+LEEDcfju4rj+n9iRJJBd817hGf/pYbssxuDabJseZMtw3OWLa/8KC3zDHhi8RY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:22 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:22 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 11/21] iotests.py: execute_setup_common(): add required_fmts argument Date: Wed, 21 Oct 2020 17:58:49 +0300 Message-Id: <20201021145859.11201-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eee0852b-3f37-4d21-af35-08d875d1e4dc X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eaRd9JQqcVY9mCROnJ85r/yN/SkZMnMDpZqF/IGX3lFOtY5UKurTKeJ4x0x0sBZznFMZswCQ6+j7WKs6OH8j1xQ7ytQ7dwkhY7I9CXmIcK76Ez7797W1Znm4pZCeX5415B3rtxtzC87XsJxx7YWWkVYMzWJKwFYozktbI9Zn3f9oNKr7YQScyw9V0gf9LbjXR7CUIb5Ad8winX1+6E69Q/CiBNQ8neOHJt07EHKwFaDkV8ymA+Vtkx0wsF5NbK9lcGX3PHHwS0/GBg800RLKXfQ9ejVb+F7lFK9d00Epg0YwhxlqNBapyom4+NBi5THa3fi6A9lGtVCrUGoeXBKdWA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: fNaSr8K159Gujp6iOX2IXF5nbXqOvzbK8KydD+RvwMkRE0jIyfnvEcpJAJoYskLoHFvvZB/ACdqugJeKkHgjzv1FqVIZNbr4Zd3lik+f0d6bodmnorOR6OP6RtMmlmoNlzpztFuGD7l2YB+CMBIiutxXiXkXPtIHK2hb3ZrqUMiIM82d696li/H0YzcOFGgxghQKAy3SiVLz5HYxajA5CpCcS2Ha1LshrazqEl2N6tURLkFv0GUypiZf+8vNqZpXehWmyvM9FVTvS3Yp1wYbd5qtstoGk4ROcPGVBEyks7TjMniywczxUILl2hDGGcrmBzziwbtbHWAhy577nQn+RgKCoP3Q6YsdKeH7Ct/xXCDlEgjXhJyOWAy8Ea7IgSbX8B6T+XWsxqljFoj5Y/3loRreNSBw9G+3ufhr5pvJfpbb2IueNKeAjXYk2NTaulnuQXxUXkVDA8KAbPau/SOVKT2lGWhcn67UiJeHHcMPHXeefNn/dUxmDKSr4Pj8hf2GNeO7e+BpUTPzS4xWAIVUJB7Vm4skvm7eBaB/7vxVIKXBpyIqU5Q2YmSNDW06ymjDZ7jFhZplUFvDFfhQCxNNQvQMayQ4SKTnuTbUA8ulIndm1BE45Rag+GA1DynSmDx1ozgLW/gGdPvhF3RW/2zk/g== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eee0852b-3f37-4d21-af35-08d875d1e4dc X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:22.2661 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5RkgVJjlHNmCKvgZwNk9O9WsRILBvAV6QBlmGfllnIiNJD3nstkSCateo3RoagY+jEDC0SizVKS3ysZUbaC+FXSvCDLW1qUN2UCcqu9CXbE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Add a parameter to skip test if some needed additional formats are not supported (for example filter drivers). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 0e3d1d0ba3..274396b14e 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1109,6 +1109,11 @@ def _verify_aio_mode(supported_aio_modes: Sequence[str] = ()) -> None: if supported_aio_modes and (aiomode not in supported_aio_modes): notrun('not suitable for this aio mode: %s' % aiomode) +def _verify_formats(required_formats: Sequence[str] = ()) -> None: + usf_list = list(set(required_formats) - set(supported_formats())) + if usf_list: + notrun(f'formats {usf_list} are not whitelisted') + def supports_quorum(): return 'quorum' in qemu_img_pipe('--help') @@ -1266,7 +1271,8 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), supported_aio_modes: Sequence[str] = (), unsupported_fmts: Sequence[str] = (), supported_protocols: Sequence[str] = (), - unsupported_protocols: Sequence[str] = ()) -> bool: + unsupported_protocols: Sequence[str] = (), + required_fmts: Sequence[str] = ()) -> bool: """ Perform necessary setup for either script-style or unittest-style tests. @@ -1292,6 +1298,7 @@ def execute_setup_common(supported_fmts: Sequence[str] = (), _verify_platform(supported=supported_platforms) _verify_cache_mode(supported_cache_modes) _verify_aio_mode(supported_aio_modes) + _verify_formats(required_fmts) return debug From patchwork Wed Oct 21 14:58:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4F29C388F9 for ; Wed, 21 Oct 2020 15:24:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B43D22225F for ; Wed, 21 Oct 2020 15:24:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="G8RqztXe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B43D22225F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFyg-0003C9-Di for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:24:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaU-0006Mu-CE; Wed, 21 Oct 2020 10:59:38 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaR-00086M-VE; Wed, 21 Oct 2020 10:59:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyJzGVro4BWYjipzWKE0YTVfFB/RqLogglzO+RGOGbXvEOMi+PSlgXzwPDaw/iL+uiXMrRF9P0vwm7zOn/9gEqy64R3r2Rsf2qp/5sLN7hEXulo/2waXagy7xF/WMZznboEBL5tsLjEmiZJdy02OXcYPLiYmafwhpVONAjNKlUy55E78mX4o1K+HBI4yjH9j8NEzVqLYeqkhA9mWton2jalZCWAwOGJAkEz0oJcIuxXC1w7w7bc1nVg+XwtAc1+DjsmBK3IG7GVjDxMgfImoQG9tZD1+SHF6gqOgFxEMPkq7oo72DEK+sGDHtRLbj3F0lRYVSYzBIgli+hXobUqbnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1r4UTuyDBg3eudP/ejNSaY3z6P4VodQzs3RlOw/PjHA=; b=TNtTF/XjAUG0vRVYwwSeKpoeHzIpL2S+oup9TGylNuyUWfIKBIIe/1DoSoHuiERIqjVxamwPA4Fg+1ETa4GOfOs0jKRsipQrwRYI+5r4ZN1QGl10F5FjBFwW06Vibsbu/YyXOkJapAzOh9APTkIuo9GETALRewOP8AD4IB+skCKt345i6yQQ3frsx18g4XpqsjPCDwheq5DLyCVMeZKZ4hHWIIfHJPqWIHrblpUXckt1Tn8oVo+ZNjzEqqZxWE4v0aMzYMEtZSd0Oj1g4MQhFmf/aBSPKugr2WZmnOTIsctaFDutd5+SxQ/F5ineQ1iypmqlikNdhxgmkyTP/zFZMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1r4UTuyDBg3eudP/ejNSaY3z6P4VodQzs3RlOw/PjHA=; b=G8RqztXe5q7Tl5TTPHhrkDrroTMZSixp4lVZ9pC6MyEnn7JzSFGSCse6afpBPPSJ3zWzpE7sOuFVz88+30M/bFF9klgsU7MSUMRkmyHPP9uaBzVtSruKaDFBrJBAw3YQJPwNANfVo2aVACN622euZWdLNDu4FnjRKL85vrFKSRE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:23 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 12/21] iotests: add 298 to test new preallocate filter driver Date: Wed, 21 Oct 2020 17:58:50 +0300 Message-Id: <20201021145859.11201-13-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ffd7224-480a-4b2d-11aa-08d875d1e556 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GVXNIFlvZjNRTPpDpmKQ7Afk1sqWRogLzXVSwFUVIMFW6PLTRhPziNGVk+OO98IiOBLJzacu7Kx6lI/Z6QqARh0IKbWpJ4K3MJYiOWUXGhL+16Um1HKThdFw+9AXPaR1p2++oTsEb9cbKLZ4nIQmlZ3EzruI1rxmKpcdb8C60DUr00qQl7IFk7AnmIXYr4FgXDJGUfTMBMqhcUwg8yDk2uD8XO6nUwqlrsVzXJwfehoClgGyFuLbFSk0aco5sPbmrekybkqwfTpTxYljBoAHNtuNggtgWyW92LfAuJfxwyspm2dr5A2jnxfXIvncKDoqZWfN/S0QnT9COa4K6AuYCCeNFgx5vylijKP+DivLZdkpXvoWnB53wE/fFr3ZSJF8XPYOMZfc3ZhQ6iUoIHdjEamH16QRnLeonIbm9pXHEKBgckk0aXSg9+gVGItKtotn7J7OWffwV+c3PI2bhQJQkg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: /222lG6QgYpQk09JRLet1IPD/ch0cx4b2FAOAh7E3BsCG9bAfKxvRjT4eiCdqQNwCSfBvDFwmONqVy6ObANXveH1O3niWFC3moTiURY/sLk7r9I7KHaeZpP7LhIQGrCO/unhxLs/TT9zJmJPxwkSuC44PRs+6JhC8wUiU8oQWpMVhKYnOBYBbvv95J6MfgBvJKP/xOBrRAbvYXKq77eaRHUKt1YHlWf6yK0qmDa4+sYesUib0yVkP48NFQsRK3PoZ63CHMhbuYZ97nWSR3dwD6dqWp2In6/Ayw73aIwxCv5u+cOVGXxMQAx/ufg203evLrsijJ6hm2GPFj46+lj70IWOLqSPWsNdIsOzc8X8L1+Edctgbb/g6RTcBCDlMMctl9RbQZrG78U+fGWUP4jdRwwBSzpgNen5yvlr/n6Je9x/1Y/FH8NtUFOQn5C9XEcwQXzXJa6DnlHf7v+TN71GVUh30uO+7MdYQvdopDYnL9Hx8/03CkrULlioDcggyKzXXq9utEi0U73bILNVcMfrZ7iPC+5dF8nvygQFO30ic8ua84TSq2OYzk5vf9zObLQKLADoYcobKnSdVKCQJmE8Soki06nuGBJ0LHYo8W52PZbiq9oEZZLw5Vcn07ndFIcePRrhdxulvVU8vw8UUUtURQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ffd7224-480a-4b2d-11aa-08d875d1e556 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:23.0745 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dYVzdve5Ffl5xuR32Q99UNMD3s45Fbai9bR5lFgWp7IkyY+9XydkcpFybIufIlRUy2QgHC0MAx4P88oIpWkWOzw4bAX9u+QXytALtMm60mQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- tests/qemu-iotests/298 | 186 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/298.out | 5 + tests/qemu-iotests/group | 1 + 3 files changed, 192 insertions(+) create mode 100644 tests/qemu-iotests/298 create mode 100644 tests/qemu-iotests/298.out diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 new file mode 100644 index 0000000000..d535946b5f --- /dev/null +++ b/tests/qemu-iotests/298 @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 +# +# Test for preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os +import iotests + +MiB = 1024 * 1024 +disk = os.path.join(iotests.test_dir, 'disk') +overlay = os.path.join(iotests.test_dir, 'overlay') +refdisk = os.path.join(iotests.test_dir, 'refdisk') +drive_opts = f'node-name=disk,driver={iotests.imgfmt},' \ + f'file.node-name=filter,file.driver=preallocate,' \ + f'file.file.node-name=file,file.file.filename={disk}' + + +class TestPreallocateBase(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + + def tearDown(self): + try: + self.check_small() + check = iotests.qemu_img_check(disk) + self.assertFalse('leaks' in check) + self.assertFalse('corruptions' in check) + self.assertEqual(check['check-errors'], 0) + finally: + os.remove(disk) + + def check_big(self): + self.assertTrue(os.path.getsize(disk) > 100 * MiB) + + def check_small(self): + self.assertTrue(os.path.getsize(disk) < 10 * MiB) + + +class TestQemuImg(TestPreallocateBase): + def test_qemu_img(self): + p = iotests.QemuIoInteractive('--image-opts', drive_opts) + + p.cmd('write 0 1M') + p.cmd('flush') + + self.check_big() + + p.close() + + +class TestPreallocateFilter(TestPreallocateBase): + def setUp(self): + super().setUp() + self.vm = iotests.VM().add_drive(path=None, opts=drive_opts) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + super().tearDown() + + def test_prealloc(self): + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.check_big() + + def test_external_snapshot(self): + self.test_prealloc() + + result = self.vm.qmp('blockdev-snapshot-sync', node_name='disk', + snapshot_file=overlay, + snapshot_node_name='overlay') + self.assert_qmp(result, 'return', {}) + + # on reopen to r-o base preallocation should be dropped + self.check_small() + + self.vm.hmp_qemu_io('drive0', 'write 1M 1M') + + result = self.vm.qmp('block-commit', device='overlay') + self.assert_qmp(result, 'return', {}) + self.complete_and_wait() + + # commit of new megabyte should trigger preallocation + self.check_big() + + def test_reopen_opts(self): + result = self.vm.qmp('x-blockdev-reopen', **{ + 'node-name': 'disk', + 'driver': iotests.imgfmt, + 'file': { + 'node-name': 'filter', + 'driver': 'preallocate', + 'prealloc-size': 20 * MiB, + 'prealloc-align': 5 * MiB, + 'file': { + 'node-name': 'file', + 'driver': 'file', + 'filename': disk + } + } + }) + self.assert_qmp(result, 'return', {}) + + self.vm.hmp_qemu_io('drive0', 'write 0 1M') + self.assertTrue(os.path.getsize(disk) == 25 * MiB) + + +class TestTruncate(iotests.QMPTestCase): + def setUp(self): + iotests.qemu_img_create('-f', iotests.imgfmt, disk, str(10 * MiB)) + iotests.qemu_img_create('-f', iotests.imgfmt, refdisk, str(10 * MiB)) + + def tearDown(self): + os.remove(disk) + os.remove(refdisk) + + def do_test(self, prealloc_mode, new_size): + ret = iotests.qemu_io_silent('--image-opts', '-c', 'write 0 10M', '-c', + f'truncate -m {prealloc_mode} {new_size}', + drive_opts) + self.assertEqual(ret, 0) + + ret = iotests.qemu_io_silent('-f', iotests.imgfmt, '-c', 'write 0 10M', + '-c', + f'truncate -m {prealloc_mode} {new_size}', + refdisk) + self.assertEqual(ret, 0) + + stat = os.stat(disk) + refstat = os.stat(refdisk) + + # Probably we'll want preallocate filter to keep align to cluster when + # shrink preallocation, so, ignore small differece + self.assertLess(abs(stat.st_size - refstat.st_size), 64 * 1024) + + # Preallocate filter may leak some internal clusters (for example, if + # guest write far over EOF, skipping some clusters - they will remain + # fallocated, preallocate filter don't care about such leaks, it drops + # only trailing preallocation. + self.assertLess(abs(stat.st_blocks - refstat.st_blocks) * 512, + 1024 * 1024) + + def test_real_shrink(self): + self.do_test('off', '5M') + + def test_truncate_inside_preallocated_area__falloc(self): + self.do_test('falloc', '50M') + + def test_truncate_inside_preallocated_area__metadata(self): + self.do_test('metadata', '50M') + + def test_truncate_inside_preallocated_area__full(self): + self.do_test('full', '50M') + + def test_truncate_inside_preallocated_area__off(self): + self.do_test('off', '50M') + + def test_truncate_over_preallocated_area__falloc(self): + self.do_test('falloc', '150M') + + def test_truncate_over_preallocated_area__metadata(self): + self.do_test('metadata', '150M') + + def test_truncate_over_preallocated_area__full(self): + self.do_test('full', '150M') + + def test_truncate_over_preallocated_area__off(self): + self.do_test('off', '150M') + + +if __name__ == '__main__': + iotests.main(supported_fmts=['qcow2'], required_fmts=['preallocate']) diff --git a/tests/qemu-iotests/298.out b/tests/qemu-iotests/298.out new file mode 100644 index 0000000000..fa16b5ccef --- /dev/null +++ b/tests/qemu-iotests/298.out @@ -0,0 +1,5 @@ +............. +---------------------------------------------------------------------- +Ran 13 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3432989283..43da33337e 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -307,6 +307,7 @@ 295 rw 296 rw 297 meta +298 299 auto quick 300 migration 301 backing quick From patchwork Wed Oct 21 14:58:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B370EC388F9 for ; Wed, 21 Oct 2020 15:17:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1233F2177B for ; Wed, 21 Oct 2020 15:16:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="oPVKj5dh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1233F2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFrG-0001tJ-Tb for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:16:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaV-0006Rj-Tk; Wed, 21 Oct 2020 10:59:39 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaU-00085a-6q; Wed, 21 Oct 2020 10:59:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W0O5jHvneBnkDyb3bvrZEoyNII/RKaA+n8O2zgVJJ4Vs9prC6//6gLWwdD197NgET5RIZHsoiENEukBgz0GKzjB4/BwtEUg6PjDWC8NX+sO44+2c9pqzftMyav2NuOvifDewO+caBUq5ipzrGI7jpqOg+94J/HADbCrK1fYQAm/YVXq1KqomJfmK2+ydIrhQnkibvNRDBGKAk9TaL9Gzvw0m5UeeHcBQ/iEo1CWQJP+lCLtMl1k+1/cBttVAALKHdEmeaOtE6x1Lx0Y0KgNzg/54V8O8Shz9M4N+2S/IPagraGl6osO3oyFBuH9yzurV1/sAjFQvcnnACcJpSinNUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GWu577RRtAL9jg22BYbaZSnth7FPOjVTlrtxPp6/6S4=; b=SFOcTBkz+RYtW03HizzvEcRQkky/8IXKp7pBYEFPROhn4asaAXwG40Zx3WoM9/yXAf9C3W/H1YRcWxePMrsGftoN2ONPBd9qESh1NwLOUXsCmqocWNQzFE6fa+krcvzN+rTXTgwQ4S7sRzY+oy3mYcv/lQJNQ5bT4FrIkocsDKWuZHwij24WHspnqgdebiN1+PWp/S1rZ9GEek8q6aNZ4o7TkxH4RV9vnfuFDJZQxrf8Sp40mvIdyGAqpKQy2cnZHN9NiwZxQLlySwhXzGSWP/1otEPw4hVFbEgQumSUWAjfOpDqubFVtqASmHveJS7udnykaK4BsQrLr5UG5YuvsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GWu577RRtAL9jg22BYbaZSnth7FPOjVTlrtxPp6/6S4=; b=oPVKj5dhkqYxk8ccPM8ZTfjomB7yKFXerxZWA4dliRFw9HvEgQkUSAubCJsLLws2dKfDj/6wu65WpWphVaxNl4U+PxeZCOxNl5ZzYyK9U5cMwHFIvhzieGP8Xff4dsyj5IQPvP5mMAKpZT7UYc0TM4t7X5Pf4AJMO+2CZw0wvBM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:23 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:23 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 13/21] scripts/simplebench: fix grammar: s/successed/succeeded/ Date: Wed, 21 Oct 2020 17:58:51 +0300 Message-Id: <20201021145859.11201-14-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7bf21d7-9212-405d-9b00-08d875d1e5cf X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nTA9eKrLiCdj92Sdbv+yU+xMSefjI3rcqAcsHtybwG8yYgXCKtLBNvEJdmOB8Qo+ShG/W7MHC2aPpLJuVFPJj0VSheRFG9pdBqUOy3tdii/7J/9u1XJuaHyNzTbrEMzhVJzzGbYovscxjulGZH2QmJKSuDD0VZv7gCu+ck5cpRHOCsolzuGMpfCHrCcvetFzUjnI8SHyukMESC112i04JGdUwD8vc8xUx9O9bWESeAkbCb7PV51IlFuQ5HDyTMznQon7P5JR/e2L6jy4VUg94jOMfra0edQ/TEYpdk+bFT8lKwnY9K6bZMU5UuSYjxi9 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(346002)(39840400004)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: XOMo7HN0vLHPS2NqF//tT/ELXT8ICo7OOMJDnJKQeCuYF3GVpI/Ejg34FrjpKbENp7A2bGVxjLTDbRMlrMjQxn7sdYzATB1ZW1sWLbdfytWn6GClTXbbtq7sevtdwGs4wguUtui9nrpZS2OEOBUPwlacFr4xsRZpnzy4Nk3vIF5wlo1mU925NYFwjZ2+wMYCKgintnXbCWrdTwB9Hfsy4g/5bMxGKML0Qc60vwbUdvxjcivG6so7zBZlENvK0O7TcA6GZWSqq31MQtc2JRlN+WZZXZoB3bkZdDwbCW3uckYWuegEINGGAVGarRUU7ddjs+srA3gLGTBWh7c8edGoIfvtiFItK85GjhIqlLz9mm1qRry+6Us+7Af65RaVdEgHYL9PZd/2WC4beIZEfijmIkQkW6ZBw5zti6eaCmEr35ZO2NM0RBYnjKXsL1DNMyLQjBfLTuTnCO7gJGqyupKyYDXey3ZY2xM6iDQqzo5H4n6oeevYrhlSCCK41lF2LhhMOMbkPScZxJWg6NteXCU/bw3cvsM3DaIzGQMN5n06VG3/TpTaTo/3IjUi7+UtuTuEz7UFApuC8CcNZ1eptLJl8ZZU/k/6Ho+nKYWIVor5PHuNgOTsOCm9K2MTa+vyXA1K2N6X6lEtjy5tw8E/VWzG2Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7bf21d7-9212-405d-9b00-08d875d1e5cf X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:23.9079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sYBZGRVb+OQpnEa2q8Gk6iKCre9P7SWA8XuivnXYpiaqA5neRqXQEvqbLz/ahhFhcOs+zefA1YXxcIwOVh/SaErZ6QosZwQO0Dtcc6BwmCI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/simplebench.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 59e7314ff6..2445932fc2 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -54,14 +54,14 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): result = {'runs': runs} - successed = [r for r in runs if ('seconds' in r)] - if successed: - avg = sum(r['seconds'] for r in successed) / len(successed) + succeeded = [r for r in runs if ('seconds' in r)] + if succeeded: + avg = sum(r['seconds'] for r in succeeded) / len(succeeded) result['average'] = avg - result['delta'] = max(abs(r['seconds'] - avg) for r in successed) + result['delta'] = max(abs(r['seconds'] - avg) for r in succeeded) - if len(successed) < count: - result['n-failed'] = count - len(successed) + if len(succeeded) < count: + result['n-failed'] = count - len(succeeded) return result From patchwork Wed Oct 21 14:58:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56C95C388F9 for ; Wed, 21 Oct 2020 15:09:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9131C20BED for ; Wed, 21 Oct 2020 15:09:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="GSXCJod2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9131C20BED Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFjl-0007Z7-5a for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:09:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaL-0005xa-Rc; Wed, 21 Oct 2020 10:59:29 -0400 Received: from mail-am6eur05on2139.outbound.protection.outlook.com ([40.107.22.139]:50030 helo=EUR05-AM6-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 1kVFaJ-00087A-Bm; Wed, 21 Oct 2020 10:59:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Poin7yXmanrQJsICL8kwWBaTgtMtm/9fZh7CxKAMR2IZZpOcbMus8feMPPDTl2SMI3KnhH3QZPupy0DIsam5T0KuarL0T4NePPwAEGgJBxKJ8akcrgyngKn+vIkKZrkN5vmmanpwVeFUleu33F2/6Qmw8tjqX0wSr31htcRgd2Km3SQ1jMja4AE5i7eBPWO7VkcDv0qo9xSfVaMpWK+XpwMCxDvMAQzESGRw4lI3+Xc7RnGyN711mRuV9vBBVtTv4yaHxjLjZm7610Dix6r/JJlKL7xeT3/U7SbQgJUGGT0+MZT56aochIWErFOBcfQpF8iw6jAxFk4c4DEG7qOo3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QEXJBxVoOspw464yWfuxZJJdXbTjMB7KDl4x8Lf24Ec=; b=OHqvwsamF2dmSS2oj4BiiNuppPL1vnMl2cas4oxapsSiD2MNPsbKjwfE7MFnwWxXZAWwZgAMqPO3RR16T3EwC/0UDEcSvGel18flezrW5DohzLqxnd/EKKmWxLQ0kgD83qI06K8P//h+MNLt/jes2joVZwa3GiVYIf0U8QWGiCneacsDke2TYdV9b+RqkbgzRSETOqJXpbc3QrLWzdQ2GrrR/bhG9G98PaXAxYf0wPbat5/+hvH5x83/RBjXqyGrfZ9A1diq8vWekZD6pVab+5zmvehzv/m3dISNkXA+nOdbL1gZRachaHCxT2BtxUIOxvdzxdkNlNqGdx4GDotOlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QEXJBxVoOspw464yWfuxZJJdXbTjMB7KDl4x8Lf24Ec=; b=GSXCJod26oPP2ClV7nYOce0NvV4k+dK0HHBWkihDRzd0klXpTqGfNvBvzsJG76NjEwVM9fRCFs6XOkoaxpftQ3KSEEN4cwi23thJhjYX4jgBnJtYtQAH1++N13LHf0m5PHSigDCSLej+oudhuhChcW82Y8Kzs0ytIxOEuAZfhho= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3541.eurprd08.prod.outlook.com (2603:10a6:20b:51::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 14:59:24 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:24 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 14/21] scripts/simplebench: support iops Date: Wed, 21 Oct 2020 17:58:52 +0300 Message-Id: <20201021145859.11201-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d1b1a94-9801-4e42-728d-08d875d1e655 X-MS-TrafficTypeDiagnostic: AM6PR08MB3541: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 61w3FXWTIcZsZKpFkAEBM0anAzB74ygnxKX+scqpMFF+oyTC3GNLcB9Agln/g8Asxvl0LE5I408Z2zNJ2Rx8JGYe+vt/Mjy5TDzvTkVIIflcGrm6MJ9dS3v9+K68tznD/FGW9jh7DZ0K1UANMRtsP1RdHuSwd9OqfezSfmfZ3e1UnJ2omn6k5c5Alk0HRXZ+i2X2PbZLMSpoJgxay336L3qlCaCMmLRJqvErZJGUg9f+o09gPAfEvq/1ist9I/YtMR3CzeOB3hW3oL9GpOhRfscunVqzDKpHJny0Lbp7lA7dtQxBUXgiLWcgEWsgbUgHW0wvFGPNKWIi4psbaoxWgg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39850400004)(376002)(396003)(136003)(6512007)(8936002)(83380400001)(52116002)(4326008)(478600001)(6486002)(6506007)(8676002)(186003)(16526019)(107886003)(2616005)(956004)(66946007)(66556008)(66476007)(6916009)(36756003)(26005)(2906002)(86362001)(1076003)(5660300002)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: H413Q3jK0E/6m0U2vIK9JBeq6jqPlG3nmM9Fh3ZqxAhB4YtGoQaJ9ZxcGKYPw8DWHE5+Hr1eZi8MqGijefgH0OmHiHaOHbDvzp9zgVcFvnj7lpvlyfpKDiHqkBjm6O8YiLaURCtXic/VcSR9dAd1bfZUbw11cnNDwYyZvqs3W6rvcwRNlZhbAFrTAa1oJm/NhrOLo7G57ytjhJmGpnI3HoiSPAfRWgv8paaTnFLT/2Om6OMjpX3bq2K9+5FBPsklbB8jKxi/Q5CNXjiKbn/j7wF4Sk0F4lPv91Y66HXQFVRXjAgwATrd7vaPahUAlyTghpaq6NUzfp+XgGBXcynKDzrNoOXLziJm81DOarK9u3iuTdnzo11HLGQicUQmMzuKYN89n01D2WsYEfWo1P9L1YweTeAAaizEJFJ2Pgoz9VgvsB5Au9iaK1hbd4o7XJlNeNa4d2OAcWOT5Xu/XtqevYVna9VmA6p5+7xcxhzk39GIKP8YSKuoVDvPxtZD7z6xMD1Mo7NVox/ZppB6fKN6VHh1GddswiBpqu77XSHzRKwn4XJz/DOYjtoxHVt4B/yaVx08I651JS2rOCOH2IHrk4EpfM28ZClkFo5Yuji636ZA+qMbo2mOy88B66bSzXrqHfhJZI2YEe1iIGayYfqHGw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d1b1a94-9801-4e42-728d-08d875d1e655 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:24.7313 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eVQc5hVMufC5BeO02wFTqKT3PKOGZ+OISw89ay1P1AHitCCH9qbGKKwwzOeOlZLHTKZ7zCZceq8OMNHPnTBOtuM2OUDh18+AgWVGcwJX1zI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3541 Received-SPF: pass client-ip=40.107.22.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:25 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Support benchmarks returning not seconds but iops. We'll use it for further new test. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/simplebench.py | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 2445932fc2..2251cd34ea 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -24,9 +24,12 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): test_func -- benchmarking function with prototype test_func(env, case), which takes test_env and test_case - arguments and returns {'seconds': int} (which is benchmark - result) on success and {'error': str} on error. Returned - dict may contain any other additional fields. + arguments and on success returns dict with 'seconds' or + 'iops' (or both) fields, specifying the benchmark result. + If both 'iops' and 'seconds' provided, the 'iops' is + considered the main, and 'seconds' is just an additional + info. On failure test_func should return {'error': str}. + Returned dict may contain any other additional fields. test_env -- test environment - opaque first argument for test_func test_case -- test case - opaque second argument for test_func count -- how many times to call test_func, to calculate average @@ -34,8 +37,9 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): Returns dict with the following fields: 'runs': list of test_func results - 'average': average seconds per run (exists only if at least one run - succeeded) + 'dimension': dimension of results, may be 'seconds' or 'iops' + 'average': average value (iops or seconds) per run (exists only if at + least one run succeeded) 'delta': maximum delta between test_func result and the average (exists only if at least one run succeeded) 'n-failed': number of failed runs (exists only if at least one run @@ -54,11 +58,19 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): result = {'runs': runs} - succeeded = [r for r in runs if ('seconds' in r)] + succeeded = [r for r in runs if ('seconds' in r or 'iops' in r)] if succeeded: - avg = sum(r['seconds'] for r in succeeded) / len(succeeded) + if 'iops' in succeeded[0]: + assert all('iops' in r for r in succeeded) + dim = 'iops' + else: + assert all('seconds' in r for r in succeeded) + assert all('iops' not in r for r in succeeded) + dim = 'seconds' + avg = sum(r[dim] for r in succeeded) / len(succeeded) + result['dimension'] = dim result['average'] = avg - result['delta'] = max(abs(r['seconds'] - avg) for r in succeeded) + result['delta'] = max(abs(r[dim] - avg) for r in succeeded) if len(succeeded) < count: result['n-failed'] = count - len(succeeded) @@ -118,11 +130,17 @@ def ascii(results): """Return ASCII representation of bench() returned dict.""" from tabulate import tabulate + dim = None tab = [[""] + [c['id'] for c in results['envs']]] for case in results['cases']: row = [case['id']] for env in results['envs']: - row.append(ascii_one(results['tab'][case['id']][env['id']])) + res = results['tab'][case['id']][env['id']] + if dim is None: + dim = res['dimension'] + else: + assert dim == res['dimension'] + row.append(ascii_one(res)) tab.append(row) - return tabulate(tab) + return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Wed Oct 21 14:58:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C12AAC388F9 for ; Wed, 21 Oct 2020 15:22:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0A7B72177B for ; Wed, 21 Oct 2020 15:22:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="rd51iBV6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A7B72177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFwG-0000Dy-UZ for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:22:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaQ-00069t-1W; Wed, 21 Oct 2020 10:59:34 -0400 Received: from mail-am6eur05on2139.outbound.protection.outlook.com ([40.107.22.139]:50030 helo=EUR05-AM6-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 1kVFaM-00087A-Im; Wed, 21 Oct 2020 10:59:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k83p6CvJuwC6EI5pFwbSM127VIwhZd8aHGxdHFbO2hmThT8NJ4VhweQ3WLza9UMyTuSTPgvlNcFtQS64w9zqhD/LmBmLw0sJgHqw1hb0w/E2V6ZomOyXy3I25la8rGVczL+my8ZnNEHtZwA/0oNqwP7fLszyrkXe3J3AmK6p2nd9q2bIP50VEXQqGa6/XwfplyYMTlI6u50YyUFZ2+AoW8U7Y+FgIU9+IeaVqIj/7vqT3CJhJjrSYp2RricLuMtOogNch/xYPaTubHvbkoflI3nPQSLLP3QHgR+hsAVq6AQ5vySEPu6ElVjbzt8/rod3N/WmF5BoT0e5QShh6BAE6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0MBLroa6hqWyXf7peZ0E4uC9dZbhJl9w2aTdum25V3o=; b=IgxG1/58UlLi7OVBiKKV943iOIIOkGb+vaEF5ohCgBWteRUr2ComicQYzZEXuVSnv42zYyhazKa15slMwsRDYufDeec7JtHqjcbfa1Yko0gk/lf0jOPn3/Z6TRYT/x8g3NR6hlD6ACs9P+FbsWEgU11Zqcya7WvqLO0lcyxNLrMMd+Bz9d0N/xcBUB86GL+s6xfqdZNhYvnS8XBucHUXDTi2+LlCPYr1GovRlW3riECQnsC/q6L9JFtvIn41L+omhVDvsdTx+upigwiF9OQwW8evY6WLln1uaf4Cm0cUYt2pgjclUc9QINhKRKXlAjnZR1id5DuMPJHtrQgPFvEnEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0MBLroa6hqWyXf7peZ0E4uC9dZbhJl9w2aTdum25V3o=; b=rd51iBV66YO9Zjm8ozt+HiVPhBD84spAo8M0KZORNmquMEz49Asn37KyW+wHvzV9B3rrpZnR2zqD29uMv82rrEHlDZsVVTB450TfSK7CnJj+Y/+YNN/r0DGnDKcoy/ozu29//WiB0znMnI5/uBe6Q268cPGK1Qe/u8co1Xc1B2M= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB3541.eurprd08.prod.outlook.com (2603:10a6:20b:51::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Wed, 21 Oct 2020 14:59:25 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:25 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 15/21] scripts/simplebench: use standard deviation for +- error Date: Wed, 21 Oct 2020 17:58:53 +0300 Message-Id: <20201021145859.11201-16-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cf882a9-7f4a-4069-1d3e-08d875d1e6e9 X-MS-TrafficTypeDiagnostic: AM6PR08MB3541: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j2iF6TRjlEk1gWk04TEu4tc63MlFKDQRt4lQhY/pzbbXkHEDkSIUCuUGbbCFtlXG3Rw3xa5BZI2+MqPTmdidqfsw4o6QjwdmRrSaRi7JHtHnhHoqVli6hk6lJ6w4aCmrJUQOl1laFjGajmXHnPPd0FxCg0jX3ilG+uaq6xdUhE5dkt9Koa433WXUbxwuqEww1+5c7KSRsaSANFf5RBWccyf0PmrZjxTKtflXoQzvLfr4jn1IptttDhN4BEKTqDrcRr5GM8e2N1CdskovnwMqGNwb8PsvPFUNU2Uu1xIFKp3FcNFMBZnZ48TEIZ2lzAsgxisEzoitd5kJC83bwJE6KxuAHNgMeRy/WT+yT9cbM6hbavkIjCHqDiDATQxJNC0m47j+3/gLnmTpL8qrbpEF2Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39850400004)(376002)(396003)(136003)(6512007)(8936002)(83380400001)(52116002)(4326008)(478600001)(6486002)(6506007)(8676002)(186003)(16526019)(107886003)(2616005)(956004)(66946007)(66556008)(66476007)(6916009)(36756003)(26005)(2906002)(86362001)(1076003)(5660300002)(6666004)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 8M66nRrFUYgiymgKDHcxpy8sJNlEAdf8dQ3IXltxT+5MlM0G2/ASh1cM4Z8h9JtugGUAS+cWU24WWyuquJINMlhLR3v5hY12dnHTZs1xRtKpO4kVPHWGTXvSb3PjWTicWUka2mKywwA9EM7r3UYFFkcmxCxxYMYX0MtXOr4CsTQLQxCSC1NIXwPiWeLPeTnaFqBfh/sbzrF9OO2vE4YKEuz+ska4Oq7pKfAJuwgotl61LNgYml/nUK1euYOXQEdbLN8Hnu+J3VreqH2x9vGZxVJJ2xYzCPCKyCs1iYicDMRTWm4R2ExwdCkrYyXXZzjxqIWrhtoLKsibR8vcnBex7XVmx7Ihmw+kYS+Y0qGSrN5vCnHc6k7sNxNHLsolC8n+jd7Es2xdcAbFBBko1FEjFKl3mgE5LIOtD2TPw/5WAI/osX+6x/rngaIp89WK2rmJU8O1qRqk4YNmtv4McEPR+x+TNm2wVVYUPfbi29x6+pPMjWiPGadh2q9N2fCnFPXvLduWDMSL3PQdAEjzRYjcICe61C90ucKUu9MX4bvtmAbb6mRV/WylvQtI1mhoIBTBLFPKlEYP7AodWDEMYRj6B4EYX7IEVbcdrDRhEcR+lZA6/5rynq4MJQt2lNswjsFU68ILcCxQdmpZf2tUjewT5w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cf882a9-7f4a-4069-1d3e-08d875d1e6e9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:25.7080 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kBoGB2xOT9xN3Qy7pddJTa99nkL2vQ/XY3ZV1WYlOr1muone890hbBnhiOAqssdcBfOOtEZWYITSzD9piW9ESRwk7p8J4TYD4VRlaCCZ4JY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3541 Received-SPF: pass client-ip=40.107.22.139; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:25 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Standard deviation is more usual to see after +- than current maximum of deviations. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/simplebench.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 2251cd34ea..55ec1ad5db 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -18,6 +18,8 @@ # along with this program. If not, see . # +import statistics + def bench_one(test_func, test_env, test_case, count=5, initial_run=True): """Benchmark one test-case @@ -40,7 +42,7 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): 'dimension': dimension of results, may be 'seconds' or 'iops' 'average': average value (iops or seconds) per run (exists only if at least one run succeeded) - 'delta': maximum delta between test_func result and the average + 'stdev': standard deviation of results (exists only if at least one run succeeded) 'n-failed': number of failed runs (exists only if at least one run failed) @@ -67,10 +69,9 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): assert all('seconds' in r for r in succeeded) assert all('iops' not in r for r in succeeded) dim = 'seconds' - avg = sum(r[dim] for r in succeeded) / len(succeeded) result['dimension'] = dim - result['average'] = avg - result['delta'] = max(abs(r[dim] - avg) for r in succeeded) + result['average'] = statistics.mean(r[dim] for r in succeeded) + result['stdev'] = statistics.stdev(r[dim] for r in succeeded) if len(succeeded) < count: result['n-failed'] = count - len(succeeded) @@ -81,7 +82,7 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): def ascii_one(result): """Return ASCII representation of bench_one() returned dict.""" if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['delta']) + s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) if 'n-failed' in result: s += '\n({} failed)'.format(result['n-failed']) return s From patchwork Wed Oct 21 14:58:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270770 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF402C55179 for ; Wed, 21 Oct 2020 15:20:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1E2582177B for ; Wed, 21 Oct 2020 15:20:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="tPn6bNqO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E2582177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFuC-0005nL-3M for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:20:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaP-00068l-M6; Wed, 21 Oct 2020 10:59:33 -0400 Received: from mail-eopbgr70118.outbound.protection.outlook.com ([40.107.7.118]:29410 helo=EUR04-HE1-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 1kVFaM-00087i-3s; Wed, 21 Oct 2020 10:59:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KW4tMsDW3A2Dhepbj0Hro07qMkXPh7itVjkRt9wBXTqFHU0MVGVPO71lZy+pWnu2Ajwylh/3CzUHHunYNyJZZ1ZNgtFzusC+7/f9JRJcPWOGauVR+5gCUwC1fmkLvFy7+0M+hwMtLOdVolOBSajjib+LEPO6cF9c/P2RkOtNHXU2CaO7p2MYgnq0uTKzV4m53q6kYKSt39MleViuc1H8Y+UP+1m3oqLOOS9AtVSFH2fTyFNo1InMmEBwiNl53yEX/ycq8UTFhErAtZYxr5VFrxZiWsEd/Z/PERVCCA+J/npg8P3WF1ak8GgmFFyz0GWXSU9eoajI3ZoECqgwnlab/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yUzbyurBn2JnvAZK2gIaZVQQ2JNkzIdVBrlRecRaxhI=; b=jo9EuSY1AajdrrMgryPfJQWCOLtj78NE7tmIMLonMQIvl7H/OErTUOcIoil+d5mpdEBSpqiQqx9iZVuFDzspADOb5lUVxOccrboP1oybT0qq5mjtUdClgctyEW6ofm96MOfXzrdkdEUGyyrt4uxReREnTDXtU6kJBJ7e3Y/OWtlp7Q2L/gpKKENvnqNDWkafrGl7mV9YENdWb0J1TIyoaAZUIgqaqhohLkCjz2KwtiIWXvBCkEW5YQZHnKxjpdCJvcyrJ5Bp80WNH1J8vYPDm8VAi23q6arh6jGFvlmERo3UrAXRV6oB97G1zl9OzDD75YYoO60ayG7v5spd4w3+uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yUzbyurBn2JnvAZK2gIaZVQQ2JNkzIdVBrlRecRaxhI=; b=tPn6bNqOxhS6Jscm5ZpZydh7MJ5vP/X7cBT2Yurc1/mgdIBnt/GDKSYxCsYkUIlsLgQVaiR8js62rqCoTqHS5ysIF2rL6YLDqMxrEwo5VPA/ZGjk1lN0xWeKHh7gW7LeB4FkC+3I/ZquyeD2kC4VaukyU0lzT1sKhRC+rz4Ifec= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Wed, 21 Oct 2020 14:59:26 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:26 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 16/21] simplebench: rename ascii() to results_to_text() Date: Wed, 21 Oct 2020 17:58:54 +0300 Message-Id: <20201021145859.11201-17-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f013f1c-11c6-4343-0e74-08d875d1e767 X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s8BLF7S0dmOg+2Ae+Cb30fOEKI1BTuvnQmV+okuyI+HdNaWQzSJXOjC6xVq/8Yx2eJlwkieg9eu34fhIxF7PlEygwyxVc/rb+eFqmVGEqUHlGsFNbtni+/wfg8HpYd1t23vgGEC0iPDhQYCSjwNJIiHHTfmudf31SrBFhzawnEfT4FC1whhXQM41e0dub1OWmhyPMKF2UrOwTiJnf/GcBXKAWrJs4PpHoBoB/m1T8GRmiiwL+aLYUUItXEr3UfSg9VRZA+AaSOQQ5HVkTSojZMctlD4vonGrGPR1aVF5wd30SapA2g9EefeiXwRwyVZr X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(366004)(39840400004)(376002)(6666004)(66556008)(4326008)(66946007)(36756003)(66476007)(8936002)(8676002)(6512007)(6916009)(107886003)(6486002)(956004)(5660300002)(1076003)(26005)(16526019)(186003)(86362001)(83380400001)(478600001)(2616005)(6506007)(2906002)(52116002)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: FlilkmWUU19CE/4YOph8D/16JTtXFbKcxlY8OryyHY+ltb7DK8J10v0d+NCmY9TDMR4En5PKfgzwi+h3M1ji2jZTlAX0fdoGTkrmhIVjn0d+Qq8hQCMyUQUCpsK7MI79HQpK+BYrw3RSVkK3ZlfS5iJ3u6ZVDnwWMI31UdR+yIbQEHTwmn/JT8TN745gyYLfr8bjFAY3zN60w69AqX4Tkq6eSV9vc0CJBEQFNyBpKCRQjQRAxkPIv3R08D94Gn7reYIhVKV8tcQCmQkmAHBP4wM/YKJRFR6GSxYhmNZOyjL4mlRsF6NOqVOUAkPZjtsXHs3AAMo+URRZeSZNOW0TvQxTyX2vXbVReBkNdhEsRMO7UhVwaofaAer1sfAvIVDMV313u1q8xI57Y3N94Y2Fu786FX1eUEscp/Mk1v7sz8ggmht55f8qgqLmMsGjXCY0KFGDecVtJfjvOrhfsNw5RM6C040Sdh6swiy3BhI4YotT4TVT4jkwA8L70XEGLS9NnKCOczwZKn4d/Px+oVDujZ91ZjusVeZIRaYcBcT3mQ/DKV1IdA+LPFlAzDF8C68w1daeaxqm2DOudvhkqKipYrxA6bAVx/a7wUWEv2cXL9x10tL/AMfe53jswlkuY29H3n1C390rJX8cUv1eQhOoNQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f013f1c-11c6-4343-0e74-08d875d1e767 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:26.5124 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dMphS9/NEvtoT3bf6OkWBwa3V5X0Hg9n/vy5fZeSaeGxzzHHzfJc2q72Cg+nU+6pYsGHOdw6drl8N/8VqkueDdRoLmcEbkpSbV7cUam6dzE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.7.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:28 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Next patch will use utf8 plus-minus symbol, let's use more generic (and more readable) name. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/bench-example.py | 2 +- scripts/simplebench/bench_write_req.py | 2 +- scripts/simplebench/simplebench.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py index c642a5b891..f24cf22fe9 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -77,4 +77,4 @@ test_envs = [ ] result = simplebench.bench(bench_func, test_envs, test_cases, count=3) -print(simplebench.ascii(result)) +print(simplebench.results_to_text(result)) diff --git a/scripts/simplebench/bench_write_req.py b/scripts/simplebench/bench_write_req.py index ca1178fd68..e175bcd7a4 100755 --- a/scripts/simplebench/bench_write_req.py +++ b/scripts/simplebench/bench_write_req.py @@ -167,4 +167,4 @@ if __name__ == '__main__': result = simplebench.bench(bench_func, test_envs, test_cases, count=3, initial_run=False) - print(simplebench.ascii(result)) + print(simplebench.results_to_text(result)) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index 55ec1ad5db..aa74b78a04 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,8 +79,8 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): return result -def ascii_one(result): - """Return ASCII representation of bench_one() returned dict.""" +def result_to_text(result): + """Return text representation of bench_one() returned dict.""" if 'average' in result: s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) if 'n-failed' in result: @@ -127,8 +127,8 @@ def bench(test_func, test_envs, test_cases, *args, **vargs): return results -def ascii(results): - """Return ASCII representation of bench() returned dict.""" +def results_to_text(results): + """Return text representation of bench() returned dict.""" from tabulate import tabulate dim = None @@ -141,7 +141,7 @@ def ascii(results): dim = res['dimension'] else: assert dim == res['dimension'] - row.append(ascii_one(res)) + row.append(result_to_text(res)) tab.append(row) return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Wed Oct 21 14:58:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10F52C388F9 for ; Wed, 21 Oct 2020 15:19:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 675B12177B for ; Wed, 21 Oct 2020 15:19:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="PA8fAf/D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 675B12177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFtd-00053B-8q for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaX-0006Vs-Eo; Wed, 21 Oct 2020 10:59:41 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaU-00086M-Sz; Wed, 21 Oct 2020 10:59:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g/PikJLjd0mhX03pHKgqc6HZE4NdNx0RV4d8549Mep0cci7jFaF1cl2INK/sP7Msz2KudmUYjP7UC/7gGXCgZwrWCkbyT5XhUEld6MZzzM1MJ8AVkXRIiQeopQbi61V6duVZD6hzQHNzzwu6J54OnJD6Us2lRp/gbWV+wq5ejyKZwONbCPiy5qQLV6jOJO1rW2a7RI5kdfIX3LT5ScF/RJD3x58RPcRJjH+/p9DtMI36zc6ev0GpUc4em9tJ5s0vYExOSyv5QpWMDEGHqZA7h3PVyYOtvuO1CyZXJqlMgMrasfjMIz4g/fnl77LKO6rvVHK9tMdpz45RN614HphlsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fj/z0TGHy48bGzDIPGyP4zMOBmqroG9KOWvf9VvtcWk=; b=SX5w9iE3/jldtlw2T6Wxn+BMEtOTLzOw6QTQglJmdaJbVHAZzu6+a3ZDUYMiC+haBU+E2S+0It4gNK9Q5PpakYYseFksgYGeW/ZnrGm2MC+IyUXeTR7qeQskp88L1WtB8RGJGz646sA2w+dlR8Z+VB2EQ2iqjhFCYfNXKx4qFIe2VbFu4h3BhHOs54UiOkhGjwOPcizW/DlIlqSOHXRRh7SfONntq8x84L6rdoqnmxT/sYIFm9GakzywHySyeLlm0f1KxmQshUPjP1yiR9F5vOICf0JQou1Jm6Y7gHpMabqZ99Bw8+a6phng/fZNpcNaazn+vTKrW8ASBfZYVuqjlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fj/z0TGHy48bGzDIPGyP4zMOBmqroG9KOWvf9VvtcWk=; b=PA8fAf/DJTl4fDdNlA93nmpBMkTU1Z5pMaZ/pB1JN2kvp4nTRNFrDZEZCN3lnNVT1JMWAYE58tyfUU4ZBvBJHv7IZ9dUyyriRIAQXA8dNUXQGr66QU9pXf9zh6iB83hU1+k/8pjr8kKwaE9OBZti/5iijRQ0CfsuWGBQNqxtb8s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:27 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:27 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 17/21] simplebench: move results_to_text() into separate file Date: Wed, 21 Oct 2020 17:58:55 +0300 Message-Id: <20201021145859.11201-18-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4632389-00bb-4281-19b2-08d875d1e7e9 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oeVyz2p7BHtCh9EsQsZLJinIMgrBNJEq6TbRVYWqkceFp2zf4nGdFK+9PrN7av3qk/7M4IcZy11r4i6jsM1DIO36q/PsRIeuZBYmnobRV9uZ7L+RokcpWrxwLgr3yemuEcqhW683/f9oRSzZc9acmJjl2KOh9LL7J36a5ZKPnUPENKz6dra9aLmDpKVDvdqUbmRz6yP5yRfhUxyLM9LlCApnTVzzFXbwUX1Fu0gOOFJHYWTkPnAI/sW1ZGn5ZNpBwjOGAsgnTd/bAW+17sQHpvpvujqjvfYg33MuJvjmuGEhji8BcxXzPf8mdiYPAtgPNyd3WIH9RRq4h7FjbZgsBTRx40Q8+bEVfyuUJHc0I86dwSNop3JicFYM25g0jzuqnbqvfoaYzPoXsyo8zsCt75KbKKv3DP6U7oYEUArecBQ1LbTXIsMEjNxU1K13tq/YSaSRoaIcdObTXjFZ1Ggf+A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(39850400004)(346002)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: zX7Bb6mfmrttv9dxfBhOYrG5lOxJFd7oUoPz8bIq1/AQ1D7fCvPUqfbRbbJUpA94cRaud9gjgRS6zIPUJkds3Cp4k2rW8+VyneKWqicVHCCm3AwKScvqS+2Y+4Q771qmYWMuLk5oz74PQKUD2SXXx4WX013W9hBVTTZeuDtKKc6BNch89D2Q+5puYn6PFJgMjubud4TIdxkOzr/54BjiJGML53a2OQjAaQYUn9EF0FUK6YwE4y9X8uNagrY/8hd1Gxa8AsmPpGoqzuGA1u5XgniM6OYv15PMe+EhcJfuIIgvNOfU0Y1udxsr97jhWCSN29WqWjiZL1DFkm+UF/4UibhDRnvP419gY6lML06FaApDjQY33vNOPeO70rxi/LmzmIiVjkOGjufBaGoy1wBwrqGN7xbn3lRHo4+t5BX0EZvwB3VgW7hSFXyn5CTxOqvXMsErC49Mpu4EYGdQlciHHhONqoZQPnZudKqmGLRI13iH6En/qDmQWjkdaW/Uee6mjw/7MwTRlv4bs1e1l+wZu8PERr7Thi92T/MPwvcOVtwgLvrPgRKaf6kRrSLoWy6Lg3raSi5lccM3KJAD4Fqyx+S/vz7E8X8O0iiANz0p6JiPwGTn2mxWbPa3pdcAOy6lB9q7qD2QRIZzfrlMtHd69g== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4632389-00bb-4281-19b2-08d875d1e7e9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:27.4095 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vIlAlT+TlDTSfAL1av1NDwLSsYYJjYXUVi7eYvkVRT930/ZUJaPqAsTfI1AZu8xvOtoBAK/vTxg/ywkC1TXlpQ9YsgP1Mu7GPbTnvYZ1YgY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Let's keep view part in separate: this way it's better to improve it in the following commits. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/bench-example.py | 3 +- scripts/simplebench/bench_write_req.py | 3 +- scripts/simplebench/results_to_text.py | 48 ++++++++++++++++++++++++++ scripts/simplebench/simplebench.py | 31 ----------------- 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 scripts/simplebench/results_to_text.py diff --git a/scripts/simplebench/bench-example.py b/scripts/simplebench/bench-example.py index f24cf22fe9..d9c7f7bc17 100644 --- a/scripts/simplebench/bench-example.py +++ b/scripts/simplebench/bench-example.py @@ -19,6 +19,7 @@ # import simplebench +from results_to_text import results_to_text from bench_block_job import bench_block_copy, drv_file, drv_nbd @@ -77,4 +78,4 @@ test_envs = [ ] result = simplebench.bench(bench_func, test_envs, test_cases, count=3) -print(simplebench.results_to_text(result)) +print(results_to_text(result)) diff --git a/scripts/simplebench/bench_write_req.py b/scripts/simplebench/bench_write_req.py index e175bcd7a4..da601ea2fe 100755 --- a/scripts/simplebench/bench_write_req.py +++ b/scripts/simplebench/bench_write_req.py @@ -26,6 +26,7 @@ import sys import os import subprocess import simplebench +from results_to_text import results_to_text def bench_func(env, case): @@ -167,4 +168,4 @@ if __name__ == '__main__': result = simplebench.bench(bench_func, test_envs, test_cases, count=3, initial_run=False) - print(simplebench.results_to_text(result)) + print(results_to_text(result)) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py new file mode 100644 index 0000000000..58d909ffd9 --- /dev/null +++ b/scripts/simplebench/results_to_text.py @@ -0,0 +1,48 @@ +# Simple benchmarking framework +# +# Copyright (c) 2019 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +def result_to_text(result): + """Return text representation of bench_one() returned dict.""" + if 'average' in result: + s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) + if 'n-failed' in result: + s += '\n({} failed)'.format(result['n-failed']) + return s + else: + return 'FAILED' + + +def results_to_text(results): + """Return text representation of bench() returned dict.""" + from tabulate import tabulate + + dim = None + tab = [[""] + [c['id'] for c in results['envs']]] + for case in results['cases']: + row = [case['id']] + for env in results['envs']: + res = results['tab'][case['id']][env['id']] + if dim is None: + dim = res['dimension'] + else: + assert dim == res['dimension'] + row.append(result_to_text(res)) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate(tab) diff --git a/scripts/simplebench/simplebench.py b/scripts/simplebench/simplebench.py index aa74b78a04..f61513af90 100644 --- a/scripts/simplebench/simplebench.py +++ b/scripts/simplebench/simplebench.py @@ -79,17 +79,6 @@ def bench_one(test_func, test_env, test_case, count=5, initial_run=True): return result -def result_to_text(result): - """Return text representation of bench_one() returned dict.""" - if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) - if 'n-failed' in result: - s += '\n({} failed)'.format(result['n-failed']) - return s - else: - return 'FAILED' - - def bench(test_func, test_envs, test_cases, *args, **vargs): """Fill benchmark table @@ -125,23 +114,3 @@ def bench(test_func, test_envs, test_cases, *args, **vargs): print('Done') return results - - -def results_to_text(results): - """Return text representation of bench() returned dict.""" - from tabulate import tabulate - - dim = None - tab = [[""] + [c['id'] for c in results['envs']]] - for case in results['cases']: - row = [case['id']] - for env in results['envs']: - res = results['tab'][case['id']][env['id']] - if dim is None: - dim = res['dimension'] - else: - assert dim == res['dimension'] - row.append(result_to_text(res)) - tab.append(row) - - return f'All results are in {dim}\n\n' + tabulate(tab) From patchwork Wed Oct 21 14:58:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB26C388F9 for ; Wed, 21 Oct 2020 15:21:39 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6A1692177B for ; Wed, 21 Oct 2020 15:21:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="hq7racAn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A1692177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFvl-0007sj-Cs for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:21:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaY-0006Yo-Ei; Wed, 21 Oct 2020 10:59:42 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaW-00085a-HE; Wed, 21 Oct 2020 10:59:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BxsBBCeRXfS30NeorSoP/IOKK+EGVYsxI4QOiiiY3cgumNzEbQ4BWY7Fl+WgmFMKfeXTgQied4S+Q3xaAtL2VtCPZg4zFMjCpjmTEF9jllr3RSjupZFIrYhGRycDeQM5VqQCygrF6zoExEq3+mihyWUvUHPbIoVDy9p8Rqzgv+bRp4Ot7/b5hjU0E/poZz/g7aQhIgBcMMMkdRcS/h2NL9JaCBoGkSnNgwex9eXwXaGgBxxv3E8NwG+FDYOiCtDK28a8hW3AItWp1n4RLIZDmxeRUBVaxVvxdaq6XtIeZH0QV9y/woEDD4hT4Hahz6VMYcOThnit2UKIsWJMBVMmwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgZ2U1mgiZ6DIP+4CzJ28CfUEIpSuR2wCE8qztkFr2Q=; b=IwnhwKZ6KEVUtqO+rR44zRi+T8Gtf8Pl1gKilJouTOE5O3RF06wsYTkQsYZ/tUU0MUMcHLEX9qlqHYp7OXVS1Gep44rX9g6nQlZTiEXCJqbi0x/yZLKaV+4zrt1OZcjSIU6AYg/mHIrJ8VzPcx2jQ83LAyaprJOjKSsHTyRkWm8DU6CxdRUo5wPeWFjrTfMZzanfk8mh6Kftkp7CQQp2hHZbnwAlQVebFXaAGAybimxWl+4RrrGf7kv7LOyU/D4dMTBB9J+/maZvc3qEMQMjlzTMdUTT03XC93QPS0akkmHPjDilW9VjnYjkwqOJ8goVp1zzPewEuAN9n5OzqZSc9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgZ2U1mgiZ6DIP+4CzJ28CfUEIpSuR2wCE8qztkFr2Q=; b=hq7racAnEg/mgW00ObyeQOdQ73YVw3tTuiYcE+RrOrGS1ivkELcVteSEM6L3yKsUNKvriuuVGq8qZXosFnh+cNDyN0p7absbakoC71oe1Rf+bm5t0pXxbNKQtvHMty1rVFkfPDDmuIwl1zxIRI+4B3WvfEXJGXopmzDnAGVTMD4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:28 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:28 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 18/21] simplebench/results_to_text: improve view of the table Date: Wed, 21 Oct 2020 17:58:56 +0300 Message-Id: <20201021145859.11201-19-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0479edec-1645-4fb2-7f93-08d875d1e867 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:612; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EXKedcfl1O0ERwWc/SBR5HnM7DAguLJTGzx6CzRept/E3gIgNoPwNL9pj0At7RWZr9K3VIgWpl5rw8V+lwQw00su9fupNBOOM80l51/UBjaJhyZgMVT4WB2rJcfCUSlN1O3W5+8+6dWzpTNjc5ItZ1dDJ9NMWy6jGPj2QRv/twN/lJ055Svl52cRfbP91P7HKZln8yGVAoRDPZA35Mhp94lM0xMMAhpOu/qpITFbiaDwormJm/JSG3mr+inKPJnJFlXsc6N0vTwJ7UX9shOj0KewlOW9xOnAd/MKSrxgfh9eUSKkW3+LhvJgvEEG+VewD/moJbfFhct9jCx4FPojJiVaalGk8yPYVGaooVnUf2ETozLs4A/t1Cfxcr7KLR4+UTPPVcMaASsDRimtI9d7Kw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(39850400004)(346002)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: UE0JgLfnDaK1uLPYQJg9Tdey7CnSr9nEwKY8MzUUBsi1U3zxASctqLkLnf81X2+0VVZtpcUnmSvl40d7Q6+NSV7woVL7BtEcKKFUw4KycWtI4sxCugihE5IjhYFRKrg0zLvJuzMpzhbJdOyXmgRwIfU7DLP9eVyChuL++JG6uRu3p7xN96P+us1QB5MXtehUdi0z7W6vPeVs+BK/F/TQBud9ReiDoBFaPsQApZuFz2zha3E269V3rhDsQuFaTC6NcBCyc491uxJap6t3vaPJMrtodWKphKwpIOo1hrLjJVWnb3WYgyUaoEDMI0XVx3mTTFymiCs/EkcgIaCgDpLGmAZ1UXdpwDfFcpDu5s67KjcxvGEuxI1yEQ5OX3KaiWv5A0F+NPvMizeJvmv+b+BMyh8G1MLlRQKhZB5nlsAJU0bn/Rmcu51n7P3vFOEHlK0xj+P4EZZcnj4ET8HphKe2qCoc5O9ixgEafDnReObIRJx8SlRL4ZiatuHlBEed49IuaoH9wNO/qYAd4WyiU7+Th0wCoeEaUd4pAfujKRMz4LEgWrauLquivzBWOKaKRT4eeshBSm9F0joDzeQ0NJxMMfP+MpCs/zyTiPDYbZDW9uXeB9HjsQE3Y41j5OhlSQGMOgQoGJWhLqIozq6NmvhBdA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0479edec-1645-4fb2-7f93-08d875d1e867 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:28.1881 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c7WgiUZmGlxxmGBKrAUNrfh7cweDPFom67ly8K7N5NeHb6TtQoPQPuwWtivg/2OoanLu1D1GLNimimsOkHGQVX8Yvtz7Wslbg+ScEYHwauQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Move to generic format for floats and percentage for error. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Max Reitz --- scripts/simplebench/results_to_text.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py index 58d909ffd9..479f7ac1d4 100644 --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -16,11 +16,22 @@ # along with this program. If not, see . # +import math + + +def format_value(x, stdev): + stdev_pr = stdev / x * 100 + if stdev_pr < 1.5: + # don't care too much + return f'{x:.2g}' + else: + return f'{x:.2g} ± {math.ceil(stdev_pr)}%' + def result_to_text(result): """Return text representation of bench_one() returned dict.""" if 'average' in result: - s = '{:.2f} +- {:.2f}'.format(result['average'], result['stdev']) + s = format_value(result['average'], result['stdev']) if 'n-failed' in result: s += '\n({} failed)'.format(result['n-failed']) return s From patchwork Wed Oct 21 14:58:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 270769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0719EC55179 for ; Wed, 21 Oct 2020 15:21:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7356F2177B for ; Wed, 21 Oct 2020 15:21:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="G5VdCIDb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7356F2177B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFvm-0007x2-FD for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFaa-0006dU-56; Wed, 21 Oct 2020 10:59:44 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaY-00086M-12; Wed, 21 Oct 2020 10:59:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VOecqCqmNawtcPfCgqRw0k9AFloUdvNfPbpt67TfzmbPjCSZRjpv6yl0jUqMFaNpwrMl6Ao+rE8UTwOKRjMzlYDHbFGXYcDJj3aNutMDCgH6kVwTqQnjJbt81hRZj1aX0ULhhiB1kchPmg6TigOavGnMkp87gvxsU0ttg22AoNsQE6uiY3vLTBndBkVYJWF3JNoS0iIGr1Ktku+vP2UmG66VOa9IcAxRw67X5pGrAYPJM8mTjkxIG3TW3RuwXfVd40ZWYnPha3IX7D3QislbzOfEq9FoBcqbGqALpB1mo7IKOgT/DX3DNgP6UolVge7ujFblaXqAQBugQ0NEsyqFEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T+5Hj5A0RR4K/eFpiMDFJDBnoVDR9w6FoL8CUK98Iyo=; b=KST9KF6jRcRBcsRwlOwVSVEiXh0pYBvnXRMlu31v3gcya86y4aus4+odBDObCpAKC4hpJ4VNCC+uYRJJ+QrYb1+9eHB88NtexqczUIDU9CvLAfIkYiEIJhowIlPYurhKK97V+PLrp2UgV/E/a0keIa4tfpOWQZ+AaQifMcINKD8g80KrWgPZUTAKS9cpfOM1gZ9nc4lvao5Xantj4tuc/9DyrjvOI9LClFNyhj6EhMrRjMfvIxxHKYJ9pydIOsw9FinPRCyjMqgNpZwtidHoij12IXUAO3odscVzRyBfFLRsyYpmQJbwD4o42K15tY2s8B6Q302Z/m49BL4tDu5GIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T+5Hj5A0RR4K/eFpiMDFJDBnoVDR9w6FoL8CUK98Iyo=; b=G5VdCIDbu8TKe+mMFQQyKIh5BbfB7sA/8cqw9VI6MUmB2GF23qG0+9G73ut6T0X43/2OBTwEVaxW2koRdupDAyP1z0GFN54g5o5GRmT89WmZSK+AoCoBzQ26z6ohjicEH7VGIhfVgvmOlURXqySZGp3cFsROiPo3RmMJi93cJF8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:29 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 19/21] simplebench/results_to_text: add difference line to the table Date: Wed, 21 Oct 2020 17:58:57 +0300 Message-Id: <20201021145859.11201-20-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e865053f-ba22-490d-3638-08d875d1e8df X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9m4E/gYG1AbV5NkIU0r898rF10Hsk1GRtFJsgQaGJICVnbleBfmxJzxmQNRkaBp7CVhC0nGIkPSGCQYyn6g2sNjLCfs8ElOkwSNSzLBlpU+ooqe4n6QOX2OlwpBHQKJnyap2H8UGq9E62k2DDiJ8pQ+DBlHK5bzucSvgiG3xdsWp4HyJcOFq8GXydTH+UpTKG9DwQLDJrnxsKafOJd4iX6HcSlP3tguSLTv/sY6jNh3oxD+3E7GcMFFdHZW7LlyaOr+ZHn96N41131K2BR45RPvemBFM2BEi6ENtLC82fAKvWs/PqMiB+f3h00KIsD8JLZbSxmdbu9nBiXjMYT2S+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(39850400004)(346002)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: N9P0iTJmz1Gx2ZE7e59ZfpgvStb6vHUgkw4Sjh9ag0KufNq49CB7PN/rzIb/seFHsYq2SDAhhHLtvSkH9+cP5pSVhLyISZAUWLCcFOQw9JybcJLwpME3NNxaCv0FpYBySYtPbjE58eGG0T8Cz2/8u6+5qi4WAshsX3g5SKBN/AYr76etespgE7mUl+XjNeCVx09gXVtN9tjnQhTUy3hTfVzK4UdQ4lds3cGCpMMPuwVVOBLyEFcnHh0hc50gSNOksobHwueVhPMr4s52P9PC77pBoyBLQwJRUz/pYKdpwdYzZF8rrByH4Sulneq6BCWGYfWK3D3e5KD+CkE+CJDOQqYLfSJ/VGSwBwC2IsH/XCYFd0c3Ks1cpQPqoMeYqjwlx758qGBbp94RnR3UVdt6+5S1VMBskX8FJXiM1VTOMo0GLitYBJpSwzyb7w326WOi40F78JEw1O4jdEbQgbOE7fqTZydbAkwbyuKLHAKPJDjF4W3neGbvK/U18DcV4Qox3zTq9fXyXZKNPasOaiFo8tGG65PSEXfAyk0Ega2jdL74hKkPQajNdOqYwl4M7C+R4RqkdFu6r7fGr55kX4C2r1z0X8T6wjQqRz1bDl6g/SlAJOegAYJ0LlZfGpNmzaiRSbXukIcMGDqFHr37CjNlkA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e865053f-ba22-490d-3638-08d875d1e8df X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:28.9736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oSIoafpvB/k1+H/vM+PfgpfYsF0xnYODODqgPduiahzVTWJNTE+nruMKP/Mrrcp8QUzboHyHgHO91E06wQ6giNqd0wNWLNiPP5UOD0WzbSg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Performance improvements / degradations are usually discussed in percentage. Let's make the script calculate it for us. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/results_to_text.py | 67 +++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py index 479f7ac1d4..56fdacf7ca 100644 --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -17,6 +17,10 @@ # import math +import tabulate + +# We want leading whitespace for difference row cells (see below) +tabulate.PRESERVE_WHITESPACE = True def format_value(x, stdev): @@ -39,21 +43,70 @@ def result_to_text(result): return 'FAILED' -def results_to_text(results): - """Return text representation of bench() returned dict.""" - from tabulate import tabulate - +def results_dimension(results): dim = None - tab = [[""] + [c['id'] for c in results['envs']]] for case in results['cases']: - row = [case['id']] for env in results['envs']: res = results['tab'][case['id']][env['id']] if dim is None: dim = res['dimension'] else: assert dim == res['dimension'] + + assert dim in ('iops', 'sec') + + return dim + + +def results_to_text(results): + """Return text representation of bench() returned dict.""" + n_columns = len(results['envs']) + named_columns = n_columns > 2 + dim = results_dimension(results) + tab = [] + + if named_columns: + # Environment columns are named A, B, ... + tab.append([''] + [chr(ord('A') + i) for i in range(n_columns)]) + + tab.append([''] + [c['id'] for c in results['envs']]) + + for case in results['cases']: + row = [case['id']] + case_results = results['tab'][case['id']] + for env in results['envs']: + res = case_results[env['id']] row.append(result_to_text(res)) tab.append(row) - return f'All results are in {dim}\n\n' + tabulate(tab) + # Add row of difference between columns. For each column starting from + # B we calculate difference with all previous columns. + row = ['', ''] # case name and first column + for i in range(1, n_columns): + cell = '' + env = results['envs'][i] + res = case_results[env['id']] + + if 'average' not in res: + # Failed result + row.append(cell) + continue + + for j in range(0, i): + env_j = results['envs'][j] + res_j = case_results[env_j['id']] + cell += ' ' + + if 'average' not in res_j: + # Failed result + cell += '--' + continue + + col_j = tab[0][j + 1] if named_columns else '' + diff_pr = round((res['average'] - res_j['average']) / + res_j['average'] * 100) + cell += f' {col_j}{diff_pr:+}%' + row.append(cell) + tab.append(row) + + return f'All results are in {dim}\n\n' + tabulate.tabulate(tab) From patchwork Wed Oct 21 14:58:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 689DCC388F9 for ; Wed, 21 Oct 2020 15:26:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 63A0E2225F for ; Wed, 21 Oct 2020 15:26:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VkQhXEYB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63A0E2225F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVG0M-0004vD-DX for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFab-0006hV-GU; Wed, 21 Oct 2020 10:59:45 -0400 Received: from mail-eopbgr70109.outbound.protection.outlook.com ([40.107.7.109]:36743 helo=EUR04-HE1-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 1kVFaZ-00085a-3L; Wed, 21 Oct 2020 10:59:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BhvFkJAN9Pm7RoFUFyi/hgOKc9VAm4ui4dK/6NnFAqdxvQEvwkQh70s5wmu7wNav3ZaUW6LpKjmRPZtt/ZAQafqDrKotnK9QXvvD0C8vBZO6Or3gdaMS0XArcQevg5UPHBOsMebELrIeKa+Yl1omzywqxdm24xhgQKkrEZUnoAr06epL25rimwtkg2qAtCe9KMpSVa3gHqr+jEi9IJO8IUJlgqEHS+CLvGBy/LkVFYj93A/Wd4p9FBRZS9ns2qktklRaxdAhWXx52U/YvWEwyEGx65NgXoPF10Mz86HlHmfv02F49hepaS/a4eNxC018WXLmFyp2UKsXcwvsxj0gjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mAEpXnsbhIh3NaB8t0CK+0ql2QeitwSPmPQcUKxVYwQ=; b=eegC32X9dK2wTbCDbj7CZk8fgyYV4eqq26dgo/750WMb7cEMd0pxvXr1uVFjOZKi6riWwyRYf9C/x9P5donQ04YKm+fYp1HhFLZWdLtYDQNhDgcYaLNSQFJSwHHaqSPLhxl/tpIIAXqdw8EW+Amk79HrlV0q4elbLtd9YfzOx8a0E2Ln3fYZpdPeaDy6SHlm0Sh1v3vhTvc83PpdSnnr1UsMUH3bgqEkZc48oYmlQEf9RtlOg4nwdLzA/aoF1kRaFU0ZZCcdLYHJdtgBCjMmXJMcsZU5HlGYvd+SpohpgQ75XwDWDOUEkah0Y/h1LgvU7iKx6zO06/MClFGS0tjXAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mAEpXnsbhIh3NaB8t0CK+0ql2QeitwSPmPQcUKxVYwQ=; b=VkQhXEYBmM6sSOSgLQJNpxA9bWK7VXCFYlsHLoLrlVKf/Crq/LJ3cxRHonnwj0ct+c+KxWOc1JlOEl+u+qRORx4pr3ttQ8DczrwKFikfwMFpJWk8IgqzhwmYp0vupI1SVn8HUvADJkPWdcSw0s596sSk3hqcMtt8cicf8MJ7TmA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:29 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:29 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 20/21] simplebench/results_to_text: make executable Date: Wed, 21 Oct 2020 17:58:58 +0300 Message-Id: <20201021145859.11201-21-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5618415a-4657-49b4-343c-08d875d1e959 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sPds7YOonsVdMClR0f4BwNARjMjUt4i3ICV3uN9NM6GTt6gb6aW/UY8tHPLJMtTi90xVVRrfcCV90aVWvshiyo6IERKyHRHhYMak0zMuFvj3LQUMjWZi46VgvD/wrSrGkQx5SuGGaEaaDVJrH4f7IM4h+Lg2N4b/+7MSyrVE39wjY2jvMSbSvnDf3XZt4XPAomNEqrsoTVQGNIR0oWeWIh7hKoACGzCdcJTozFCVkRo+NeKOgZZYDJjctIRHrJXs+vWju8+k+vhIKAXzc7T3SRXEr3MIs0wpNeF5ZkeJZ3gR7njIQ41g8Hu1cixpVX6Ia2l494W5nZkZU+HHTErSiw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(39850400004)(346002)(66556008)(16526019)(66476007)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: eT8kYlLS9U8wfE3FgpVggWgTPXhvys0cAUr+UzD7iZmlnR9Y+fBWv6s+AwsgoJFARzyh0OolVhw9+4T8uwU111526KP+cmY1djcMKRh73bZmAlTEW2LTzamlgB1fqud6BPGGGMCfIFlrYf4TBlEFBI/N8lUSbHQJlhyInKvoWK59qEVe76hYQWcjPNJ7YJXVm1LGHPfFtXUozX1PNfx/xYz4ext8L0WyOQQZ67xpedrhVVqOW6k/f8KtthyyHD+a81dBJH57RLl0ztSKoCg/JRWQi6+1v+EoTSNr8U/K8D7XqdbaN6ign2bIBalOrWJQf5gQxCi27AQUUVdn5VSDku0fhHtIrb8kVSUXc5sv5+aFLaw8OHlj6fpsBbC2tGEFwZAaXNa/Bd4+YU8fHOs9S5wQvFnFdYh3koRr/kFXO3bIy4rEOTORV5Cg1zcQomz9HBN1OYNLoS8Szb9nc8ji2zzwONn2O6TmkHOazMb1n6yRSkrL/AZrW7nI8WgS+5VHIerplfesGOeLcYXd3/g2ZJCTupWcRrbRn+owt8T9KFktv9hxq5eE7wtg310I9l5vu+FKTDd1dX8pJ8c+9FfEPyWorKeCROxIv5/Xt496U+gVjz0Fuiq+FM7JSI1CX1ULho64Rrle3S6PVhlmR5fmoQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5618415a-4657-49b4-343c-08d875d1e959 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:29.7871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: heWlySvqVGskde8mLA2pqd3M8BYfkfXk8CZF+DfmJpSQHI6KzUpvygEhGC1HL2UIW8FHhloTI9W+npKs8XET48xBIh0VVoMg2KM1h+jZl5I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.7.109; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Make results_to_text a tool to dump results saved in JSON file. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/results_to_text.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) mode change 100644 => 100755 scripts/simplebench/results_to_text.py diff --git a/scripts/simplebench/results_to_text.py b/scripts/simplebench/results_to_text.py old mode 100644 new mode 100755 index 56fdacf7ca..db8ea41cf2 --- a/scripts/simplebench/results_to_text.py +++ b/scripts/simplebench/results_to_text.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Simple benchmarking framework # # Copyright (c) 2019 Virtuozzo International GmbH. @@ -110,3 +112,15 @@ def results_to_text(results): tab.append(row) return f'All results are in {dim}\n\n' + tabulate.tabulate(tab) + + +if __name__ == '__main__': + import sys + import json + + if len(sys.argv) < 2: + print(f'USAGE: {sys.argv[0]} results.json') + exit(1) + + with open(sys.argv[1]) as f: + print(results_to_text(json.load(f))) From patchwork Wed Oct 21 14:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 302376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D63CC388F9 for ; Wed, 21 Oct 2020 15:28:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B352822283 for ; Wed, 21 Oct 2020 15:28:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="MtxRYpYW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B352822283 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVG1v-0006Wh-LD for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 11:27:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFac-0006iY-TN; Wed, 21 Oct 2020 10:59:46 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:60672 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 1kVFaa-00086M-PF; Wed, 21 Oct 2020 10:59:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bd40wRcFw6Bv8YMqMqRtchl5zSci39EdDgWtBtF7+t8oq2ynvxkHXg2L43CTeqF/0dUzM3fbAy4eL7iksHFcDNXEpiZeB+2KacNOQfxKEef7urhenx11cX9DYDiiPQMqyTOZBRaD/FcZpCUXMTUw4sTcSE4YB2TTpqHrLYNuvfZTRYeXm08TwM/xjbo/HbqWKPTF2c14eR71l+5QvRndAEGsknqgxvqCgbwZD7Voirk+Vyd6WcnzX9MxwHL/IwWuAQrwn4q6YiTaItmyhM7Njnsb34bb6+PCkNBuTHV4FXmmF3C8bAGcwwZhUJlUuQ+vhrDWEe6Y1tjLa+XaNIbwIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JmkbsEUCLW5Lf9RTa7rh8ZPJoXPEtNaRYYtjwkC/+WY=; b=RCRvnVw+27BlDWs/D0IgkP4cJImHl9EhRaBrIQWceOdAxPNxq3M4hA9gVzcfXCulpnDoK/ibhPc2sBsfR4p+x53obri6Hcv1dm2STzOtPAeyk+6JNAwJ3gSiEY/lSGCL0cRwYsCMRCi9zti43QQUUU9Jfxlz2MtHXQxTiBA+Fu9F0qbcPxNt/qiC7CcQDaGPGBmYxJkVPoRSUuquRUbq/+zI++JreE5ho580GUVKpmmkHfgVNyH7+ekeZhwwPK+yWzfSqBL0b5wmohAih2K2SEDzZTMA9qfvftX7i8PdS6Gc5sqqovIUPPeS+QCNt1e8QMo8rOy9/PmWWrcL7bRm8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JmkbsEUCLW5Lf9RTa7rh8ZPJoXPEtNaRYYtjwkC/+WY=; b=MtxRYpYW9yBwBY9ecpF9koOaREVLphLeK1Ekr8yH2qPWupQ0DGDci+DG0kRC/wR5kgahuMrf2rrVKMI9OuzBcW1eb03XdStNe0JEPY6W9mhtICAkG+KfssXZh/ddyp0RtNBe9o8n/IvKTMBgz7p0LXNa2sEWvL6i/fsOmIoobnA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Wed, 21 Oct 2020 14:59:30 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::fd02:1330:f620:1243%9]) with mapi id 15.20.3499.018; Wed, 21 Oct 2020 14:59:30 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, eblake@redhat.com, armbru@redhat.com, fam@euphon.net, stefanha@redhat.com, mreitz@redhat.com, kwolf@redhat.com, den@virtuozzo.com Subject: [PATCH v7 21/21] scripts/simplebench: add bench_prealloc.py Date: Wed, 21 Oct 2020 17:58:59 +0300 Message-Id: <20201021145859.11201-22-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201021145859.11201-1-vsementsov@virtuozzo.com> References: <20201021145859.11201-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.82] X-ClientProxiedBy: AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from kvm.sw.ru (185.215.60.82) by AM0PR03CA0091.eurprd03.prod.outlook.com (2603:10a6:208:69::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Wed, 21 Oct 2020 14:59:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bda071f-51e5-4f57-8679-08d875d1e9d1 X-MS-TrafficTypeDiagnostic: AM6PR08MB4472: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w+h6X7LDoK40bH7YQPs52j8xvYSbkqAJWaIlNGbRfoUD/dRxK4ORA6h85Vi5/OOCeB8jrkt4AmYqB+zu0lLQlOv6EBXO8fonNdRhHaTP9KFahr5dvYqjrohI8RjBQ9s1qPAOrJZYkyChVB8JYjgoN7U3xuN9CxW0O6XyDX9StgT0H1jHMHISKl1R0eHBsIbkWeDEAbV/iI00TDi5al6ijvE/YyYURvIja1RWu8rpzm+0SPPRk+ineYWpwjCBJvLvQejJqp1QoVQJskuRCFVCjwq+W8qAvqv9ff3Kh95qrLsQS6Z/eSb0xZ+7wUN0qNAV6A9CWh15tiHikd7B5my9qoaobhNOsFktTALbzf9uyckuG7/6UTmPh8UxDoY9RXoMw+Z3ij/UEWlfYit2F4VRkers+YIjdYV+S04BQHwSimBfy/LRiVk9Plg3acV9TtFi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(366004)(136003)(39850400004)(346002)(66556008)(16526019)(66476007)(83380400001)(6512007)(26005)(478600001)(66946007)(186003)(6506007)(6916009)(86362001)(1076003)(6486002)(8936002)(2906002)(5660300002)(52116002)(8676002)(2616005)(6666004)(316002)(956004)(107886003)(4326008)(36756003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: zYqmzD2d51ojG1IJ8NamQgdxCQBQb153FnTakyW/jt4E45NmLROWcFN4i2JaHcRqdu+IiWj9oWXEb3gdt+udXqKJ23Kjg7KPiMAxn/pHMT9PVcDY5ushHHHjRbNyuKJMMskDsWpGtZe2lx1m03lis3DrHqHCzk+a31ORg3ItBgYlfLaEKJsAA+EoOz1xGKoPduugl0JfraLx/BlTXLTy0rCrff+/ONevbdKf9mxt2nXLTcKdgDfzhGBtwK15bJYo30DX5IGtvAvSk9P3W9XiVesBIxxp/sf56iKnxjRcbNQlbpudJfCXlreqXwl7VqdvqJNvMSaRONSEI+f1sIv/5G3TRWok3of4I+SsOoILgjPEWBJcYpuEW3r4dLKcNB9CILzDvxtxhX5tu0FQC4X04kwVo2fMQt1tQIFnd3t48O/uA/IbJLPxuaXQwVnb5aI3HaerpEsgl3UAa6ClV33Gx12HGzM7dwver4/Pwnt2ldpv+j4wzUG1jxMxQBCCu7WizyOkKHJpGuu2v5wYKpuisagBttTY2cUD8UASSZNWzd4+wZs6eGneef6ux05V+Xa/Oc6CdLje1xUcfuImC1BEjQwtinkrKnY1BdeNUGaN2jwSANrlGpjvy4X2oGguN2rdvDJXYKFfnPiJmBMyo54BPA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bda071f-51e5-4f57-8679-08d875d1e9d1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2020 14:59:30.5557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a/aCsCg6BzaWPTh6LtRmZ+7lydypOpN5qimJSQ8Jnwg79hJMxcIOjtk7jHJKMWkISJXtHW9D+8miyRVg/gYE6rqYHjI8jTqimLYvv3X4JfA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 Received-SPF: pass client-ip=40.107.20.117; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:59:20 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Benchmark for new preallocate filter. Example usage: ./bench_prealloc.py ../../build/qemu-img \ ssd-ext4:/path/to/mount/point \ ssd-xfs:/path2 hdd-ext4:/path3 hdd-xfs:/path4 The benchmark shows performance improvement (or degradation) when use new preallocate filter with qcow2 image. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- scripts/simplebench/bench_prealloc.py | 132 ++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 scripts/simplebench/bench_prealloc.py diff --git a/scripts/simplebench/bench_prealloc.py b/scripts/simplebench/bench_prealloc.py new file mode 100755 index 0000000000..85f588c597 --- /dev/null +++ b/scripts/simplebench/bench_prealloc.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# +# Benchmark preallocate filter +# +# Copyright (c) 2020 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +import sys +import os +import subprocess +import re +import json + +import simplebench +from results_to_text import results_to_text + + +def qemu_img_bench(args): + p = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + + if p.returncode == 0: + try: + m = re.search(r'Run completed in (\d+.\d+) seconds.', p.stdout) + return {'seconds': float(m.group(1))} + except Exception: + return {'error': f'failed to parse qemu-img output: {p.stdout}'} + else: + return {'error': f'qemu-img failed: {p.returncode}: {p.stdout}'} + + +def bench_func(env, case): + fname = f"{case['dir']}/prealloc-test.qcow2" + try: + os.remove(fname) + except OSError: + pass + + subprocess.run([env['qemu-img-binary'], 'create', '-f', 'qcow2', fname, + '16G'], stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, check=True) + + args = [env['qemu-img-binary'], 'bench', '-c', str(case['count']), + '-d', '64', '-s', case['block-size'], '-t', 'none', '-n', '-w'] + if env['prealloc']: + args += ['--image-opts', + 'driver=qcow2,file.driver=preallocate,file.file.driver=file,' + f'file.file.filename={fname}'] + else: + args += ['-f', 'qcow2', fname] + + return qemu_img_bench(args) + + +def auto_count_bench_func(env, case): + case['count'] = 100 + while True: + res = bench_func(env, case) + if 'error' in res: + return res + + if res['seconds'] >= 1: + break + + case['count'] *= 10 + + if res['seconds'] < 5: + case['count'] = round(case['count'] * 5 / res['seconds']) + res = bench_func(env, case) + if 'error' in res: + return res + + res['iops'] = case['count'] / res['seconds'] + return res + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print(f'USAGE: {sys.argv[0]} ' + 'DISK_NAME:DIR_PATH ...') + exit(1) + + qemu_img = sys.argv[1] + + envs = [ + { + 'id': 'no-prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': False + }, + { + 'id': 'prealloc', + 'qemu-img-binary': qemu_img, + 'prealloc': True + } + ] + + aligned_cases = [] + unaligned_cases = [] + + for disk in sys.argv[2:]: + name, path = disk.split(':') + aligned_cases.append({ + 'id': f'{name}, aligned sequential 16k', + 'block-size': '16k', + 'dir': path + }) + unaligned_cases.append({ + 'id': f'{name}, unaligned sequential 64k', + 'block-size': '16k', + 'dir': path + }) + + result = simplebench.bench(auto_count_bench_func, envs, + aligned_cases + unaligned_cases, count=5) + print(results_to_text(result)) + with open('results.json', 'w') as f: + json.dump(result, f, indent=4)