From nobody Wed Nov 27 00:48:40 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=1703758565; cv=pass; d=zohomail.com; s=zohoarc; b=j0h3EL++84chDMSvLiR/e+DtYidVAO/1tdQ4RdVNkbn4yseIR70mbnIysl+WaySBTQCjsEeXa/1gH99/5CUJkrtFNT4Rn99C27adbTu45oV/AD9MceV2XhtO98/9ZGZ9wXENHKdQuhB28foDMZmBOv+e3euF2eGedaH5sjApNo8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703758565; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RtRIfsa8yMATIzeAlVqe/ZKQZpRciBlgyBwsHIDo9M8=; b=PUWl+rsmwtZUTA6RMkO8ZhjCV4UibAMseiHX7+Ba6Z/FPS+kQ3IMeudoYa+hRqilOCldoEEot6VMZA7RR8mhwMtVqLZO1lrYl8DrdYKpGKknKaTaGjH/W6dr9a79emrf27GrY7K1O14ADdgsqaWtL6/Z1jMOAUO46SYvrcwrZqk= 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 1703758565908330.34075698294976; Thu, 28 Dec 2023 02:16:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rInOL-0005bk-LE; Thu, 28 Dec 2023 05:13:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rInO0-0005PU-Q1; Thu, 28 Dec 2023 05:13:11 -0500 Received: from mail-he1eur04on0713.outbound.protection.outlook.com ([2a01:111:f400:fe0d::713] 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 1rInNy-0000at-0e; Thu, 28 Dec 2023 05:13:08 -0500 Received: from VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) by PA4PR08MB7459.eurprd08.prod.outlook.com (2603:10a6:102:2a6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.19; Thu, 28 Dec 2023 10:12:47 +0000 Received: from VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::60f7:3267:9f9d:cdc0]) by VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::60f7:3267:9f9d:cdc0%5]) with mapi id 15.20.7135.019; Thu, 28 Dec 2023 10:12:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dSY+su3h1gGxZAL8v0y7yWWGEnBKYrDM/yJB8dWqofumiywU/rB3IyorbuoX2odV/bwcCsoL7BIi8d3VyBy+tG2hdlR2BIVdn0Jj3hamcyye2HuCVUVimD+6TFPTrmLjLwD4jzJZmQcTyaSmoa/F9IWmnIxmkiWTvTzftUras5JGrNWNQdij1+MUXnMlGwdkJTiP5za3tb/WWMuUadaOplTuK8N64ugDI19P8au/7iEyQ0cShnP2ZEbFbuosy4F3PfHn3kVN+xsrD3D874XMobZ120OGoQQcbWUtY6zPrSkrgxi3DeL457C8KXFBeiScKl8TLwhhbri2PSPPZLxO3Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RtRIfsa8yMATIzeAlVqe/ZKQZpRciBlgyBwsHIDo9M8=; b=aZ589PtSVB0i4Ojut8fG1Ewlb1ITBtNHyzax8BraLM7AVjwhDlExf72HXlj6mVvoie84FzNXMoTYabKSG21xXkdmi6/dFuMfazv+866hg4wF5Bz639fr/v1ol6NzhfACYnM6EBKHZHu2lonek9rXq7fd5LR2a8zweAZEj9bbKNcOzsJmwk6vgJlBVbE6vNrtpi26qNmg0hS2cGpUFJcIfu/juboebsaqdG3di95N8s3xn89rTu7/SOJr+0APmODird5BluAWBYpCbgiDS+AkVj/Vfx42+chZsjf2lXPM7lLatBzgby4J1ytmpQpdcmY1si+0taACnvEomHxIzWSLaA== 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=RtRIfsa8yMATIzeAlVqe/ZKQZpRciBlgyBwsHIDo9M8=; b=Ne/p3muW/014MtMsFBxe7guUHTIfuI9QWSsLwwwuAMdDwBDSSsQVMsWUOTW6/uCQZlJdsEHWiMACq3R/J5C5uUlCXDMXJxNEC6wrZmZsjsyHeGNc02ZxvP5DklgG5lb/HY0qIIhuNGvS3KlGmr+iR0Uu+2dsAcHBpfI8qGHeRhe5j4/4/vRNYg6xSlwMPygAgIPUzdYuZibaW2Z9RBqE7Tgt/8xKoSfXfpGe5pWPe/w+87ibsqbPVMh9x5rrtl8MgnZV9F2gIDwDykDOpUqy7A30Kx6PUG5ASaT2whvUI/e72gvaxbv2TGnoNA6GbKrN/dK2Zqt/dpL+8z25LEoRdA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; From: Alexander Ivanov To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, den@virtuozzo.com, stefanha@redhat.com, vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com Subject: [PATCH v4 13/21] parallels: Handle L1 entries equal to one Date: Thu, 28 Dec 2023 11:12:24 +0100 Message-Id: <20231228101232.372142-14-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231228101232.372142-1-alexander.ivanov@virtuozzo.com> References: <20231228101232.372142-1-alexander.ivanov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: FR4P281CA0044.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:c7::8) To VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI0PR08MB10743:EE_|PA4PR08MB7459:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d13bb3a-568f-41ff-6776-08dc078d8a57 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kJLlbQ5iV96JvScIl27YtAT3o3oNTwAWTV2MqWBKeDKs1PQ2FfHjybZKnT3JVKkAOPPLWs5VT4o8l/TCbTDlI3VqRkBarPXGibdtRN67tN7WAYG83yygQCi6CYY10pPaCNGygdMB3g894HPNFMCDCrZdKsdPzeMXA7I45acknwRqPjKW92WWSfcXkz6uTnopPv8mRbNZFhrRUecFpVNB/GYOMl0MloKYhxqBtDOXMKsU2y3LIRJF4zHAY6jNJWbKf30/wX5947a8YMNzfStIDRJyDFeOVRJ+Sco+Ux8hmoZlI22UupLZXBFFyvdQ7MxkDOw6gCs4Tls2idlfnOnCS57lNj1grLIySY4hDqH8XqqC05mdlP8fYTQtxFAoCRQvIg5YPEkhdVpbuhCdKHX1YNYnAiaVUsCmVDM543hq/DLLR1MtppDz9Kfj5VfQ3EGxzGr5Ie444fHB4+NaLDYmUCxJwtLpz57FIRcnBMKNBcfsrCq4VS5xdGMF/7B+/GTjNq4WkGzcrACMJWEoisNJ6WnzBbb0RZLJvt1+CkQuhV+smKkme4V51dB/wx2QO72bI7Fr25m3C5Xxuh6rYLxFYWZq8oZachwtJJLd3uWhpfcgc96Z61W9uVhfirKqP5fC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI0PR08MB10743.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(136003)(396003)(346002)(39850400004)(366004)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(2616005)(26005)(1076003)(6666004)(6512007)(52116002)(6506007)(83380400001)(6916009)(478600001)(4326008)(8936002)(8676002)(5660300002)(44832011)(6486002)(66556008)(66476007)(66946007)(316002)(38100700002)(86362001)(41300700001)(38350700005)(36756003)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ba4usCD01bYoOYkzFvPVt1YDP5YRTinkcXipb/VYqgk826uGxOfhSMgHC3iO?= =?us-ascii?Q?Bhc85X46QXQuvh1Chy7JsPYeb+E1E/zrRl1rwNPmnmlF+YiGaRBOsm5HENTI?= =?us-ascii?Q?B2rtPjBx8dbKc8FD7xJIXSm4IBoRYeDWaNsdgQAKfJXcqFMLQwX0Udjnh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GltmHgb8YbX5pdyhMPlnD6hz6QpnukQDHj2?= =?us-ascii?Q?8qUpZaHhSDKIwJ0Nl+qjxqwQGvcTqM6KmIiQVx2aX8a4geiFN9GSXrYYtVZC?= =?us-ascii?Q?rtvRp+d9VKsqqiEYuylvEgr8hJfg/+Ub+EI5F3Y6o2fjOdLLOvd4GliLnhZ+?= =?us-ascii?Q?Zeqa5sWJ+ESi5BWSsnFayKc/rKdIDNFutrr/PrhBAMFqKJXuIDGUn1RpLSJM?= =?us-ascii?Q?ZbeUu8rhD8F+PJc8P0hxTsPhgiE4THxogwhNrERrqXAgDentxDeKAFYcdEdp?= =?us-ascii?Q?0S7ipXTtYIQrswsgYJKvgwEpU2G7J4HN3wwzTVPGDPm12I7y4QdcS5A11Lnv?= =?us-ascii?Q?F2uqLZyoAPR0kS8Lq3w70j6gxsDFtX1cIwoDIhtVoNwfCxOiuFlqXadupvm8?= =?us-ascii?Q?aUf8rcR3SnEfRBr0fLArYYoc1028A9n+7dcg2d8AoQ3ODOHNd/2KrowTavsy?= =?us-ascii?Q?uJ6edZmEqwnwz7yj3euHQ6vAPYOGOS8KR2Xe2OMRnosPI3o8jO2mpHvls0yL?= =?us-ascii?Q?dNxacAcyeYg8Ceb+ZXtDlD5XYwjCmromZlYy9+Cq2M0IVsWLSJD6e4f3MwwI?= =?us-ascii?Q?vduxE6BKrlDzII/La8JJXgo=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d13bb3a-568f-41ff-6776-08dc078d8a57 X-MS-Exchange-CrossTenant-AuthSource: VI0PR08MB10743.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2023 10:12:47.3692 (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: LxFUbIGsQAfWMWw91Tkgpq7DVt2dazhahPXb9N8TFQwB4yqDIrck/4IUeDkS5GwazC46XVE4q1r4kpOJhVWg6piGiTnT96gbOU/yYYVg8OI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7459 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=2a01:111:f400:fe0d::713; envelope-from=alexander.ivanov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1703758566939100001 Content-Type: text/plain; charset="utf-8" If all the bits in a dirty bitmap cluster are ones, the cluster shouldn't be written. Instead the corresponding L1 entry should be set to 1. Check if all bits in a memory region are ones and set 1 to L1 entries corresponding clusters filled with ones. Signed-off-by: Alexander Ivanov --- block/parallels-ext.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 195b01b109..033ca3ec3a 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -354,7 +354,7 @@ static void GRAPH_RDLOCK parallels_save_bitmap(BlockDri= verState *bs, offset =3D 0; while ((offset =3D bdrv_dirty_bitmap_next_dirty(bitmap, offset, bm_siz= e)) >=3D 0) { uint64_t idx =3D offset / limit; - int64_t cluster_off, end, write_size; + int64_t cluster_off, end, write_size, first_zero; =20 offset =3D QEMU_ALIGN_DOWN(offset, limit); end =3D MIN(bm_size, offset + limit); @@ -367,6 +367,16 @@ static void GRAPH_RDLOCK parallels_save_bitmap(BlockDr= iverState *bs, memset(bm_buf + write_size, 0, s->cluster_size - write_size); } =20 + first_zero =3D bdrv_dirty_bitmap_next_zero(bitmap, offset, bm_size= ); + if (first_zero < 0) { + goto end; + } + if (first_zero - offset >=3D s->cluster_size) { + l1_table[idx] =3D 1; + offset =3D end; + continue; + } + cluster_off =3D parallels_allocate_host_clusters(bs, &alloc_size); if (cluster_off <=3D 0) { goto end; --=20 2.40.1