From nobody Sat May 11 17:04:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1627134045; cv=pass; d=zohomail.com; s=zohoarc; b=dyHDMpQB5usMSpjNkEHoW7avP2gxxjq1J94sAVK5LTeHCCyzn8zKEo1Xt4zRR2cEDadxwSXqhYITVMljeJwvl1G9QtnYlHedSIwm068cOJMWEW9bfHcV0O1DaPbHkAdoufJqEENsjIkVFIw9bb8v8p+aX2BT85BxXPlUEdxHY+g= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627134045; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6ClUjHS+sHx6XTswdLnAwhSmeHdWPK17RmhjgXgtOu0=; b=EjlmKlDKHKjd9xh2gKrb6NACht94VtHZAevHcUnk8/U+vOOaOUll0ngs5T2kjlVLXoWwc1JLFjyo2WkILBNtlmvY1ysydqW1/r8q83+0XqlNQKjr30JQpGOkvhh8n4PqSsu18pZCULN5mUoQQIgloQPCgSZEpBlh32mtfRozdUY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627134045965392.2164920073692; Sat, 24 Jul 2021 06:40:45 -0700 (PDT) Received: from localhost ([::1]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7HtU-0005HV-Su for importer@patchew.org; Sat, 24 Jul 2021 09:40:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7Hs7-0002kg-8J; Sat, 24 Jul 2021 09:39:19 -0400 Received: from mail-vi1eur05on2132.outbound.protection.outlook.com ([40.107.21.132]:24064 helo=EUR05-VI1-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 1m7Hs5-0004Sk-CW; Sat, 24 Jul 2021 09:39:18 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6805.eurprd08.prod.outlook.com (2603:10a6:20b:396::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Sat, 24 Jul 2021 13:39:09 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%7]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 13:39:09 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Sat, 24 Jul 2021 13:39:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i5nJbXtI2G/YkdH6XcDSDk3HqMXRjcuFMlbWI3qRzLEbx0PVreLeAgI/k2O5WJpPd2VYJWwsdHmOPpkFjZ/S8okTy7A2eRgit89B0SY07gqv42SL788UXEQ3xJp2LEfd+tS0Q68nnPaT5vQF/vX5niY8FXc/irujCaBhVjy9LXBZxfpc11wCPq+tkLyRjjMgdjZBZlRZxU4ikbUcWyDRkuVIjoN+Ldrr0JoLsFYoHwX/qYyyvTso+J4ZnRiUwoKrQJ+7EndprDp6+O6YDDvkfpFvCvDjsCsrJv4yutyLXY7jPjvkYPt3v4nfsYc6u5VeoDalCqdxURqR+rfK5p8Bfw== 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=6ClUjHS+sHx6XTswdLnAwhSmeHdWPK17RmhjgXgtOu0=; b=nVMCap5xeuXsxaE1GNgAguN2BnX47LFL1sAVGaUBi1+TrieBg/3O2m26VcqWYEQLuDusvtodz0+Ga4kxLvjL2Euhz+9dVGdfKOCfx7wJHEuC2RmrxFSQnIFEYInyckKGNmSWnYXdj9QwbWm3HAn7arupMLRw4OT2NSxwe/7SJc6VZz1CN2NwvpRcXQXzLheFVlzH1QdAG3aM4FfWNXTd3LQBDBrtMtLTZBqGWQpeq0TRrNfpgjwlrMrr0hQSyWne2BolFwj4x9/lEk0sWvKrhZj0O6D++UcVNb631RH4py/gnXKFKhsZXT5DYzH20fhQvPu1dQ3YN8Tsd3ltPfw61w== 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=6ClUjHS+sHx6XTswdLnAwhSmeHdWPK17RmhjgXgtOu0=; b=Kc1yB8crU6rDZMUlbu+l4uH/svmeTjvB5M8ljPbG0LOkY+HHa9Du26LCcytdU7yeD98KSvyUImHBQOqdV/s3Ffho3XxqcwnTGjaJ/Aeh2Rct/lsCFq4NQAlpTHnL4sp5Gtrf71gU/6TRk4v8MjRcuz3TtB4A6gJeN7tUyq0lXrc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH 1/3] simplebench: add img_bench_templater.py Date: Sat, 24 Jul 2021 16:38:44 +0300 Message-Id: <20210724133846.64614-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210724133846.64614-1-vsementsov@virtuozzo.com> References: <20210724133846.64614-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3994ab50-db10-4296-b9cd-08d94ea86a46 X-MS-TrafficTypeDiagnostic: AS8PR08MB6805: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vn59ZPWzLFNcq+CLgOldSlj6rnzRQLkWeNHYaDiyN0lhF7YNFHg6g7FLMjRuC7dueGYc4kyL3sc6IA4NuI32V6SV36p8PDPMPTacptPqlQiWLvS59+wj2x5E4nhJKxfY/preFgwq2fzL/Jo7gjx0GVV+Pgs57D5fjDahUUULh3zsu9YOzzKi5vyYEhXmmK+Guej0q8Ec6/Osf3MVwFly65GQZYdmGL7MLLaBC0emqX2/EkyjNU8cUcfFxegyZJVAuqFGj2xs7SDsp86q5DgS5y5LC/sk5buQAVTAd/Sue2TTmAIYwpMIt/wiFA/UD8v6HzbwHuwDAXRimXJ95XjKY5pG6/V+3tt/77nwcgToAOn21uu/Wjl8LDCI1P4cyvLFZWxQ+1Hpk/nsZHiRjwsA3byMKio8dekMSrC97bL4BkAExcsJnvvbR8JBkFgauftjlGMDHCslfDmbKRCqVL7Y1W7XMPDcsC9Hj8CLASfbil7fcLV7TUK1eBQR9dxkpMpbjJqf8OtVgejC8nKZrqaTb0J9z3j4kQF5v1bPC1mzzeXMSQNT1VzYn5iRWonyrhSeH0DxDIIkzAj9rQfAUkb0Lmqq0Kh+s+8WSyuf3TCRhzjiIvH8u/TmkkI7VG1mR6rLggjX5joWs5c79FGLdL1X12oUchFABxcM+rxiHjqSEKbAgjBd2LGE5HSRo6tuw1ZyLyTYuHtPQKFym8BimJbx22IbSaCWlQfZ80xwidztgfzLwy6Ic9h765v5xfNcmHLx5e1YTxhZQhSqB8QWMhK2KMW3B0QcNLOxEwcJskgu1eWQpkkSylTqFBeS4doVJzxR 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)(346002)(396003)(366004)(136003)(39830400003)(376002)(478600001)(186003)(6486002)(66946007)(8676002)(6506007)(5660300002)(956004)(2616005)(66556008)(8936002)(66476007)(6666004)(36756003)(2906002)(6512007)(6916009)(26005)(86362001)(4326008)(1076003)(316002)(52116002)(107886003)(38100700002)(38350700002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jA50yCw54OE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?Q?++7D0NRF8XEIyzA8YVuS302Gn2vYaiUJF9D+S+aBaO0CAMmtVubl4ZKo+Rk1?= =?us-ascii?Q?fS4OPbZElsxuC9GZli9ZUZhChehhiCRG6NRap2p8kR6DhNwz7PZp/QoS0/hW?= =?us-ascii?Q?ubT5VFS1tjZZ/QyViG8vGuXjISGQaFC6Nt3inkvnNKA+MAWSUI5ltXdmFHxs?= =?us-ascii?Q?YFrT6TTMsHDuFnYk9RrQcAB8ou/lZoAhdKVBXjApwgIkLIhzrHdcmeLGIkbN?= =?us-ascii?Q?e1UCc4apG812sBdoo110oCv5vS1OPh9jks1lcUJAJOGXPfQ3UUZ3i49TRuCr?= =?us-ascii?Q?Mp8UCVXBhOQFPVD45Et5jwd0MzTC5k2j/IS9C5f1lJ7HoKR3prspuL7ajjqR?= =?us-ascii?Q?uWMHxdwI25as7XWDQT5/CaTcXd9ZFsDX/M2FjX7q2XiYDE/VzroPEbPWjJ26?= =?us-ascii?Q?856/AyWZ9+oCl8yJyxPiIRgj?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3994ab50-db10-4296-b9cd-08d94ea86a46 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 13:39:09.5960 (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: uUaHj8QO39BB6C8Aqd/7SEpzTnGyRtQd5Q4Z69Gsdkp5tWQdwV5mERUrhLuR1E5vhcRYJ6TDPk8jGboJMAg601BZFfc/YDeVMp1IEEYhWfA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6805 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.21.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1627134048161100003 Content-Type: text/plain; charset="utf-8" Add simple grammar-parsing template benchmark. Signed-off-by: Vladimir Sementsov-Ogievskiy --- scripts/simplebench/img_bench_templater.py | 85 ++++++++++++++++++++++ scripts/simplebench/table_templater.py | 62 ++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100755 scripts/simplebench/img_bench_templater.py create mode 100644 scripts/simplebench/table_templater.py diff --git a/scripts/simplebench/img_bench_templater.py b/scripts/simpleben= ch/img_bench_templater.py new file mode 100755 index 0000000000..d18a243d35 --- /dev/null +++ b/scripts/simplebench/img_bench_templater.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# +# Run img-bench template tests +# +# Copyright (c) 2021 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 subprocess +import re +import json + +import simplebench +from results_to_text import results_to_text +from table_templater import Templater + + +def bench_func(env, case): + test =3D templater.gen(env['data'], case['data']) + + p =3D subprocess.run(test, shell=3DTrue, stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, universal_newlines=3DTr= ue) + + if p.returncode =3D=3D 0: + try: + m =3D re.search(r'Run completed in (\d+.\d+) seconds.', p.stdo= ut) + 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}'} + + +if __name__ =3D=3D '__main__': + if len(sys.argv) > 1: + print(""" +Usage: no arguments. Just pass template test to stdin. Template test is +a bash script, last command should be qemu-img bench (it's output is parsed +to get a result). For templating use the following synax: + + column templating: {var1|var2|...} - test will use different values in + different columns. You may use several {} constructions in the test, in = this + case product of all choice-sets will be used. + + row templating: [var1|var2|...] - similar thing to define rows (test-cas= es) + +Test tempalate example: + +Assume you want to compare two qemu-img binaries, called qemu-img-old and +qemu-img-new in your build directory in two test-cases with 4K writes and = 64K +writes. Test may look like this: + +qemu_img=3D/path/to/qemu/build/qemu-img-{old|new} +$qemu_img create -f qcow2 /ssd/x.qcow2 1G +$qemu_img bench -c 100 -d 8 [-s 4K|-s 64K] -w -t none -n /ssd/x.qcow2 + +If pass it to stdin of img_bench_templater.py, the resulting comparison ta= ble +will contain two columns (for two binaries) and two rows (for two test-cas= es). +""") + sys.exit() + + templater =3D Templater(sys.stdin.read()) + + envs =3D [{'id': ' / '.join(x), 'data': x} for x in templater.columns] + cases =3D [{'id': ' / '.join(x), 'data': x} for x in templater.rows] + + result =3D simplebench.bench(bench_func, envs, cases, count=3D5, + initial_run=3DFalse) + print(results_to_text(result)) + with open('results.json', 'w') as f: + json.dump(result, f, indent=3D4) diff --git a/scripts/simplebench/table_templater.py b/scripts/simplebench/t= able_templater.py new file mode 100644 index 0000000000..950f3b3024 --- /dev/null +++ b/scripts/simplebench/table_templater.py @@ -0,0 +1,62 @@ +# Parser for test templates +# +# Copyright (c) 2021 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 itertools +from lark import Lark + +grammar =3D """ +start: ( text | column_switch | row_switch )+ + +column_switch: "{" text ["|" text]+ "}" +row_switch: "[" text ["|" text]+ "]" +text: /[^|{}\[\]]+/ +""" + +parser =3D Lark(grammar) + +class Templater: + def __init__(self, template): + self.tree =3D parser.parse(template) + + c_switches =3D [] + r_switches =3D [] + for x in self.tree.children: + if x.data =3D=3D 'column_switch': + c_switches.append([el.children[0].value for el in x.childr= en]) + elif x.data =3D=3D 'row_switch': + r_switches.append([el.children[0].value for el in x.childr= en]) + + self.columns =3D list(itertools.product(*c_switches)) + self.rows =3D list(itertools.product(*r_switches)) + + def gen(self, column, row): + i =3D 0 + j =3D 0 + result =3D [] + + for x in self.tree.children: + if x.data =3D=3D 'text': + result.append(x.children[0].value) + elif x.data =3D=3D 'column_switch': + result.append(column[i]) + i +=3D 1 + elif x.data =3D=3D 'row_switch': + result.append(row[j]) + j +=3D 1 + + return ''.join(result) --=20 2.29.2 From nobody Sat May 11 17:04:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1627134040; cv=pass; d=zohomail.com; s=zohoarc; b=K+d+tI6E/5QsY+DqmfCCUQp/4LZN95sFC9NQOS+H+l8/iy/kUZkuMjU4uKGCJ5xYfiCnLPcfBKIjWYwBmb+cuNOMbcoBJcPXrl1gR1qiHiykaQdc4OHl82Yy4UBHwgse/rPYogGg9kKnDeuZ2LtStmaqltSQNeMtmQ/HBlpej0I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627134040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NLfPQBKuH9Xo7JBqruNxjx5/w8IgHlV0UgJwgxYXYcQ=; b=msI1p9Q3J1KlQu8ttrNG/Uc/qJS6ROb8ZKtD4h5923NLN9/6hnF+zwDR6prhbs/jhpXIqARzl2kSEwwpJj4BHHTzpgT5vDr0J7DRcDx1PmQxwG/qxOoLci7+FcCvFxdScfsaJpbZDKfbbNUi4lryI5nclnpJNw3T1ThsRuB2/44= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627134040069962.3566780670566; Sat, 24 Jul 2021 06:40:40 -0700 (PDT) Received: from localhost ([::1]:49386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7HtO-00050P-RD for importer@patchew.org; Sat, 24 Jul 2021 09:40:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7Hs9-0002r2-GE; Sat, 24 Jul 2021 09:39:21 -0400 Received: from mail-vi1eur05on2132.outbound.protection.outlook.com ([40.107.21.132]:24064 helo=EUR05-VI1-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 1m7Hs7-0004Sk-UW; Sat, 24 Jul 2021 09:39:21 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6805.eurprd08.prod.outlook.com (2603:10a6:20b:396::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Sat, 24 Jul 2021 13:39:10 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%7]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 13:39:10 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Sat, 24 Jul 2021 13:39:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L4g09TgkishxazuA4FOK52F8J8dczXf++GoYjtKzeRR4UD2lE2VivglvZWFIuFubZBDyvWX6TFZJgEMS5W6+r5ctiTRQmbO14l4PvWY/fdI9efNvlvmmI9EzYP0PKvr9jnyC9tsUI1LKSfPN3Ehh9n7oJt0KtBA5F01Uxh0hTt3GL6on0JS93X7lnni797rCRXThYtn9mOZ//nQ8VxeBPwIgyE2L++K3iTMwbkxM8uDgUE00hc8XgSpNYsknwNh7g5bE3S5s/GSgGuYDzNRVxrvIZXLFj2P19+x437sOiBdf/NYpKKTK0L6jXvEmuq494LwrnIq4HP2yFKrANRKuAQ== 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=NLfPQBKuH9Xo7JBqruNxjx5/w8IgHlV0UgJwgxYXYcQ=; b=TPists4SdUcH91gfXEqsvbjiB2qQC+BHQDvexoTltX1SrvxvUGKrwQON5pwFCEemPkxTrhMeYtOH6WmLI0ZyzMD95gBV/5p/8+1CqveV+zf8pXkFp3A+cd70CKN6uAFoE1zGs46CJFpW5oXNIKFkO+9gJiwOrsMvD7fEycwFILbVW584FIK3OFe9TWSkxjeLx9r2KrYTQ/PLfrMSnOa2+wRxgrSW3aJ7FhxDhhBbJpkf4MzhqHTkNd0PR7oDL6yOBXSmTig1+eoTgKqxeBqbPa/GFDu53odgqP4ti8uuzrHZQCEwVsdFVvOZ3xl7k+Was0KMBsTIItuceDMrRfEzGA== 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=NLfPQBKuH9Xo7JBqruNxjx5/w8IgHlV0UgJwgxYXYcQ=; b=PFROV87KjniN3k2ruWFoyP0bffE+/GPEV4k17pUfa+eWjaYVUuvOYGaCCEgzkcuKpgRE6nato8QTwKwZAzTWGtdCHaLWI0Ad595v1RfsWs7YA/FZphWgXnMdstP15eEfJOdF9AsD5sZztJuEgzkO1UJqDDVetrrt7GPXhhY+hq8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH 2/3] qcow2: refactor handle_dependencies() loop body Date: Sat, 24 Jul 2021 16:38:45 +0300 Message-Id: <20210724133846.64614-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210724133846.64614-1-vsementsov@virtuozzo.com> References: <20210724133846.64614-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79262717-9c88-46ee-9bb4-08d94ea86adb X-MS-TrafficTypeDiagnostic: AS8PR08MB6805: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:134; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ZXqNeDkB0k9sc4UnP1BDzQ+fKubo3vgFFa5XdRdgrQ9TwOWySMWO20nkpF476COtDtqib39kmBhEEiBrDMT5hCwbveQ45TVqgh5s4pdFqTXjygkyaRzftlsXjFr+9xHHYeSqMYRXOaxnPAdg+5HiAbGbzECFoX8fIhEo3F1mJ691GiqIZW9dRGpKqY0MshULYu33EA6uhJv0oD+GxoMT1vtc8crT9TXBXeX9/R6apPFBBJNJrrG2WSkS9aWtzMpanegS+YA/RtGafBp/VwrObbmKr9ddx5xhNu9bbhWcFYwnQ2hRNmh3ma5Q6GKRDpE1ZY5Ie/Ugti/9u4ERWNht4o7qAb6s2+d4x9GYc42wJb2RjxCnRGJL1HxDV3lBVZxfyqILPPlXoJK2371yfwNE1BS+ZS9GiuUca0HsSqV9bSdWmmqIQGZ4nwv9ULBB0GfBSY2Jtw+KPi/Aw+1N+A3uqOxBBVQMpRPrCeIi31BjmJspzrEIEGMnn8KoQdNJWShvbgX+Bjr9p7tZGGrAAiJlETz7XWvc5cK/Se70BFjIkO+xQHTpgWeNdTdkzHhM57zm7gVljnWo8Y35VXzXhQihlGkb7TZqo9DGNsMEeRbwkaise+FCOTIq/cWvj/7l+0HX///EC+3sdVRV+EsDlIhHDi7PciHN9N+8c1Nud6ngWS3vlMgIT+hoo6dIRXTheJDfokgD0iV/ay/xNHH2ROqCA== 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)(346002)(396003)(366004)(136003)(39830400003)(376002)(478600001)(186003)(6486002)(66946007)(8676002)(6506007)(5660300002)(956004)(2616005)(66556008)(8936002)(66476007)(6666004)(36756003)(2906002)(6512007)(6916009)(26005)(86362001)(4326008)(1076003)(316002)(52116002)(107886003)(83380400001)(38100700002)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?17Zlsz5OA4gkftBLAnEmLqrVoZvAvZ6m3AtfyVR/3Ig84v8TA+tEJ3EiMr94?= =?us-ascii?Q?FowFD2SeJoKWe2tCA0bbd+RiQzFNnTnQe0IxwJ9pZ74nl7xqKY7xCOibzXmU?= =?us-ascii?Q?xXiHevIx8dd9K0OISdmtDbXBinMRkZSvrUfzOZ35uV7bTLNlUS/rB0Uoo8S9?= =?us-ascii?Q?nR5ypoJOChCc7sDF/SgK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fv43c?= =?us-ascii?Q?PyXN25OvGu7+/fp+Vfpz2UeksdZ/yYb749eA2KUiABemI6u75gwCVgWw5x/Z?= =?us-ascii?Q?LizzI9SbHH/C5Y2JVnGYsFZNngpLntfUGyk0K0RoCxcOzzSts10qP7yT+2bn?= =?us-ascii?Q?bUzVz5xY4yawln+MahI0c0u5jymCSQRpxLJfdXv5fo9NUPNcnVdsDbWKJlHf?= =?us-ascii?Q?yLVWhgqalMResuBvFU7g5J8S78esS4Ld2abVoWMSBEyKjLWrWA3bHPyombRS?= =?us-ascii?Q?yTCdLJnBy+b/4s35xUoZalyA?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79262717-9c88-46ee-9bb4-08d94ea86adb X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 13:39:10.5129 (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: CQo1g9/RlBvY+XkIB7SKmBPQUYQT/rONUm6PXXc55bPlnXzNPaZ2d4Ftj8GqbfN7FT9OwS0G0vOarSfQzlvEczSV+wt6XkO5SLuju44luLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6805 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.21.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1627134041928100001 Content-Type: text/plain; charset="utf-8" No logic change, just prepare for the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: Hanna Reitz --- block/qcow2-cluster.c | 49 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bd0597842f..967121c7e6 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1400,29 +1400,36 @@ static int handle_dependencies(BlockDriverState *bs= , uint64_t guest_offset, =20 if (end <=3D old_start || start >=3D old_end) { /* No intersection */ - } else { - if (start < old_start) { - /* Stop at the start of a running allocation */ - bytes =3D old_start - start; - } else { - bytes =3D 0; - } + continue; + } =20 - /* Stop if already an l2meta exists. After yielding, it wouldn= 't - * be valid any more, so we'd have to clean up the old L2Metas - * and deal with requests depending on them before starting to - * gather new ones. Not worth the trouble. */ - if (bytes =3D=3D 0 && *m) { - *cur_bytes =3D 0; - return 0; - } + /* Conflict */ =20 - if (bytes =3D=3D 0) { - /* Wait for the dependency to complete. We need to recheck - * the free/allocated clusters when we continue. */ - qemu_co_queue_wait(&old_alloc->dependent_requests, &s->loc= k); - return -EAGAIN; - } + if (start < old_start) { + /* Stop at the start of a running allocation */ + bytes =3D old_start - start; + } else { + bytes =3D 0; + } + + /* + * Stop if already an l2meta exists. After yielding, it wouldn't + * be valid any more, so we'd have to clean up the old L2Metas + * and deal with requests depending on them before starting to + * gather new ones. Not worth the trouble. + */ + if (bytes =3D=3D 0 && *m) { + *cur_bytes =3D 0; + return 0; + } + + if (bytes =3D=3D 0) { + /* + * Wait for the dependency to complete. We need to recheck + * the free/allocated clusters when we continue. + */ + qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock); + return -EAGAIN; } } =20 --=20 2.29.2 From nobody Sat May 11 17:04:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1627134219; cv=pass; d=zohomail.com; s=zohoarc; b=YHqV50gPdgxizVU6AW/TZzvpYmiWjoo260XMw8R008kmaJKIbC1UfmwtfOEmJb0d3InS907bl22y9Grj3boIl3RuMRYDfpcpm1Be3DTv6kIZM6RnpxDVCilkVPPouJurQwTBG1MZHkk0azyTSeDhN7nCV5UbImZUg5K9FjoW4Ac= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627134219; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gx7tSFNU37zRBwGzH6FG7HBMSlhLhlT4vMImllsBWNE=; b=Fzjq8q0e34nR5ZfgV300HsHtR7oOevBmq7CCoXqWwznw2EBl4zlGqAMmKiMXjLXHwvb3efsrb9Bedi4dGjYMBaNRFSsbC2Ur0AhNCP4cmnBhUZtrXYBtuEfT+TQZhqOImxUQGyVc0waqG5xyaHbTOe1v+ZIxNYvN1+XVZ/TDyks= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627134219017605.355978072664; Sat, 24 Jul 2021 06:43:39 -0700 (PDT) Received: from localhost ([::1]:56512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7HwH-0001Qb-Hr for importer@patchew.org; Sat, 24 Jul 2021 09:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7HsC-000301-0j; Sat, 24 Jul 2021 09:39:24 -0400 Received: from mail-vi1eur05on2132.outbound.protection.outlook.com ([40.107.21.132]:24064 helo=EUR05-VI1-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 1m7HsA-0004Sk-7P; Sat, 24 Jul 2021 09:39:23 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6805.eurprd08.prod.outlook.com (2603:10a6:20b:396::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Sat, 24 Jul 2021 13:39:11 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%7]) with mapi id 15.20.4352.029; Sat, 24 Jul 2021 13:39:11 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Sat, 24 Jul 2021 13:39:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GAouD5uZmZcuLEY1KM/BivkbPLSU2E2azBrBExMJxICYE6CKQ+itNPzQcps6YBc768oukEEXp+ZWDUXlrXg9NPrBrJRFOVarj8cXj1IiBBMqHPb/TjA05ULHAthwe2Um3n7jHNtmetCxW2L3jH1yNrgkZ4dp1QC5uxXnFH1Jg7VZDwi+6qGdflxP2/ZH+lZikz4BcZoQBH9BE2sjJblxMaJddqDTNJVRAPwLrBABVmKdh0nWk4tr9SDy/VIzpci7dpy1Z6OemifxYkt9uiWwH8Sfqjv7hAWbxeX611iA++DQn7euw6BDY3mrVxHR10yUitorO1ccmjPlz4VIODbsKw== 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=Gx7tSFNU37zRBwGzH6FG7HBMSlhLhlT4vMImllsBWNE=; b=ilq68ZqTbHZ7Ib3BImsl+88rhsVGO3FreBxOANyglcACtr/liu26MEXqedoJWbzNPK4/qjaApuAa5mwu6/Y3DXb4Y7nXHZQMRCsEeX+ndhc9+Cc4RvjykqncqcHqhRUbKMFyvkJ46xRdjLNmhThUUhmrXSq4CoHc8UWspSxRVPwhBWR6mGq+BqcAh87fx5NjzsRi+u4h0VADVcjT71X+sXhZlZCeJ66zbhBfAIDywsEZWxsnjE/RqRcxGtXSpzh2e6tSQFEr+/AAT0NNWSFzbN4xdpyJnIuFNUgPQM107KIP4hnXd3mGTFwGDCI3Jm/J7DgiPbM7+WpHBWrHDtEUBg== 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=Gx7tSFNU37zRBwGzH6FG7HBMSlhLhlT4vMImllsBWNE=; b=rsEcS4nJvX11IRNWVNO6sufHhH9VW261HKDZgrLSDHkxegmvD++jMpc30DzZ4Bys5e+0J5odQ1J1oo2COm6rhyC9xbMREQdHBSxoigZdBzMFOgBMyFMNHJahM1ilRpkBZx0Y6k5pKAiRXtg0XcywGcNI940woEcWLXy7ZIHsekM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org Subject: [PATCH 3/3] qcow2: handle_dependencies(): relax conflict detection Date: Sat, 24 Jul 2021 16:38:46 +0300 Message-Id: <20210724133846.64614-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210724133846.64614-1-vsementsov@virtuozzo.com> References: <20210724133846.64614-1-vsementsov@virtuozzo.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0200.eurprd05.prod.outlook.com (2603:10a6:3:f9::24) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42b7a679-6617-4b04-eecb-08d94ea86b6b X-MS-TrafficTypeDiagnostic: AS8PR08MB6805: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4w47YNTrM/ijM3R9fgXFST9IcYmaZiEFSG/jY6oUVlEVHf/zam01UT4KbY9QbzKNkoGoWltTDZgX8YwtKAYbrg4WpRk8wU/W0y2thc0a3sLJQgm0W9QHaSM5ws08+VKQRBhjq1XwnTXqH0cpliTHkG+7x+9yARja+arkqRpN/vq+DnIzdmMPVP/AL5Gw8IVcSdmZkPG2ZdIIbXujOu2haUasOdDvKY3aLPY/f72MHPzNnPVet3LI3/oyHgrZvlq/7W8eVTgNSSlM2K3kryPR/pe3hhywf5PdTm2w21Jq8IIuXY6TOKOqWvNRLY+uWDMHHVzbh0XH5tq7PJucrJoflGZfiSoE9Ki6YYsWocvGHgWiSIo/ZvySKvSERcjGjoBPPGyHY+FCyfozD6baJTETdKW69Chxo4KM+wsgyOEa18/UbFN94nejppw+QFI4XCC4lxhsZV4pwYmMrXhM3IuJWmf1ZaOXllqLm8NhXCofm8q1tK0ah48NbJ5wUH7Q9ThXM2S3JAtmQhy4Fct0uyQJwVSTtHOgSEOH4JUJcOo4BY+XHbI4SUziMimSmp8zylEVYrfnRt00KBZXr9sLPiGeXsaLY2sQpM2e+RJ1mw5Rh2dFwyZsO1EU6OVF7SFJ3KuUlmjYOvgOYoeuPRTcrd+rjfxeh0/8ve/GUvTPlfRnrMqSscydtYx/CxhmrEO9x0prWHL45TozrkW6n1gCGC9liJFusJFa00zrWxSwOMsHd9o= 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)(346002)(396003)(366004)(136003)(39830400003)(376002)(478600001)(186003)(6486002)(66946007)(8676002)(6506007)(5660300002)(956004)(2616005)(66556008)(8936002)(66476007)(6666004)(36756003)(2906002)(6512007)(6916009)(26005)(86362001)(4326008)(1076003)(316002)(52116002)(107886003)(83380400001)(38100700002)(38350700002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V25LV2hqd1htakhwNUFHeDVJYVpHZHJ0cHZ2aGViemhUaE9TQkIwdXhPOGNk?= =?utf-8?B?VnhaOE1XSzhmbGREY210K1J0U05PcTdPQVNkOWFEbDloS25aVUZCcVZURjd3?= =?utf-8?B?T21Xa2IrTzlTdUF0b3Qremhwemppa3ZHK0VRVW03YThMd3dHMXp5alY5Qjc0?= =?utf-8?B?UEFLQTNualZqMnk3ZTM2U3hObHhyVzhqYk5uTlZjVHN3MldnM3AyMDNtN2F3?= =?utf-8?B?eE0veDZ6TDgrM3NPcXBHdzlXM2xGOWxoVmhNSDVRV2JMczNXTnpscU9VcjJB?= =?utf-8?B?UGRlYVF1cFhkdXZxUVFQTU5BSzhpeUQ5dVpERCtUMnJud254VWR6aUJvSVNO?= =?utf-8?B?WGpyYWdjL3Q5TEVTSm1nSmlLODhsdTdhTHkzcm5tS3YxUFBWaHJxcWRGN0Nx?= =?utf-8?B?OUpmQ1B4UGJaekZUdlpUY21hd1F6dDIxMTZKT3JPSUcrN3dUT000NmFFb2VB?= =?utf-8?B?ZWw4V0lnYzlqSWtDdUMrRzJuU05zOGNJaW91a1VLTnI1cTBSTlA1QStGOXJE?= =?utf-8?B?cGx0NVRGS2RkRVBMZnd1SU9oMFlmbmJ0TU45a0NYbmoxK1d3YkZneS9CL3Vr?= =?utf-8?B?MXVYRUV2d0hsbGhCWlkzc2F6SFhRNGVmY3BDQXRKNTJ1SzhJL2x1WnZRTUNn?= =?utf-8?B?NFcvaFNWd3hVam9EWStObHI4WjVONnBROWErS29TeXlFOVB3aXNqNlRkelFP?= =?utf-8?B?T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= =?utf-8?B?QXNaRmZCZWwzYUFkM054cTFBbEFrdnN3L1hDZ3FlTnR0TkJXTVoyVVo0UEFO?= =?utf-8?B?WHRiSS9lTTE5dDVZZFZtZDBsano5MWtMMGNYcVFuYjhFQ3UzTVU4aFBDcWI1?= =?utf-8?Q?+vVpmdaYBJtSXFQGxdh2+XhiiJEi64wgVONptcz?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42b7a679-6617-4b04-eecb-08d94ea86b6b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2021 13:39:11.4657 (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: QsP1ekJatmAk3HvFVSuqhyib8E1ghDQ90mKtxz0r/RRyLq5dW1PT73cZSgt8UvO/GLXDwMx30GpU3u5QLp/5+sw1DyoQggommOMDFS6XgpE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6805 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.21.132; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1627134220669100001 There is no conflict and no dependency if we have parallel writes to different subclusters of one cluster when cluster itself is already allocated. So, relax extra dependency. Measure performance: First, prepare build/qemu-img-old and build/qemu-img-new images. cd scripts/simplebench ./img_bench_templater.py Paste the following to stdin of running script: qemu_img=3D../../build/qemu-img-{old|new} $qemu_img create -f qcow2 -o extended_l2=3Don /ssd/x.qcow2 1G $qemu_img bench -c 100000 -d 8 [-s 2K|-s 2K -o 512|-s $((1024*2+512))] \ -w -t none -n /ssd/x.qcow2 The result: All results are in seconds Reviewed-by: Eric Blake ------------------ --------- --------- old new -s 2K 6.7 =C2=B1 15% 6.2 =C2=B1 12% -7% -s 2K -o 512 13 =C2=B1 3% 11 =C2=B1 5% -16% -s $((1024*2+512)) 9.5 =C2=B1 4% 8.4 -12% ------------------ --------- --------- So small writes are more independent now and that helps to keep deeper io queue which improves performance. 271 iotest output becomes racy for three allocation in one cluster. Second and third writes may finish in different order. Second and third requests don't depend on each other any more. Still they both depend on first request anyway. Keep only one for consistent output. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-cluster.c | 11 +++++++++++ tests/qemu-iotests/271 | 4 +--- tests/qemu-iotests/271.out | 2 -- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 967121c7e6..8f56de5516 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1403,6 +1403,17 @@ static int handle_dependencies(BlockDriverState *bs,= uint64_t guest_offset, continue; } =20 + if (old_alloc->keep_old_clusters && + (end <=3D l2meta_cow_start(old_alloc) || + start >=3D l2meta_cow_end(old_alloc))) + { + /* + * Clusters intersect but COW areas don't. And cluster itself = is + * already allocated. So, there is no actual conflict. + */ + continue; + } + /* Conflict */ =20 if (start < old_start) { diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271 index 599b849cc6..939e88ee88 100755 --- a/tests/qemu-iotests/271 +++ b/tests/qemu-iotests/271 @@ -866,7 +866,7 @@ echo =20 _concurrent_io() { -# Allocate three subclusters in the same cluster. +# Allocate two subclusters in the same cluster. # This works because handle_dependencies() checks whether the requests # allocate the same cluster, even if the COW regions don't overlap (in # this case they don't). @@ -876,7 +876,6 @@ break write_aio A aio_write -P 10 30k 2k wait_break A aio_write -P 11 20k 2k -aio_write -P 12 40k 2k resume A aio_flush EOF @@ -888,7 +887,6 @@ cat <