From patchwork Tue Jul 24 22:17:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10543255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2B34112E for ; Tue, 24 Jul 2018 22:22:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91718295D1 for ; Tue, 24 Jul 2018 22:22:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85A00295D4; Tue, 24 Jul 2018 22:22:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A009A295D1 for ; Tue, 24 Jul 2018 22:22:23 +0000 (UTC) Received: from localhost ([::1]:42816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fi5hG-0001YG-ME for patchwork-qemu-devel@patchwork.kernel.org; Tue, 24 Jul 2018 18:22:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fi5dm-0006lI-6U for qemu-devel@nongnu.org; Tue, 24 Jul 2018 18:18:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fi5di-0007Fv-Uj for qemu-devel@nongnu.org; Tue, 24 Jul 2018 18:18:46 -0400 Received: from mail-bn3nam01on0111.outbound.protection.outlook.com ([104.47.33.111]:24883 helo=NAM01-BN3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fi5di-0007FF-Nh; Tue, 24 Jul 2018 18:18:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janustech.onmicrosoft.com; s=selector1-janustech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GqtooTSZhsn6J5sBF6A5kS1svBWQKB+F9ZVvFBwQOT0=; b=XmEO8W3XSKs+ZtzuxIabW3MoSOfyUyGAOzvnYCTGX9s8WpR+djR1ssjN+hcV5pxkjDZuRKBsfQLX/N8emMI9CsNyfa423TzKU0fC6jz3c/ynbGpWbQWc+PKmxvf6/nPIDwLvA2r0fU3Zanyi/BX4QMgiWHQ3PEoMpwLLQVee0jY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by BN3PR07MB2612.namprd07.prod.outlook.com (2a01:111:e400:c5f0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Tue, 24 Jul 2018 22:18:39 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 25 Jul 2018 01:17:49 +0300 Message-Id: <20180724221750.16282-4-lbloch@janustech.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180724221750.16282-1-lbloch@janustech.com> References: <20180724221750.16282-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR05CA0128.eurprd05.prod.outlook.com (2603:10a6:7:28::15) To BN3PR07MB2612.namprd07.prod.outlook.com (2a01:111:e400:c5f0::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f24a1245-3c24-4d28-51eb-08d5f1b3694b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989117)(5600073)(711020)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:BN3PR07MB2612; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2612; 3:P4k9z6PpRf6PsIdvEyYLTZEWBzHCke++UU2waTykh9SbaQeAsDM9Hi/cEQlnMuF4Nit3h9xea4rhpkmwZ/wrCvroyduPNTWLkCzTdbM3nGEgX1WL50YssKNML+UtIl9OkPT3suorc469+s4BOQVmVoDKZy3NeuO3LB2jnQJkxNPGctrx2Vjn8o7vupbI3nx89RamIhpQFI8kwEXjaDL4d7ZHPumhOK1jufV28W7j9bKtS7hEmRxAiM0xTBi2i6wI; 25:7W+Y/IPqhFxmx378/g41jH10twZWK3CvEGvUI9TK86IgVcXdRpKbMBQtIUQjpiV3YL/7kB+se9KQeYbyh97vkvvuDRk+JXOYKIS7yWZT7symh+UKXbh/NGJcE6eOz3atRo54VJNbWj7a1TBdFteXHpLeO17/cByT+ZxXh+WabZvDneojLWFJjGwxrRNBtk2heGpBqlOkRZZtfCA/Q88WSKTz+0YdU2e9bs8c3vLC/ICWfzLRFr6KebRkQVfHbbeir8hgWAs9H5QrWtdOshQA7EU1wJBczoE8r7hL270QLgEYGgqyl6frxUE9qMjn6Nb3RVkvuJOEcBICRJzYsMIhcQ==; 31:cniWeiR2XY0bAAOuykMth1LlHvteFngq38TrrQPKONLBGO64y0+Nd/jgynHLkreowZ8nLvAwUS745fZaZis2ZSqX6F9PycsEAyuXCCp/MPfa5oLDE0MVTJVS9vRD4AsAaNC2vBc7jbcaQfa/Jsgj6PwUb9QO7Gml42c0O2ukjffk1iFkwOA0NgJ9jHb9VQNW2xryjBa3owXr68Idse9AwEeyTyJEerbHp5mLnHX9a7U= X-MS-TrafficTypeDiagnostic: BN3PR07MB2612: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(2016111802025)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(6043046)(201708071742011)(7699016); SRVR:BN3PR07MB2612; BCL:0; PCL:0; RULEID:; SRVR:BN3PR07MB2612; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2612; 4:29diaRe1u1DZq9tLD51KoUpY+uG3BPegjfLTbZbuux331NIVPBPMmmyQp7aEVu7ILMoN5ViGq43x1yYM3BSPS6qD4wKEAtseFMXrKTZWhmPwGFEdBZxt2q7c2FEF5gPMmC/PC5FgPpmNXV+d1yTBN/iPANL+o2NHp7OOLJH1oa4oddLxMB18bZPkBe7HnvnZ70JUIFCjsoxkdM/SsGRRr+sXcvRy/iQAT+cRSSfQMklxvasPAHFUhul9RODvNI+30Zzs81uUWFBaH/Vol2qLEg== X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39830400003)(396003)(346002)(366004)(136003)(376002)(199004)(189003)(68736007)(14444005)(3846002)(52116002)(4326008)(51416003)(1076002)(76176011)(2361001)(53936002)(54906003)(5660300001)(25786009)(8676002)(107886003)(2906002)(6486002)(6666003)(6116002)(86362001)(50466002)(48376002)(6916009)(575784001)(486006)(6512007)(36756003)(2351001)(478600001)(97736004)(66066001)(305945005)(7736002)(2616005)(8936002)(956004)(11346002)(476003)(47776003)(446003)(186003)(16586007)(16526019)(81156014)(26005)(316002)(6506007)(50226002)(106356001)(105586002)(81166006)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR07MB2612; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR07MB2612; 23:bBOv/jBnOte5MXKYO7SZKCsA0gPa0acFDmwxht+d1?= TA7ozFJb1jWLsbyjw0Pw/JPvrYRVYa+kGmE1IoBKTuhTScMbKRPtFFWV/om8lzXVIqzaO/TDm8p4XagR0mNVk5t2+/MJqJ8s5UBtShWQT0Ei9jXL/z+ORO8wzuG8VQferrR6wYm5Pta+eyCQljZ1DA6zhHDTn65H2Ct5DVZXinJKzA84Akc/TdXLGVwNRagajRVhK0Aims63Y41S8ncWLXwCwvx09s7cJIZ4TYTZaYqhPp5YLIzyxT+g5rXSNWbJwNIQe3L3Uxp1cYzAxHIvFQUbClEOGDld4HelhDfY4H2MhTR4kI7cZ/iTuTL3djBWbtFVyerSZ+D5hwIkr+tmyRhT5MAsLqqSXnH4DjBO9wkSHjW3dU7ixq/PyVSwbDkrN2Gy4RWUzfk7YU/AHjVv8ttksqRdnswtF5QuWfp4SDMYh7Zf7KvIrsgAkAZ8mpl0iEarXC6H0ozq/vwi7afEQVb7nRMwcO+qI3bcA2A6tQrjayOYZ6LUPc9NU2cQsSPeXZZ/K/MkCcEqnjbTTsXq0ZJfpJIc97xJBA5L/WygvLHHB4pPPqH6kiqvN0YfzQ+vvX/KCRKbUvaCP/UPKsD0+hQdLKiYuAtmHEUbRFSDlQ895ywcNL1DAkbQ3r52rX4GflVieAgvs136O97T7Nih4UmPTKfMNIbaWlzkglWnP7wbjQN5wXtKGBOW4uL7Kd/EcJ2rpxlD5fqgzrGsyooSjLI1jTFEWJVD9XCi8WO95OfBDyeX+tTIj7GlDT2zQM2mX+K58bX4zqjtv36TLulqr7eOstXIzUXxZ3Uh1OQdYpA26zYXK5RVZsycjWRzoiJwVfV/jdDaLGhTmy4sOuPzJ1FZtadOmu/CTJsgXzfcGM2RJsjw9TdR0670KtpPsPSTy3gUQ3W/2J8zpE6yQ12FMQDhGWFxVIXR2/a6o5Nbeqw6w5nJWY3+tIquMpvk5VK/73vwqaFUsyyn0BUuvROxoNXOUv4T0SgpZyVYEslPw9hhonRhRNFfqXoYtnwmDIUczoioZPqidDjFnGxTGKCequDcon4zreYuRtr02dY7bfnJ1oRRkHjvyMrl0dKDDUSYcJMrZLOQsYgq8MMbRIXB2I10AYlbwRMEOP/oLcrZ5LsLgEehP+Nw3otQ56W9NUWnM9mLIVPEYWhsAOfSEzQlnZsFliRfFqr/5wKEdQcaeOHZ8nF6Uij6vARhtIpVCJWM3/5uZEF4xidkJ0W4egtzSJko9svK60VyB94ZomWjGY4DWEv1y0OfhE1mdqrJLb5H5U= X-Microsoft-Antispam-Message-Info: RkA6UihXIJ3WTB/naGTWu//LLp9YSndkv/FmEOo/EAAYKr+Dbotf02Az3t97LDq/asnq7VwsT8AcGWWc0sBb4nvvdy8DulTvGag2r7C5rcwp6Of4zrP70npGVj6MJJflIx7xS1JjElVznnSyrVs0SAqiqnhe8EBNy8qWryaxSosVXmL96wGhJ7I1vefieZtNm7tXevq/7gjHDcK2uK30g6BX2CbgKyN+4EJl5bztpMxayDqxtJiWPCYpTXZpxta4N1cvLCX9fhJdnYkDh7lpCuetvG+sEvzM5b6D1u8pCybJVVHD+4npJsdXnomMCI15AgO0QTtCGYRk1wtCIUClXkKVjKB20wY+WkGlYeBLYnM= X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2612; 6:whY6PVHqpY2GlS5Lq10ZFdJSQO95PcCdo5IMVVLnJsnzLgBlnSI71TZVP5cBhGEkAWY0H7HSu3JqlhOmKz4I6Zf+j/hF2vNyBRF2PWWKlpgWd4lNy1O07rOC0Kne+Ii0iYhXz7/jtTzMe5cmePda0DrTdMUvZL5KDkCWXxQw2Cc/we/NJJxrpBGm/xl374E4n9eWGFczCru9Z2llfhOSZTCowCooQJ7/dBghvzbe3tPLYUvODOWu3HacVd3vpCjWBt4rBw8DooSnOrHqul2ITi15GQrEBQ1t5Y8+xzFJiA7cdlWnbRep2d3RNyc7hxtMF7PTphRqC5hEGR6+PLofbGvdybjERkZZa3qXo4XDdNUo2O04KU6GesHJMbN3PL7pGz3p4vekpkGYKzFDVRjAOQ1rQ364q7tK3AgCzLtt1KkBRAL3yGN/9dRBxzOV8U/P2/EF2U0NlaVK+rnEt9etfA==; 5:gDmSrPesv/EB+NOYw0BkuFl2CtSjP4eQI7cZuYCPOrrOvQmHS5KH00BMkh2Uz9nH+6o+BzNlBBMwYG8arHrsTYI9DI8OduD/l7ZTknzGT9ZFe7EMxu2l7C5ahuYEcP/1Qj5d1UavZ99EZy8kcx+tY0Qf1qON3q9JO9ijR7wYVz4=; 7:sh5NET1EIN+x7u741dqrVjwmiAOHhsEQv2uHuCaKeDxZxuaMu089hzpnXo1vAfCQ1qo92fnK1amu97DETaKqH3prieYl0H3tAnb4DR/yfmCG9WWkkqGXk4IrQEpsYXSrn4QuK/xoJlzebFLdgCL0VyJ8NNK1UlY8PzpNla7hJi8zvl5zBFzn8g5eHA6riYLgTbsZshP5kQIos8b4ykw86CicstGWCVJBTR5iwu0hS2xKiNp0dH5bWs4dQYOWNfsh SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 22:18:39.0050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f24a1245-3c24-4d28-51eb-08d5f1b3694b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2612 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.33.111 Subject: [Qemu-devel] [PATCH v4 3/4] qcow2: Introduce an option for sufficient L2 cache for the entire image X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Leonid Bloch , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP An option "l2-cache-full" is introduced to automatically set the qcow2 L2 cache to a sufficient value for covering the entire image. The memory overhead when using this option is not big (1 MB for each 8 GB of virtual image size with the default cluster size) and it can noticeably improve performance when using large images with frequent I/O. Previously, for this functionality the correct L2 cache size needed to be calculated manually or with a script, and then this size needed to be passed to the "l2-cache-size" option. Now it is sufficient to just pass the boolean "l2-cache-full" option. Signed-off-by: Leonid Bloch --- block/qcow2.c | 35 ++++++++++++++++++++++++++++------- block/qcow2.h | 1 + docs/qcow2-cache.txt | 15 +++++++++++---- qapi/block-core.json | 8 +++++++- qemu-options.hx | 6 +++++- 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ec9e6238a0..101b8b474b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -695,6 +695,11 @@ static QemuOptsList qcow2_runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Maximum L2 table cache size", }, + { + .name = QCOW2_OPT_L2_CACHE_FULL, + .type = QEMU_OPT_BOOL, + .help = "Create full coverage of the image with the L2 cache", + }, { .name = QCOW2_OPT_L2_CACHE_ENTRY_SIZE, .type = QEMU_OPT_SIZE, @@ -779,10 +784,12 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, BDRVQcow2State *s = bs->opaque; uint64_t combined_cache_size; bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set; + bool l2_cache_full_set; int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size; combined_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE); l2_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE); + l2_cache_full_set = qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_FULL); refcount_cache_size_set = qemu_opt_get(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE); combined_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_CACHE_SIZE, 0); @@ -793,6 +800,17 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, *l2_cache_entry_size = qemu_opt_get_size( opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); + uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; + uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); + + if (l2_cache_size_set && l2_cache_full_set) { + error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " and " + QCOW2_OPT_L2_CACHE_FULL " may not be set at the same time"); + return; + } else if (l2_cache_full_set) { + *l2_cache_size = max_l2_cache; + } + if (combined_cache_size_set) { if (l2_cache_size_set && refcount_cache_size_set) { error_setg(errp, QCOW2_OPT_CACHE_SIZE ", " QCOW2_OPT_L2_CACHE_SIZE @@ -800,8 +818,14 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, "at the same time"); return; } else if (*l2_cache_size > combined_cache_size) { - error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " - QCOW2_OPT_CACHE_SIZE); + if (l2_cache_full_set) { + error_setg(errp, QCOW2_OPT_CACHE_SIZE " must be greater than " + "the full L2 cache if " QCOW2_OPT_L2_CACHE_FULL + " is used"); + } else { + error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " + QCOW2_OPT_CACHE_SIZE); + } return; } else if (*refcount_cache_size > combined_cache_size) { error_setg(errp, QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not exceed " @@ -809,14 +833,11 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, return; } - if (l2_cache_size_set) { + if (l2_cache_size_set || l2_cache_full_set) { *refcount_cache_size = combined_cache_size - *l2_cache_size; } else if (refcount_cache_size_set) { *l2_cache_size = combined_cache_size - *refcount_cache_size; } else { - uint64_t virtual_disk_size = bs->total_sectors * BDRV_SECTOR_SIZE; - uint64_t max_l2_cache = virtual_disk_size / (s->cluster_size / 8); - /* Assign as much memory as possible to the L2 cache, and * use the remainder for the refcount cache */ if (combined_cache_size >= max_l2_cache + min_refcount_cache) { @@ -829,7 +850,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } } } else { - if (!l2_cache_size_set) { + if (!l2_cache_size_set && !l2_cache_full_set) { *l2_cache_size = MAX(DEFAULT_L2_CACHE_BYTE_SIZE, (uint64_t)DEFAULT_L2_CACHE_CLUSTERS * s->cluster_size); diff --git a/block/qcow2.h b/block/qcow2.h index 81b844e936..151e014bd8 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -97,6 +97,7 @@ #define QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY "overlap-check.bitmap-directory" #define QCOW2_OPT_CACHE_SIZE "cache-size" #define QCOW2_OPT_L2_CACHE_SIZE "l2-cache-size" +#define QCOW2_OPT_L2_CACHE_FULL "l2-cache-full" #define QCOW2_OPT_L2_CACHE_ENTRY_SIZE "l2-cache-entry-size" #define QCOW2_OPT_REFCOUNT_CACHE_SIZE "refcount-cache-size" #define QCOW2_OPT_CACHE_CLEAN_INTERVAL "cache-clean-interval" diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 3673f2be0e..bae21061f3 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -110,11 +110,12 @@ How to configure the cache sizes Cache sizes can be configured using the -drive option in the command-line, or the 'blockdev-add' QMP command. -There are three options available, and all of them take bytes: +There are four options available: -"l2-cache-size": maximum size of the L2 table cache -"refcount-cache-size": maximum size of the refcount block cache -"cache-size": maximum size of both caches combined +"l2-cache-size": maximum size of the L2 table cache (bytes, K, M) +"refcount-cache-size": maximum size of the refcount block cache (bytes, K, M) +"cache-size": maximum size of both caches combined (bytes, K, M) +"l2-cache-full": make the L2 cache cover the full image (boolean) There are a few things that need to be taken into account: @@ -130,6 +131,12 @@ There are a few things that need to be taken into account: memory as possible to the L2 cache before increasing the refcount cache size. +- If "l2-cache-full" is specified, QEMU will assign enough memory + to the L2 cache to cover the entire size of the image. + +- "l2-cache-size" and "l2-cache-full" can not be set simultaneously, as + setting "l2-cache-full" already implies a specific size for the L2 cache. + - At most two of "l2-cache-size", "refcount-cache-size", and "cache-size" can be set simultaneously. diff --git a/qapi/block-core.json b/qapi/block-core.json index d40d5ecc3b..c584059e23 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2812,7 +2812,12 @@ # refcount block caches in bytes (since 2.2) # # @l2-cache-size: the maximum size of the L2 table cache in -# bytes (since 2.2) +# bytes (mutually exclusive with l2-cache-full) +# (since 2.2) +# +# @l2-cache-full: make the L2 table cache large enough to cover the +# entire image (mutually exclusive with l2-cache-size) +# (since 3.1) # # @l2-cache-entry-size: the size of each entry in the L2 cache in # bytes. It must be a power of two between 512 @@ -2840,6 +2845,7 @@ '*overlap-check': 'Qcow2OverlapChecks', '*cache-size': 'int', '*l2-cache-size': 'int', + '*l2-cache-full': 'bool', '*l2-cache-entry-size': 'int', '*refcount-cache-size': 'int', '*cache-clean-interval': 'int', diff --git a/qemu-options.hx b/qemu-options.hx index 13ece21cb6..b493371704 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -754,11 +754,15 @@ image file) The maximum total size of the L2 table and refcount block caches in bytes @item l2-cache-size -The maximum size of the L2 table cache. +The maximum size of the L2 table cache. (Mutually exclusive with l2-cache-full) (default: if cache-size is not defined - 1048576 bytes or 8 clusters, whichever is larger; otherwise, as large as possible or needed within the cache-size, while permitting the requested or the minimal refcount cache size) +@item l2-cache-full +Make the L2 table cache large enough to cover the entire image (mutually +exclusive with l2-cache-size) (on/off; default: off) + @item refcount-cache-size The maximum size of the refcount block cache in bytes (default: 4 times the cluster size, or any portion of the cache-size, if it is