From patchwork Wed Sep 26 16:04:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 10616095 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 C156114BD for ; Wed, 26 Sep 2018 16:07:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD38297F5 for ; Wed, 26 Sep 2018 16:07:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEAEA2ABE9; Wed, 26 Sep 2018 16:07:11 +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.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4B1A929969 for ; Wed, 26 Sep 2018 16:07:10 +0000 (UTC) Received: from localhost ([::1]:59589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CLF-00033E-Cj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 26 Sep 2018 12:07:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CJh-0001pg-L2 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CJf-0005cB-IU for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:05:32 -0400 Received: from mail-eopbgr730130.outbound.protection.outlook.com ([40.107.73.130]:13864 helo=NAM05-DM3-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 1g5CJc-0005XJ-SO; Wed, 26 Sep 2018 12:05:30 -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=1tgq17XXYQkOUeIPQU0OxDzOJY0e2i+q0WTcEhghDoY=; b=hOKxzqLvwcBq6IdK3VCJNORAdZea2RrkGig19+At6M+kGa77Y2tsBeu3jXpL1EfP6FMVw5uWvVzbyRsfwfRL3zIc2M+0GFzdXnfJr+9tiiFLkkM/0GyE2wTHy8X2XdiCPtvvwIWp2Rmyey0fqNS55cK5kQ3zPt2VcqYUGgtBH8o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=lbloch@janustech.com; Received: from Jupiter.local (141.226.29.227) by CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 16:05:19 +0000 From: Leonid Bloch To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 19:04:39 +0300 Message-Id: <20180926160447.5149-2-lbloch@janustech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926160447.5149-1-lbloch@janustech.com> References: <20180926160447.5149-1-lbloch@janustech.com> MIME-Version: 1.0 X-Originating-IP: [141.226.29.227] X-ClientProxiedBy: HE1PR02CA0116.eurprd02.prod.outlook.com (2603:10a6:7:29::45) To CY1PR07MB2619.namprd07.prod.outlook.com (2a01:111:e400:c637::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e91f9072-59cf-4478-3f1d-08d623c9dc87 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(7021125)(8989299)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 3:Vhww8J4Lvf7Cqfv80H8r9jYTUJ/7H3oLU21x0G04t/UlImGPGkP9HvGbqvhn86hnpBshKiinOJCdwKTsCRb+iKQ6nhkXeZepceYatEtASM7iFVYxOm4QR2gDBmoYGB+yjLpxYVHBF8rt/eOQYqv21OnZF8BbL8dOut6bPqxvV5zgT8FwktRsZq8zKblTv6DqXSrNj8p7pIvGDb8rdVPy7eE742doemO3LudPebqxJmUqUBuj+AXJekTFzrKR08g2; 25:MI0EgF3GRx19wWwMESGes576o1t9PpOlbjK2xD4KB14vTUo1155UaJ7x6QHCBAA16GlO/gFrqfhJZp2PQtyhMY+RXM250aQrqWWAR0jaS0swCajSvxhhlkXrDAXMaQAxppbn+4Ep3aK4b62jrzGssPd/IP54xidkodZsLUwRwsemoyHcUAgTwXwMvUQrQk1isN2izVv+B2l1/eMVwVZL1tTLL8dxo7eVPzj58/U8tlwaEKprJCyWDbwH6u7dneJKkdb+P/g5emDklWRcTcK5OuimxN6qsWw0l/BQlNmq8Q0wRqyJWT1d/1X+icLt/vaVwhNeW8Qk9tT1deloRGCSvg==; 31:TcAMdbv9idZ19+5ZuSqSo1XefAfHbxqP64t0naIsFZTA4O5TT3XULovK0xb7xNXSJcpXH8igKSbet+BNrQeCz6EmZ5cKehMH505zXOi7pQHeKG2bzT6z6pIvEvKgqx6qy/jepHYtVCP1Xd4VNlCdyu/A5xYX9ory4Fq7TVXg4RxhknMZjReOaI58lWcovU3wHE+hRodtMLk0YgfX8o04Obg6xgnyC4mgIEhJ/PqgcEs= X-MS-TrafficTypeDiagnostic: CY1PR07MB2619: 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(2016111802025)(20161123558120)(6043046)(201708071742011)(7699051); SRVR:CY1PR07MB2619; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2619; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2619; 4:/gD5jQatPNd1r+1z1A9Ju8KrvP1bBH0P9DVHC4M/tWtnABz9jOFhR8VuX1GinFspZF6PYo2gWpTh0jChSvXVGILpovrNJqBya53X0k+mZQ+cd5spKVcV7CirROUcxIctKbbrStddkZQWFGAbNbQAzpf05e6sW1+9fNEUUn0+Cha16uXmnJeu7E3tMfm6F3gEY9rMD4tb1kAXXElbDLdWFLRb4I37lFkiZbtx9dE96baarl///k5M3doC14wWAlQ7cCerbI3E/aRIWqzYuMx9sA== X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(136003)(396003)(39830400003)(376002)(346002)(199004)(189003)(106356001)(551984002)(508600001)(66066001)(6512007)(47776003)(4326008)(48376002)(2616005)(107886003)(446003)(50466002)(956004)(11346002)(36756003)(486006)(6486002)(476003)(2351001)(105586002)(34290500001)(316002)(16586007)(14444005)(54906003)(2361001)(3846002)(6116002)(6506007)(386003)(1076002)(51416003)(52116002)(76176011)(26005)(2906002)(305945005)(8936002)(81166006)(186003)(16526019)(7736002)(8676002)(81156014)(6916009)(5660300001)(6666003)(50226002)(97736004)(25786009)(86362001)(68736007)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR07MB2619; 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; CY1PR07MB2619; 23:gY7Ss/HJUb8DPtcAttJfWWuFw329IXEWey2lFkVo4?= sFCeSieBk1q9hMGTAx7yWQBHwXkLutuOEAkIKym8eEpHa9atRbvnNO/5dsEXkfSxGHOcdKZugBEeAkA16DQnEVlKUBWcIaoPHVTblVIabtj/CQokSIc39Xt2stQYkpFiQBmphutoyaP9Zdzm5mcd2Ud2ZkdgyVQ4n1sT0C7GQ5nDUhNztTTCkBSlDt8o0IglrLnimGxr5vdy3zXmRgsKPaPPY0XjOGHdzYKbzdBuemKParcquRpDkBREZdG5EPQ2kVsQ1xK4eB0bYNoYCDFIjI6m+YmzVndMbR7/SekkJTkMl5OrVCE+6xL1Yc0r7z7LSXDj5/RA/JAygEO9oIAGDe9otii5LX2V8/J6SnxfWIAB0Cu7nIcyna9cEnEu7aofE8QPOyyDJVy4tONUxZXCjQTLi0J8IVaU0z19eM+eOSgDsnnsdgTjC77Eqm+DHOM1yyW4Or8E5f8CiginhDaJsjEzDSyWUkjzsxGROKs07iUf/bcupaq+7ERuxS6GqjonTH9ed51+RsxzjfnIagtHfnOLb/T4ozaQIHkEslPJsdnipcA3Xqqe6++cjQMfBdRLwc3JM8HRBx7Rf5rHYyKHrtmLMkUxsu6bWQUTXhs9NTIunEAG9cR0pQOFrT4buzl+VgPO+j+i5K7GOILnSeI0vAhX+YHoKN5aFfZ0xOeyTY7yB7uhFMYR44dk3MtzNG396jxw8K1k8KihBCSTOPhITFbXg5ardwjiMpQjMp6pIIYu2UWJ6DLbRQiD4z/D3hqEZbRV/bKnnjeUTe2G+98tGazv1c8Yp7LhlezeQkLOM7TWH96/njvLELi3TOQTvScfWN334pAKhuhBjBk+NtPpPBNsru80H9Z7Lt/aN18N2wN9sbklRrwc3h0Cu/uVrOm+9VffUgudnO91Ivd3EeEJK7eC77sxzPcIOTtUESv9STPPB+nh459hiUDBoHXFz7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/zqlpfmUnh63aan096xLyEqbn8fSicsF16+1hBDNuG3W+z/i2fMJWdih5CsnvMzeUP7trGTDRLwvSLDE25LFbFaK/GSiImQmKxnzceJ/7+UZqUWoEPdL2kLmgFNpEI/Bz8OrdESlsKYjJ4GuUUA==; 5:6pTsTCDoy5n1x2xmGVZJFyBkv0btE0BeXlnm510N0qRFnQmgFX2k6a+QpYivlY4MoeB8NJFwfuvxmnIH6ik9NqIPxN94kIIsNifUGUN4HV/i4nYpqXRqcWulMbg+W++HyFbgDQqfaNwMd8E//BrO6ttL2XbVp4GtAlUUTyPJ+oE=; 7:IxXBlNpb5gTfMlnrI3hpoMmVlhi58PxYlyE5HS5mVxSB0QICZkq4KT9M0CoDue8x/AMaL9jooVPQxJrRxC80mz9/4GC1Da0LIdZiIfjv05uqpGQP8ydTkt3C4bfMNjLlSTzhDMELBG0Lj6TQtVJF1GbDZnFGDnjzD/IF78MDhdvpXScPSj7lrLPi02VAKgwkbxLQMzJ/suN364cwCS8s7mYRO+GVRe5uA+ZeS4a5reknpRzBMgKt4NB8bkTH1A7K SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: janustech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:05:19.2404 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e91f9072-59cf-4478-3f1d-08d623c9dc87 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 34eb020e-3cf3-43a1-afeb-f5cf1310628e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2619 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.73.130 Subject: [Qemu-devel] [PATCH v12 1/9] qcow2: Options' documentation fixes 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 Signed-off-by: Leonid Bloch Reviewed-by: Alberto Garcia Reviewed-by: Kevin Wolf --- docs/qcow2-cache.txt | 21 ++++++++++++++------- qemu-options.hx | 9 ++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/qcow2-cache.txt b/docs/qcow2-cache.txt index 8a09a5cc5f..7e28b41bd3 100644 --- a/docs/qcow2-cache.txt +++ b/docs/qcow2-cache.txt @@ -79,14 +79,14 @@ Choosing the right cache sizes In order to choose the cache sizes we need to know how they relate to the amount of allocated space. -The amount of virtual disk that can be mapped by the L2 and refcount +The part of the virtual disk that can be mapped by the L2 and refcount caches (in bytes) is: disk_size = l2_cache_size * cluster_size / 8 disk_size = refcount_cache_size * cluster_size * 8 / refcount_bits With the default values for cluster_size (64KB) and refcount_bits -(16), that is +(16), this becomes: disk_size = l2_cache_size * 8192 disk_size = refcount_cache_size * 32768 @@ -97,12 +97,16 @@ 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 +For example, 1MB of L2 cache is needed to cover every 8 GB of the virtual +image size (given that the default cluster size is used): - 1048576 / 131072 = 8 GB of virtual disk covered by that cache - 262144 / 32768 = 8 GB + 8 GB / 8192 = 1 MB + +The refcount cache is 4 times the cluster size by default. With the default +cluster size of 64 KB, it is 256 KB (262144 bytes). This is sufficient for +8 GB of image size: + + 262144 * 32768 = 8 GB How to configure the cache sizes @@ -130,6 +134,9 @@ 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. + - At most two of "l2-cache-size", "refcount-cache-size", and "cache-size" + can be set simultaneously. + Unlike L2 tables, refcount blocks are not used during normal I/O but only during allocations and internal snapshots. In most cases they are accessed sequentially (even during random guest I/O) so increasing the diff --git a/qemu-options.hx b/qemu-options.hx index a642ad297f..2db6247eff 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -732,15 +732,18 @@ image file) @item cache-size The maximum total size of the L2 table and refcount block caches in bytes -(default: 1048576 bytes or 8 clusters, whichever is larger) +(default: the sum of l2-cache-size and refcount-cache-size) @item l2-cache-size The maximum size of the L2 table cache in bytes -(default: 4/5 of the total cache size) +(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 refcount-cache-size The maximum size of the refcount block cache in bytes -(default: 1/5 of the total cache size) +(default: 4 times the cluster size; or if cache-size is specified, the part of +it which is not used for the L2 cache) @item cache-clean-interval Clean unused entries in the L2 and refcount caches. The interval is in seconds.