From patchwork Wed Aug 8 22:11:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10560519 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 4FFE01390 for ; Wed, 8 Aug 2018 22:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B90C2AF13 for ; Wed, 8 Aug 2018 22:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F77D2AF19; Wed, 8 Aug 2018 22:15:41 +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 DDF222AF19 for ; Wed, 8 Aug 2018 22:15:39 +0000 (UTC) Received: from localhost ([::1]:45703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnWjz-0005AX-4W for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Aug 2018 18:15:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnWgi-0002Rh-LW for qemu-devel@nongnu.org; Wed, 08 Aug 2018 18:12:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnWge-00027x-KY for qemu-devel@nongnu.org; Wed, 08 Aug 2018 18:12:16 -0400 Received: from mail-co1nam03on0136.outbound.protection.outlook.com ([104.47.40.136]:21263 helo=NAM03-CO1-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 1fnWge-00027K-7U; Wed, 08 Aug 2018 18:12:12 -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=jTxUbhM1BV212haJ5JjLXnAChTfJTMXEWCrtgUd+M88=; b=VYNXDO8jilUc1oq/MZvzW+eeUt77ifHwNFK+wSRS8DBf2BruE/IaGztrLsRW7/2i5kgPYkGB9qo807RGtUYC1rF2zeaAvzI1r1rpDfog2PmP/Oe/8920IfedQt3ms03EA6EqzV5VaxCjExX0xEWX/nlm8ghGBmz2p82vl/HlM84= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2620.namprd07.prod.outlook.com (2a01:111:e400:c637::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Wed, 8 Aug 2018 22:12:07 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 01:11:35 +0300 Message-Id: <20180808221138.5770-3-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180808221138.5770-1-lbloch@janustech.com> References: <20180808221138.5770-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: AM0PR01CA0018.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::31) To CY1PR07MB2620.namprd07.prod.outlook.com (2a01:111:e400:c637::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1a8cf72-67d0-4b37-cab5-08d5fd7bfc2e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989117)(5600074)(711020)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2620; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2620; 3:QC2euQOku5xHvfAViDk/54FS4vQPKr3tqThG0sS2E2XDNQ0DI982hLXQGG4JnNz6JDOQSVjFLDnBuBSCZII3uidufyRzHXupj4xyHJVfg68a+2FYtOli1cCHOfKJmKMur302RrtidlpuZADXC5rDSySWEtYnTNvsffXWJdSHsPx/zG58gT00Nk5JgYM/DuqaBplx29PokJLEW+tUilWWQPo5NUIqi300wCvRWTemMKrqrTOtW12HRG/Fu8IclfRG; 25:Rrxe/gmWKSwb8pALL6eX+ke8pM0ho2al9i4rBfOMKpeBLXeoakrD+TqHI+wrx4odM6vzkgS/keYHUhmFeZ79wwMSRqGuaAd+pweyr07vcJyKCpVWLN54DXc05xHXfDycDMc5CbG1NqoKteIGe6Ml4/+RFAocRwQQKNchip1rY8D/S+C80YMmUhqAQ/uKcEuGOK/9j84k3Jg2iZKMf9vIczWGDhjbm1N8Cxh/u4ebQkwzDPuE02kFED5F0s+pJlgh72y5dSyWjxywPg4vFvDFwnrJU9ENwXqWZAH0A9YTmqmnE4WWJ+LG6VZmONJL89fcOzZqPqJGKnDPnTHZu4ZfcA==; 31:P6Z2I0izNax47GGYHlfjcyEECLu4jQlYMfRLB7WBYCHTNTHZlzrS0dRuloWsK2bJogGRISM8jOjOAwP+XCiN21kszHFpCSxJmh82IQDr2GLS5DOFGFKXZcOgqiUfHOFFjcnQDOBZJ7I6G/2p7NONEZfnmbSdvv7QHSW5zhtivfudIjqrtv5yYS7xvi/WhUIoKtC5Set4LHKtDvNqEVKGWEs8a8ifE4yUFkMt7xOVX/w= X-MS-TrafficTypeDiagnostic: CY1PR07MB2620: 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)(5005006)(8121501046)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(2016111802025)(20161123558120)(20161123560045)(6043046)(6072148)(201708071742011)(7699016); SRVR:CY1PR07MB2620; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2620; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2620; 4:zuoTBBS6j3VcSZeZT1OfRmfuh6VPshT0Yb/EVijRj66uEGRmcJ/Phl5uZwCk/rZ/stGG7MmH85YRaB6Y5FqVDcOEj345spmnqphKZqZRLUIxwWEoFL4O+6MvsfboRH+1RDXq3Lafy4BYVvgS34i8f+/ieZuiWIHLCVsg/WdhbTuu7GDVvl0Wi+guAlLulNuX3Q2YKTPWWOXU/XtTmu5FFi4BNIA0LlhVTHTnyb8CAE5HQLDtPK9adVeXSdfzajjnLw+hNLV/dV+R43emxeNhBA== X-Forefront-PRVS: 07584EDBCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(366004)(376002)(39830400003)(396003)(136003)(189003)(199004)(52116002)(6506007)(386003)(106356001)(97736004)(53936002)(68736007)(2351001)(105586002)(186003)(66066001)(11346002)(47776003)(14444005)(446003)(81166006)(551984002)(8936002)(16526019)(76176011)(2616005)(956004)(305945005)(6512007)(476003)(7736002)(81156014)(26005)(8676002)(486006)(51416003)(36756003)(86362001)(6486002)(50226002)(4326008)(107886003)(2361001)(50466002)(1076002)(478600001)(6916009)(6666003)(48376002)(6116002)(5660300001)(54906003)(16586007)(316002)(2906002)(3846002)(25786009); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2620; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2620; 23:I9vOKFSpPWKVLl6ymLfmI+sOPvV9mWV5d89kmUSMF?= r4wnejKtjhseDw3B0gqh2erLQrXgeR0BbeyZtJ5KMnd2Mo7Vibe11PcUiOrVgfyyg/4sWjE+qH1XHSDM5z6q3plOjXhEEo7ORrEPPtd0Su6XiGN44fFLviP0i2EnKfJLJAikv9DgLyytanFwZg+4kbF5k8qH/mdXPSc1VwJB1sJlpU+VcBO4b2A4ck8n2ps8B9r9eeKSd9ANzDgF5fCdsm+4+jCxY4ZkgvAK6vaLdNmxNhiFC0a0v5FzVC+IRkeqRRM2SIq6P+lHoHDOPMnwASQE5nFV7afiuswS52k3KkRZkluPEWm7ibHdEvtlvb/+w43f0zRZmBd4rbyTo0ve/xvb2LYo5uG73NJPif9z/jg8pLiaGH7WgdD4SVIP2C5C1qgWeEv6aXkzpj0s7yddbvuZfmVpzVwqrRkW1ovebLgp+acz5552jvma6ou79My3JCfYwmUDBebSPPVWxjpp9ymb+4yAXwfJZiGpDuOD/dc/ATxTPbUlvkeSFJoL1APeBiPeOgqs6ym890nVaHBh3vmy4FTn+2V8omuwC+AdWFgRLsIVo0bqkHKuoa0xEG+1k+XiOEUFoS5VDr1qqLW36qeSbFkzbb3uD68UIMWTIGDkHC/3pt9uydXrHLJTsCqF/Hupl6iJDiK+0HW2xnDDS+XCaAlBH10Xa1Cx4VudIWyh+7JYoO1HJwwQn8sXPRTWh0SICKclFbbsvWA8grnizdZfgFbtSVJV+n6MGcyV2gjyWIKUBcrDZGwt5HJFNvU4NUenbLy81dSJ6DCN4+1DERrqpNcqOPIxS2CEWt7g/4GouWEIeI73SqmAurpJpCYd29Q8T40MF0zAOeXhill6TDEuDPo4dw1gBnZl4vlAKi7jJ5trZYXitMw3SpejFDxGWgDjyBsamL7gDJ0FIl4jxyf8DdSfbX2k+cXOGbBIaNsCCgmG+M6WzauxYbHlqKpRPSFhba6Dx2AMR9CXLRspT3u99PM4CK6/MtLoapGC0WMmKTZMWJoD1CtvlYlIicY2Jo1QZcUYidHPAh4L99Pcsf6dZwpKRautoQp3eTwm9hPWS6Seuud5BQI23cX4flWt3FUWs9OqzHUxfwPOXn8apeS6V7+gRWlv7H1hViBbdMyz6YGzot/np/5NIVKDylZleAwLfEUxf+v9LOJU8h1fz6ztIBTGzcnEMkYJQGEWuxAwUh4IFmFRt3nKwUJtF7EJwrDyxJ+hapjxhn+/GXNb6VAk8Vg4reUSeqiGix8r7gKgPrtWqQIOL1109FH4SRImDs= X-Microsoft-Antispam-Message-Info: ypmgn2Ppf2Yl3BwpOnU7PDzDTA4RnF+5t84HTu13w2hYetDOHmCBX2papwUCirY/vj0K3r3gPmOPvkhG+QslyOBX9hvgl99Ew0hEeWOsYgGkFU56OVpo9CM5quSAZp9p3ZL74527zi9fXDXJ0q4ynQT6Coek5prGcAY04rvxaDDaYm6JUbfOkeayphBynjjbgScK3w4FDk+YALi33XAAITpVbM6Rup8pX7fCCcaPOLSfKx8/HGpYIHh0Vi9Ospl2BbD1C7+wATk0FaSANBQFGTlHsMGjn5RAJ67+4xNsCJOU6u9cblQas4JwwAUnBK7ZXQI1sBNfukjrSRDpJQpn+shD/qPZLnpeKrX4ej5sRGI= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2620; 6:jzbCQwT5Lvs48CvpM5/BatKo2iEMecbHMX1fs8kaHeYfYG+cc1mcUodlP9E7DEGySSlk8heYv9RHGzaLfRE4OrHlawLSe2E9vuwyndbrKmQ+LfReOjTO8fUXeNzGbTXUx4eeYnrbrzPH5LxggAPUG9IcIXGTlOuRZk3JN8jIFuOtSlwvLRBCq5LpOs03yinLOv7ChUi3L62C24gaXt9PLMypE1N5jwYQt0NNt5AwuBNxS3O/5LdW7U47Wr87frrFysZgXby64EPvxtm3wt93949nd83J4oo6LIpesQFBpZkUXSh3q1UxJFMiFjCSDZ9f3FbdJJIW4DnszPUXrasRazqRAqc3B6Bw5YKrMQIYslCepbNVF99GhaMifcNDmA0AfHnQ8K1t+gNy2dQvzgspKfhTZat7247yD1iEMqPCz5SXey4tcUcLetkMOfQT0VUILngedEZxkkIZIseV8CTmaw==; 5:aMfQG1kjKQgPJy0rJ2G/syZqmUUOYWgj5zk3eSzUre0gYvXUocppCLXP66K5W76HPYQAEK3a1V/jpQbB4Wg3MaSzZyTHLWiyvssTVv3mJNJV0IYZ/qsng2zevTez2rkkdxC20fo9gbqVdBzcIkuex5SM2Dq8KbVJgCtUqKZkHbk=; 7:6xn6CBXqgKLAhgoRgtloYnSvmNtdnIySkykSv6tUk9sg8HOMy+qD+f6D3FRGc9qVWA9njL/UiBRUGxtqGD4nLpfleKPM03e+7WMABZdXFJ2xgVjA+L2ZkMP0o63eEql0sAwkv3wIPaUM5VdZ9fcu94M5ngb5cWZ305moAybKJYN38x0kgmJLnZFRSRod1UlVHpxk4Y2tQJyFX9Z+0A+Lp8x6P/KkSiuwuTGMBzoowQzEAG2gzIJ3U0VVX+ASIjtC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2018 22:12:07.8287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1a8cf72-67d0-4b37-cab5-08d5fd7bfc2e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2620 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.40.136 Subject: [Qemu-devel] [PATCH v4 2/5] qcow2: Assign the L2 cache relatively to image size 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 , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Sufficient L2 cache can noticeably improve the performance when using large images with frequent I/O. The memory overhead is not significant in most cases, as the cache size is only 1 MB for each 8 GB of virtual image size (with the default cluster size of 64 KB). Previously, the L2 cache was allocated without considering the image size, and an option existed to manually determine this size. Thus to achieve full coverage of the image by the L2 cache (i.e. use more than the default value of MAX(1 MB, 8 clusters)), a user needed to calculate the required size manually or using a script, and passs this value to the 'l2-cache-size' option. Now, the L2 cache is assigned taking the actual image size into account, and will cover the entire image, unless the size needed for that is larger than a certain maximum. This maximum is set to 32 MB by default (enough to cover a 256 GB image using the default cluster size) but can be increased or decreased using the 'l2-cache-size' option. This option was previously documented as the *maximum* L2 cache size, and this patch makes it behave as such, instead of as a constant size. Also, the existing option 'cache-size' can limit the sum of both L2 and refcount caches, as previously. Signed-off-by: Leonid Bloch --- block/qcow2.c | 33 +++++++++++++-------------------- block/qcow2.h | 4 +--- docs/qcow2-cache.txt | 24 ++++++++++++++---------- qemu-options.hx | 6 +++--- tests/qemu-iotests/137 | 1 - tests/qemu-iotests/137.out | 1 - 6 files changed, 31 insertions(+), 38 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index ec9e6238a0..98cb96aaca 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -777,29 +777,35 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, uint64_t *refcount_cache_size, Error **errp) { BDRVQcow2State *s = bs->opaque; - uint64_t combined_cache_size; + uint64_t combined_cache_size, l2_cache_max_setting; bool l2_cache_size_set, refcount_cache_size_set, combined_cache_size_set; - int min_refcount_cache = MIN_REFCOUNT_CACHE_SIZE * s->cluster_size; + uint64_t 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); 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); - *l2_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, 0); + l2_cache_max_setting = qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, + DEFAULT_L2_CACHE_MAX_SIZE); *refcount_cache_size = qemu_opt_get_size(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE, 0); *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); + *l2_cache_size = MIN(max_l2_cache, l2_cache_max_setting); + 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 " and " QCOW2_OPT_REFCOUNT_CACHE_SIZE " may not be set " "at the same time"); return; - } else if (*l2_cache_size > combined_cache_size) { + } else if (l2_cache_size_set && + (l2_cache_max_setting > combined_cache_size)) { error_setg(errp, QCOW2_OPT_L2_CACHE_SIZE " may not exceed " QCOW2_OPT_CACHE_SIZE); return; @@ -814,29 +820,16 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, } 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) { - *l2_cache_size = max_l2_cache; + if (combined_cache_size >= *l2_cache_size + min_refcount_cache) { *refcount_cache_size = combined_cache_size - *l2_cache_size; } else { - *refcount_cache_size = - MIN(combined_cache_size, min_refcount_cache); + *refcount_cache_size = MIN(combined_cache_size, + min_refcount_cache); *l2_cache_size = combined_cache_size - *refcount_cache_size; } } - } else { - if (!l2_cache_size_set) { - *l2_cache_size = MAX(DEFAULT_L2_CACHE_BYTE_SIZE, - (uint64_t)DEFAULT_L2_CACHE_CLUSTERS - * s->cluster_size); - } - if (!refcount_cache_size_set) { - *refcount_cache_size = min_refcount_cache; - } } if (*l2_cache_entry_size < (1 << MIN_CLUSTER_BITS) || diff --git a/block/qcow2.h b/block/qcow2.h index 81b844e936..d77a31d932 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -73,9 +73,7 @@ /* Must be at least 4 to cover all cases of refcount table growth */ #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */ -/* Whichever is more */ -#define DEFAULT_L2_CACHE_CLUSTERS 8 /* clusters */ -#define DEFAULT_L2_CACHE_BYTE_SIZE 1048576 /* bytes */ +#define DEFAULT_L2_CACHE_MAX_SIZE 0x2000000U /* bytes */ #define DEFAULT_CLUSTER_SIZE 65536 diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 5bf2a8ad29..c7625cdeb3 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -97,12 +97,14 @@ need: l2_cache_size = disk_size_GB * 131072 refcount_cache_size = disk_size_GB * 32768 -QEMU has a default L2 cache of 1MB (1048576 bytes) and a refcount -cache of 256KB (262144 bytes), so using the formulas we've just seen -we have +QEMU will use a default L2 cache sufficient to cover the entire virtual +size of an image, which with the default cluster size will result in 1 MB +of cache for every 8 GB of virtual image size: - 1048576 / 131072 = 8 GB of virtual disk covered by that cache - 262144 / 32768 = 8 GB + 65536 / 8 = 8192 = 8 GB / 1 MB + +A default refcount cache is 4 times the cluster size, which defaults to +256 KB (262144 bytes). How to configure the cache sizes @@ -121,8 +123,11 @@ There are a few things that need to be taken into account: - Both caches must have a size that is a multiple of the cluster size (or the cache entry size: see "Using smaller cache sizes" below). - - The default L2 cache size is 8 clusters or 1MB (whichever is more), - and the minimum is 2 clusters (or 2 cache entries, see below). + - The default L2 cache size will cover the entire virtual size of an + image, but is capped at 32 MB (enough for image sizes of up to 256 GB + with the default cluster size). This maximum value can be reduced or + enlarged using the "l2-cache-size" option. The minimum is 2 clusters + (or 2 cache entries, see below). - The default (and minimum) refcount cache size is 4 clusters. @@ -180,9 +185,8 @@ Some things to take into account: always uses the cluster size as the entry size. - If the L2 cache is big enough to hold all of the image's L2 tables - (as explained in the "Choosing the right cache sizes" section - earlier in this document) then none of this is necessary and you - can omit the "l2-cache-entry-size" parameter altogether. + (the default behavior) then none of this is necessary and you can + omit the "l2-cache-entry-size" parameter altogether. Reducing the memory usage diff --git a/qemu-options.hx b/qemu-options.hx index f6804758d3..d6e15b2f06 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -756,9 +756,9 @@ 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 in bytes -(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) +(default: if cache-size is not defined - 32M; otherwise, as large as possible +or needed within the cache-size, while permitting the requested or the minimal +refcount cache size) @item refcount-cache-size The maximum size of the refcount block cache in bytes diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 87965625d8..e3fb078588 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -109,7 +109,6 @@ $QEMU_IO \ -c "reopen -o cache-size=1M,l2-cache-size=64k,refcount-cache-size=64k" \ -c "reopen -o cache-size=1M,l2-cache-size=2M" \ -c "reopen -o cache-size=1M,refcount-cache-size=2M" \ - -c "reopen -o l2-cache-size=256T" \ -c "reopen -o l2-cache-entry-size=33k" \ -c "reopen -o l2-cache-entry-size=128k" \ -c "reopen -o refcount-cache-size=256T" \ diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out index 6a2ffc71fd..70f245ae7a 100644 --- a/tests/qemu-iotests/137.out +++ b/tests/qemu-iotests/137.out @@ -19,7 +19,6 @@ Parameter 'lazy-refcounts' expects 'on' or 'off' cache-size, l2-cache-size and refcount-cache-size may not be set at the same time l2-cache-size may not exceed cache-size refcount-cache-size may not exceed cache-size -L2 cache size too big L2 cache entry size must be a power of two between 512 and the cluster size (65536) L2 cache entry size must be a power of two between 512 and the cluster size (65536) Refcount cache size too big