From nobody Fri Dec 19 16:01:27 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533673606015859.4214634253132; Tue, 7 Aug 2018 13:26:46 -0700 (PDT) Received: from localhost ([::1]:40728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fn8Z2-0004Bw-TY for importer@patchew.org; Tue, 07 Aug 2018 16:26:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fn8Uk-0000DX-O7 for qemu-devel@nongnu.org; Tue, 07 Aug 2018 16:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fn8Ug-00088L-4N for qemu-devel@nongnu.org; Tue, 07 Aug 2018 16:22:18 -0400 Received: from mail-by2nam05on072c.outbound.protection.outlook.com ([2a01:111:f400:fe52::72c]:22811 helo=NAM05-BY2-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 1fn8Uf-00086y-Ml; Tue, 07 Aug 2018 16:22:14 -0400 Received: from Jupiter.local (141.226.29.227) by BN3PR07MB2609.namprd07.prod.outlook.com (2a01:111:e400:c5f0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Tue, 7 Aug 2018 20:21:49 +0000 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=V9k2+C3jiP1RGH8k4AbfeASoqvFXQEb9J7Fn7SKVFIo=; b=Z9AYeYzD0bC2JGXP/DsRL51cdjXJLWKHkdVKrmkyn/PlFFbb5sdGeEFAK+SF941uAhD7a4Aj0zw1OoOt8DTKj32aN0nWrBh+Hm1J9Apx83hJGlqKFcn4bI1Qba2Iy9PO+Xye8vT4uVNLdaFPkabC60MQklkw324RHVBLN8hTuS4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; From: Leonid Bloch To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 23:21:19 +0300 Message-Id: <20180807202122.27006-3-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180807202122.27006-1-lbloch@janustech.com> References: <20180807202122.27006-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: VI1PR08CA0126.eurprd08.prod.outlook.com (2603:10a6:800:d4::28) To BN3PR07MB2609.namprd07.prod.outlook.com (2a01:111:e400:c5f0::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: adb17f16-c19f-4eb0-90c7-08d5fca36903 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989117)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BN3PR07MB2609; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2609; 3:/Rz8uhUwqZywK0yqyV+o2cT61RXXXZ3w8D+helkdYzMyY8g1mrdynWes07nI+wnuCwmJEGWdI1YYw99e/f6sfrsYaIKD19TwuG3qOMCCxGcnJI03Tp/BEN30UL/B/yDMIMsLwgYkcJZ+Uig/aBLZCgKSNsWeULoGPZkSXrrbJIezf507PHshoC26mk3ii532D+KOajqhkwoYPN9Q2SQcC4Z0Jx8avrMyesdAE2jzbZILpLdcaACVHNz/5UU3xozo; 25:umZLaHnoWHXZl25Q08tB2i7gW9yyFvVrMSZP3NZWNgyhvQ6PjBs8r4lJ5xQmxMfR0l8Hs4FOEkSG5p0gcyfgEXcbM1IBQ0QUH6XMhYeSaVQJsLN0lHxqySy0huSND5rHKbat6ijzZcaBkV+LSLYdiFSAT+9mKGPHSnPgG/epBi3PDreiqJU2lMxvHs4UyjQ5Le7CLjXDWIL5NxXZdIwMug4j2oMvVQK2lWyCsHwVF1XpXO5azwgffV/5e5OnnjaeKT8llFSSlLaommK5hCOBjvkQlCa/3t31GLd26bJVMbg6y4vegbHTkgvi62/hiWQ5TzegWyt59NuaXGukP77gBQ==; 31:SVCP4wCC191LS7swRr35reYvkyFd8yPk8nkHqeH/tpQl+KGTZM5Q2oheNln7oDUqEMT0iwx90GSUswz7NXI8kKoHRdb+HjenLuJsrF397i1KOwQadpCkKVQ6B7TFjOpzbipye0E+NUDWhoJtpWSYvVI4o2NjS2GzyVCl/bbC0Ze18i2iaXIW76LpChfZuyTZUWtyzpGxVSsMRcvNL2OGt1cOvpzKZmI2vnEfZDiZkj4= X-MS-TrafficTypeDiagnostic: BN3PR07MB2609: 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)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123562045)(2016111802025)(20161123564045)(6072148)(6043046)(201708071742011)(7699016); SRVR:BN3PR07MB2609; BCL:0; PCL:0; RULEID:; SRVR:BN3PR07MB2609; X-Microsoft-Exchange-Diagnostics: 1; BN3PR07MB2609; 4:azVeqiwR8hoDW+JfSK/VYpWo69GPWHwb5XYwYfAxsyHliIIAEnbOW9nL1F+jWdIhpEvjEU1QMfBWIaUqvdWlIXh4vxuEzcwwgv3VMoz71yYVTZ7oGMEYXcbuWROgdz/xEjxNrZmSy9tAYQ/IH+PE9U8a4bX0SAAZXwiFcBTbdljONJBsC9x/MmLmr4eeL4R8Ogb6LkUbg8CxLKRm11syobLUBKR+Y1kRNoVKrNN5KmlK6l+B2S9zzA5m0p2Q+lIzaH3dOqIDAw0cqDHsitWYqw== X-Forefront-PRVS: 0757EEBDCA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(39830400003)(376002)(136003)(346002)(366004)(199004)(189003)(47776003)(446003)(66066001)(956004)(305945005)(11346002)(105586002)(48376002)(76176011)(486006)(50466002)(106356001)(7736002)(5660300001)(2616005)(25786009)(52116002)(2361001)(51416003)(2351001)(6916009)(551984002)(81156014)(81166006)(6666003)(476003)(36756003)(386003)(6506007)(8676002)(8936002)(16526019)(50226002)(16586007)(26005)(54906003)(316002)(68736007)(186003)(6512007)(3846002)(6116002)(6486002)(97736004)(1076002)(2906002)(14444005)(53936002)(4326008)(107886003)(86362001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR07MB2609; H:Jupiter.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: None (protection.outlook.com: janustech.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR07MB2609; 23:46oVjV5qsq0FLF9R1e2RxNfT+76eVbfkvo1rUy3Dl?= =?us-ascii?Q?0BkQ5Ef0pIg4W6ueScG4re90eUtm1MkgTk39KvwM0JUIHd5my+x9l10X5Ssy?= =?us-ascii?Q?J5P16UdpV1nxCTXYjGOuTSgrrpfgrFHq/5t/S5Q809zLsi2A8e91vSsYHIYP?= =?us-ascii?Q?ymnv1NnA6a/39t/gVQt7zTlaSt6bHnq9w0IGY/tPEpODKfS3Q7Xh/FdAaOom?= =?us-ascii?Q?tv0p53OD+z7a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nwYTvEwcMkqwnJcrJNYVs2Rew26V9OR5a4dCN+mlDZpvG/bQz+pQi9eIZUt8WtPyM6yFfhWSLvKUZyjJAVAZLGWKqBgIULYt1FXtPN5Ezcyc6E5Fbuh+/An4qcT1iA74oH6sCQ==; 5:acFA6r5iAKF/hrGUUxh71fRx5nsMTAO/KbtdxmPV+7/ZmnkvwKPUJp5gK8PaIUPWPehwSqxevH4C9oGoOPR/pNRBArNEEQtsP5jDS7uxM+VL6Onr7hPZt+jlVguGkz2Xubl1bMnleg7ZV9Bkvty5WrzqVQzjRhjf1S9Z4Zrt/9Q=; 7:V0BMeTZrUWjsU00wouQGTeTnfStcH3YBQvHwStaDu8GHgZnEkrhKc3S4oKNUVLMwRrhEbbSKnwo+s4B9gBYIJk6caXwvFSSQBdrE+HTHVGFazyYNGqRX3FsVDl0Xp9daAeYdJqbdGVmoa1BlRD0oufTzjB0jhY0KyMjwPNZ8n/jSgKqpKlXV4iEBHqpGoyJKS+uK4Ij9hMpP03D+9wFyPBBuobMnSuDJFI5n+JzEqs0DO8yZjfnbhrO9+3piYPLD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2018 20:21:49.9090 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: adb17f16-c19f-4eb0-90c7-08d5fca36903 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2609 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe52::72c Subject: [Qemu-devel] [PATCH v2 2/5] qcow2: Make the default L2 cache sufficient to cover 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 , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Leonid Bloch Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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). For cases with very large images and/or small cluster sizes, there is an upper limit on the default L2 cache: 32 MB. To modify this limit one can use the already existing '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 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, Qe= muOpts *opts, uint64_t *refcount_cache_size, Error **errp) { BDRVQcow2State *s =3D 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_s= et; - int min_refcount_cache =3D MIN_REFCOUNT_CACHE_SIZE * s->cluster_size; + uint64_t min_refcount_cache =3D MIN_REFCOUNT_CACHE_SIZE * s->cluster_s= ize; =20 combined_cache_size_set =3D qemu_opt_get(opts, QCOW2_OPT_CACHE_SIZE); l2_cache_size_set =3D qemu_opt_get(opts, QCOW2_OPT_L2_CACHE_SIZE); refcount_cache_size_set =3D qemu_opt_get(opts, QCOW2_OPT_REFCOUNT_CACH= E_SIZE); =20 combined_cache_size =3D qemu_opt_get_size(opts, QCOW2_OPT_CACHE_SIZE, = 0); - *l2_cache_size =3D qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SIZE, 0); + l2_cache_max_setting =3D qemu_opt_get_size(opts, QCOW2_OPT_L2_CACHE_SI= ZE, + DEFAULT_L2_CACHE_MAX_SIZE); *refcount_cache_size =3D qemu_opt_get_size(opts, QCOW2_OPT_REFCOUNT_CACHE_SIZE= , 0); =20 *l2_cache_entry_size =3D qemu_opt_get_size( opts, QCOW2_OPT_L2_CACHE_ENTRY_SIZE, s->cluster_size); =20 + uint64_t virtual_disk_size =3D bs->total_sectors * BDRV_SECTOR_SIZE; + uint64_t max_l2_cache =3D virtual_disk_size / (s->cluster_size / 8); + *l2_cache_size =3D 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, Qe= muOpts *opts, } else if (refcount_cache_size_set) { *l2_cache_size =3D combined_cache_size - *refcount_cache_size; } else { - uint64_t virtual_disk_size =3D bs->total_sectors * BDRV_SECTOR= _SIZE; - uint64_t max_l2_cache =3D 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 >=3D max_l2_cache + min_refcount_cache= ) { - *l2_cache_size =3D max_l2_cache; + if (combined_cache_size >=3D *l2_cache_size + min_refcount_cac= he) { *refcount_cache_size =3D combined_cache_size - *l2_cache_s= ize; } else { - *refcount_cache_size =3D - MIN(combined_cache_size, min_refcount_cache); + *refcount_cache_size =3D MIN(combined_cache_size, + min_refcount_cache); *l2_cache_size =3D combined_cache_size - *refcount_cache_s= ize; } } - } else { - if (!l2_cache_size_set) { - *l2_cache_size =3D MAX(DEFAULT_L2_CACHE_BYTE_SIZE, - (uint64_t)DEFAULT_L2_CACHE_CLUSTERS - * s->cluster_size); - } - if (!refcount_cache_size_set) { - *refcount_cache_size =3D min_refcount_cache; - } } =20 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 */ =20 -/* 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 */ =20 #define DEFAULT_CLUSTER_SIZE 65536 =20 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 =3D disk_size_GB * 131072 refcount_cache_size =3D disk_size_GB * 32768 =20 -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: =20 - 1048576 / 131072 =3D 8 GB of virtual disk covered by that cache - 262144 / 32768 =3D 8 GB + 65536 / 8 =3D 8192 =3D 8 GB / 1 MB + +A default refcount cache is 4 times the cluster size, which defaults to +256 KB (262144 bytes). =20 =20 How to configure the cache sizes @@ -121,8 +123,11 @@ There are a few things that need to be taken into acco= unt: - 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). =20 - - 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). =20 - The default (and minimum) refcount cache size is 4 clusters. =20 @@ -180,9 +185,8 @@ Some things to take into account: always uses the cluster size as the entry size. =20 - 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. =20 =20 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 blo= ck caches in bytes =20 @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, whic= hever -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 possi= ble +or needed within the cache-size, while permitting the requested or the min= imal +refcount cache size) =20 @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=3D1M,l2-cache-size=3D64k,refcount-cache-size= =3D64k" \ -c "reopen -o cache-size=3D1M,l2-cache-size=3D2M" \ -c "reopen -o cache-size=3D1M,refcount-cache-size=3D2M" \ - -c "reopen -o l2-cache-size=3D256T" \ -c "reopen -o l2-cache-entry-size=3D33k" \ -c "reopen -o l2-cache-entry-size=3D128k" \ -c "reopen -o refcount-cache-size=3D256T" \ 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 sa= me 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 siz= e (65536) L2 cache entry size must be a power of two between 512 and the cluster siz= e (65536) Refcount cache size too big --=20 2.17.1