From patchwork Tue Nov 15 06:37:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9429081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12D4360469 for ; Tue, 15 Nov 2016 07:12:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB882289F4 for ; Tue, 15 Nov 2016 07:12:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCD8228A98; Tue, 15 Nov 2016 07:12:46 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 07F94289F4 for ; Tue, 15 Nov 2016 07:12:45 +0000 (UTC) Received: from localhost ([::1]:44612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6XvA-0000KL-Hi for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Nov 2016 02:12:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6Xuo-0000K3-JZ for qemu-devel@nongnu.org; Tue, 15 Nov 2016 02:12:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6Xul-0000ms-NU for qemu-devel@nongnu.org; Tue, 15 Nov 2016 02:12:22 -0500 Received: from mail-ve1eur01on0092.outbound.protection.outlook.com ([104.47.1.92]:25052 helo=EUR01-VE1-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 1c6Xul-0000mC-Gl; Tue, 15 Nov 2016 02:12:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=25H9zR37YDjqFdgEverDkY9wLQqhfB0nl2u21yRl5J0=; b=G4fz8Cg4GmAhzmatrWsoUzhseQe89r8RCZCpJN4i76A9a9/IOzqPGA6Ac5r98XpSrWdliP0K52orUNlrox9D0LXKpLh4d2P5tntbjBcOZ74Qz0yZ8x06cfeuPpA3W9RLP/LIUCI4bq9GZ2L44wTp42dFMiT/66B8wOKMHBAoTjI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.10) by VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.721.10; Tue, 15 Nov 2016 06:38:19 +0000 From: Pavel Butsykin To: , Date: Tue, 15 Nov 2016 09:37:04 +0300 Message-ID: <20161115063715.12561-8-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161115063715.12561-1-pbutsykin@virtuozzo.com> References: <20161115063715.12561-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM5PR0101CA0010.eurprd01.prod.exchangelabs.com (10.169.240.20) To VI1PR0802MB2558.eurprd08.prod.outlook.com (10.172.255.136) X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 2:c7UdiwJsEBoP+7FL7I4FkAEdoFbEKUiJNoOjlP/8mIKMJes4RYJIYs8hSscmn70++tmo8Wuumhc8fQPBmOCtcVZ8pvXpYBBvj6x69UeZ9umvlDbVYOmpRCAMS+bbvWpo4jVTWBrhiWOXZX5YkzuCcQFmIiOMkpMWf+vvZJcU4Po=; 3:0RKgoVs0Rqcr5fi8yXJTzD4FOKeWJmkIA9nJB4QrF6TcpcVvb4ExU1uXO22IiXrLED4yNUrUy4FjCwD5J4bk3ehW0YTYm0ULBbEohDZ0HP31bZ9oCmNjrilRFPDBwMiMxHFH3Ly49Pxi9LMXioFCa5prVjqh/KGvPExID6rA5bw= X-MS-Office365-Filtering-Correlation-Id: ac214d0e-4c92-4990-b847-08d40d21fd29 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0802MB2558; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 25:gUCmQn82XyLYJ9yPNzaOe+nBaR56Vre6tL0QbU11dsk6M7phApwZoF5tPMqr2A4IcgHO/if4ziLJgIEIjkrZwCCYyR0zqRjQcmPaM11vhU/jjUI9GP6Nx480FpsWSi4fF4iS75QGKpKCQ61c5+CBAiBIvKDkmThfYeH+bXCPntS0F+dig1A4GZlyKQwQFekgfdXtMDwIQzjlGr7If/25uqjDO6UUBPbf5SJJjHh46XZe687digQCyxUMhDHyDKHjiqtb0MWGy0sQMUzi6HDiX/iM/JusD0m8zm5wvwtXIxNAX7pz8uv48D9u6Jl02WrWWHK+7pGSZwtFpW9M3lrc5rri0HnwGc2msBv1iFZyqoj96g8q/q5zmGIuGLUB7lBJ9DBgxjxYcd8josdCvSKU6sBiz3uHD6nc/bxjhn/1lydsP9ILB60NRWms+oC4Pu0jB+e0fTvXUtl7eKOh55YIVseBh5LViaUXfmBGVmfYV25MXJYkrjbXHXa+ed05tG62CeRe6E2qZIBzib+DHg1OB8S2YeTw8Wb/viADhVyq7+vgFioEKUhUiPV3Rpsp92p5QKzZTFLw6I//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XlGB6bP30Z5qMDg1+U3iWLGJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6061324)(6043046); SRVR:VI1PR0802MB2558; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2558; X-Forefront-PRVS: 012792EC17 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(47776003)(105586002)(101416001)(1076002)(68736007)(106356001)(6666003)(76176999)(305945005)(4326007)(97736004)(66066001)(53416004)(189998001)(42186005)(69596002)(2906002)(7736002)(5001770100001)(7846002)(86362001)(48376002)(50226002)(2950100002)(50466002)(50986999)(5003940100001)(33646002)(77096005)(81156014)(8676002)(92566002)(81166006)(3846002)(36756003)(6116002)(5660300001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2558; H:pavelb-Z68P-DS3.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0802MB2558; 23:DjMWsNd0J4EYS8NVrFfHop69mJ7pVclNi3VKyP3?= =?us-ascii?Q?gqg7cSNzYkQZ+CYuaFDaWZjZk+5btRKKnMpct9Q5xxFfCpnMmE57eSzlPFqy?= =?us-ascii?Q?UaUtna3vE17q3Ig0k+E3bFhlUq3SPczlb74WScS+0ZC1KmZCT8JDEpR5NO2i?= =?us-ascii?Q?fnEK5BhOaRY2jjcje8A6zVOw0WFYKHojLSTv09943sDc5U92LlsY/C6IOErU?= =?us-ascii?Q?2IpdkY1vHawpuVtbLCY7L1edsFEFgqhilDo7CTbcaYw33n9qqnNCNUeKyAHE?= =?us-ascii?Q?BqIoEPCr7K2hbs40DWNf1UHWY90f5rDt8uLTuk4Lnl/22e+fUuiOhi9G7mPN?= =?us-ascii?Q?g3reA2pjHWFRXzL4IOnJfAMlaK9SlxRyebw+OSjlcVQJNgWecvkjPV+VGWtz?= =?us-ascii?Q?iyEwH7MaQTaGYb7I1rBJ3Aag4inax6T59zUMey9XW4h3WGkUjzfD+ZDrDcpC?= =?us-ascii?Q?lRXBBmZjUOwyJOXvKl3m21T7u8EoKvXZc81bC0kexak37UvMNOcDZwxC1eAQ?= =?us-ascii?Q?/cuA2TMXKjij5MgaptemfEhqLLox7gy/GlMaSbSEV+xnK+RLp0SBSe4hwOuY?= =?us-ascii?Q?6ed8K/EnGirh3ZYwgGKkNc+7ahMbptt0GQXyh9mWnjGLspkUDZb7NgUuDGxA?= =?us-ascii?Q?lbjMKRs3E0u+Z7M8ztblIVSAAiiyzot4r3Gtevxb+nrUdzs2ex2Ri7/qb+R7?= =?us-ascii?Q?sbAZ01Q9jeXsgNyrcvYSD/kxmasauGqlswRBNiCnIwsA1PJt6e9IM/AUEjHu?= =?us-ascii?Q?0wPLAHe8DtUaAVAgqe0Nx/qbHK7G2VOYn8SJs2IfQhJDj5TKGcnijlPaIpdn?= =?us-ascii?Q?AzUv21Zl4eTatiqyV0p7sp35Y0sbyaGJQcuX/a6Zj+xc8qgZWtGYXwVBsi2E?= =?us-ascii?Q?d1yzqHkBHNVE9wVRPo7taU0rYIG/Luslr6LRyRZ4UxbfPy7Y0G1MGAFICDss?= =?us-ascii?Q?Tybcb310530609S7ZgAqWYFl6cXuNObg65A25qMgoziDsDCaH5B0giD2g39I?= =?us-ascii?Q?55yJAUvihlkytWLFgm0HkKnOXHL0gSHXf37lh41hQdNmCOGsTI9s88sMnhM0?= =?us-ascii?Q?8ECnDzwB3igI58Y5pVeNolyES9TQr?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2558; 6:t+hIB4/sybce4cpiQxVNcnStc4MNXE8hk27VondJJnJKYFrDQU9T3g1f8NitWYjfkJbSgpiDEpnLXdjqoCMqAWXIu9V8rak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q1qnIjYUzzJd9sH0mWXIGJqXxlZTHB4MliRs3DQ2jCxo2Mz0d5eV4/VVB4O5eD1vfvk4SPxwrl2FyrHA9Pk+N+W7fuQ6IzOc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2016 06:38:19.1148 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2558 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.1.92 Subject: [Qemu-devel] [PATCH v1 07/18] block/pcache: skip large aio read 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: kwolf@redhat.com, famz@redhat.com, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This change will allow more efficient use of cache memory and filter the case for which the pcache isn't efficient. We skip requests that are not required in the optimization and thereby reducing the number of unnecessary readaheads. Add pcache-max-aio-size open parameter. Signed-off-by: Pavel Butsykin --- block/pcache.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/block/pcache.c b/block/pcache.c index 60b1f93..bfc7e97 100644 --- a/block/pcache.c +++ b/block/pcache.c @@ -16,6 +16,7 @@ #include "qemu/rbcache.h" #define PCACHE_OPT_STATS_SIZE "pcache-stats-size" +#define PCACHE_OPT_MAX_AIO_SIZE "pcache-max-aio-size" static QemuOptsList runtime_opts = { .name = "pcache", @@ -31,15 +32,23 @@ static QemuOptsList runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Total volume of requests for statistics", }, + { + .name = PCACHE_OPT_MAX_AIO_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Maximum size of aio which is handled by pcache", + }, { /* end of list */ } }, }; +#define KB_BITS 10 #define MB_BITS 20 #define PCACHE_DEFAULT_STATS_SIZE (3 << MB_BITS) +#define PCACHE_DEFAULT_MAX_AIO_SIZE (64 << KB_BITS) typedef struct BDRVPCacheState { RBCache *req_stats; + uint64_t max_aio_size; } BDRVPCacheState; typedef struct PCacheAIOCB { @@ -64,7 +73,9 @@ static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset, .co = qemu_coroutine_self(), }; - rbcache_search_and_insert(s->req_stats, offset, bytes); + if (s->max_aio_size >= bytes) { + rbcache_search_and_insert(s->req_stats, offset, bytes); + } bdrv_aio_preadv(bs->file, offset, qiov, bytes, pcache_aio_cb, &acb); @@ -93,6 +104,9 @@ static void pcache_state_init(QemuOpts *opts, BDRVPCacheState *s) uint64_t stats_size = qemu_opt_get_size(opts, PCACHE_OPT_STATS_SIZE, PCACHE_DEFAULT_STATS_SIZE); s->req_stats = rbcache_create(NULL, NULL, stats_size, RBCACHE_FIFO, s); + + s->max_aio_size = qemu_opt_get_size(opts, PCACHE_OPT_MAX_AIO_SIZE, + PCACHE_DEFAULT_MAX_AIO_SIZE); } static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags,