From patchwork Fri Dec 30 14:31:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Butsykin X-Patchwork-Id: 9492329 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 755CA62AB9 for ; Fri, 30 Dec 2016 17:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E8F61FF1D for ; Fri, 30 Dec 2016 17:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51FFE223B2; Fri, 30 Dec 2016 17:05:15 +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 1F39F1FF1D for ; Fri, 30 Dec 2016 17:05:13 +0000 (UTC) Received: from localhost ([::1]:40786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN0cB-0007Jm-Lg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Dec 2016 12:05:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN0bh-0007Hv-5b for qemu-devel@nongnu.org; Fri, 30 Dec 2016 12:04:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN0bd-00059i-W2 for qemu-devel@nongnu.org; Fri, 30 Dec 2016 12:04:41 -0500 Received: from mail-db5eur01on0105.outbound.protection.outlook.com ([104.47.2.105]:37280 helo=EUR01-DB5-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 1cN0bd-00057r-HB; Fri, 30 Dec 2016 12:04:37 -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=LkB5uVab6wF0iU6M5Fszwk+EpYn2Px3tIvIbQ0fxPTw=; b=ZkUmC9bU8jLCTFfVzTJkdGfPWQXLjQvHxu+iujLjdg3t75KoLGuMAppP5CtnXt/Ek2KfcBETsREnVT9HG2uPbCuW8oMrSVjym19a9brGX10JKCXAwafXjTnEiuDxCwS7uDlkdgf9jF0GHxLrgIXwCFIj9DxL4fC9xVC0j3z3yTA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=pbutsykin@virtuozzo.com; Received: from pavelb-Z68P-DS3.sw.ru (195.214.232.6) by HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.11; Fri, 30 Dec 2016 14:32:02 +0000 From: Pavel Butsykin To: , Date: Fri, 30 Dec 2016 17:31:30 +0300 Message-ID: <20161230143142.18214-7-pbutsykin@virtuozzo.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161230143142.18214-1-pbutsykin@virtuozzo.com> References: <20161230143142.18214-1-pbutsykin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0802CA0010.eurprd08.prod.outlook.com (10.172.123.148) To HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) X-MS-Office365-Filtering-Correlation-Id: 4ac437ef-6ad2-4629-e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H7eunJ1SIlwvN8Rie1kDw4WalEhlhCFIsuCw/i4NrAmvkXNyY+Ui0q/vV6qwbZqtVgrkHh6pJ0C7SoooVTlEbNizEuasHrg8Erl/UgI7KuRqT1hAmAwg/LWh2povK3w==; 20:KVoAV5nsBV9qTZ8NhilzlDeHWgJ8XJMuV3SCiY/bleJNQVouz9OY8hwSxE5kvikv3F5qCOAkwMAMBxkx3ThpIHmjrJLRJbtqCUgV5DJX318970siLEBRHlTGFV1jneAyxqcmXXYWsnhpX4VBKBa3xqcdYgSeb+nRoS6hWq4dcW4tple3ru5Ghu0God488OgM/Gk+5X3CjcfvjYCK6zV1Ib1XgyvVEcsRiPdqROSaMAPEZT2+b3X7Q3aIcWhfiPC9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123558021)(20161123560025)(6072148); SRVR:HE1PR0802MB2555; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2555; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 4:A+KMSD/ySY9nYpQWm+YXsuV/ztSpLA6He6D7ZvIHiy8+3uQVgc0f7PuJYbZ5aOYEIxCtgzosHqaJxI7K496XuOlna2IlbzEWbLjWzDuqUIoAeD8YBE2kJe7svBVC8QaXHMExfKo1B+6LOtSRXvwSeK161D+TJYiCVl+7gttTEJvtTrpIJdVf12NbJS+bLDFS0QHJs4Adysz/W7FcM3rzXNP0otm9NpB11Hbu/hrmJqa3AZZDg8IJ9x9zOoXOTw5N15YXEPpcJstJFNw4zULRHFCiaDlR1Is55tq28Y4R3THweIGL/35LaFRUGozWIFWAzUJapxnCkytHeq3XIncQhykKLTEaCZuvuZ113jm2VZkx8SgMR42jCYzvLUssmh4HlgbMkXTxEoJFw8Keu/nGLIj0tb8ERYCERqNtQn3EOwV7D0mzE8XV4hLoDtqA4xa8GDyuKmlTknmWWPR9TerrATLRZ61wiEU7RzuUb6ZtchOf1+JEc86W/wnYBtOuDltu+6gC1/BQQDjzZmmGOJOd6B4/1TKOXlabQ7YkTwHfTNCMJqK3C+pBqEZiZDQpGVvNGveuQyo85XpuwLHAvOH7szuc6P2ch17BSP1IiyPEXXg= X-Forefront-PRVS: 0172F0EF77 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(199003)(189002)(6666003)(5660300001)(189998001)(5001770100001)(50226002)(81156014)(81166006)(5003940100001)(8676002)(97736004)(47776003)(66066001)(6486002)(36756003)(6116002)(3846002)(76176999)(105586002)(33646002)(92566002)(305945005)(38730400001)(50466002)(106356001)(50986999)(1076002)(6506006)(6512006)(69596002)(4326007)(2950100002)(25786008)(2906002)(7736002)(68736007)(53416004)(42186005)(48376002)(101416001)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2555; 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; HE1PR0802MB2555; 23:dEw+xtNYgz4OUrhlu5sdme7PeHzbSepuxdXumcs?= =?us-ascii?Q?MmbHkbGd5H1LME7DsEzmi+p6xHb66YJlVDDGpUD2XrN0TIU85CoTLVAJwwPA?= =?us-ascii?Q?yoSLXQZNf+hnpXFIjERJMSedMRf/ORB+U7KdDXsNrntLqf81dJh2ISTWVX9g?= =?us-ascii?Q?OrIYycAaI/vaSLf0+kz1tivlKOchMUqnwpjLaZdeTC4qSLMJ+ltu+/baJYvS?= =?us-ascii?Q?BQNeXLxmtgFi8fkrWjf0D2qvhjiaLDR/WisAPDfdcIghVtzzC/12siryrS1q?= =?us-ascii?Q?2QbnWTq0X6IwJlaXzXRLh8MB1pxDPA4qw/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lu842NkPiWXfVhimuXdxa7eQe8yZmPBNEZiCqYYZmvMsERzQjDB24jlcIR32x6WSCSwH2depuIYRa4z5xRqVJI7wpI294EQ3ezBfszhmAjDYg6MtkUrdo+iExR5VTVqmPxOciHBsUoOMnJq7NkE2PcFQ==; 20:OmIMs/LraoC2211BTt/hBvX60fi4v0npwVa0g2k1Br/X7WigAvqOB0623PsZed44ZLsrmdjy1WbvhLpyGalaPf20iRpRlty9RBeI8158fHlVX2Z7ftql4rLQ5JewqtDL1QXNgqzsA++YOyhEjyTCGUiNeeBAV2ioeQ52esIcwfY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2016 14:32:02.1664 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2555 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.105 Subject: [Qemu-devel] [PATCH v2 06/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, den@openvz.org, armbru@redhat.com, mreitz@redhat.com 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. 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 296ae382b0..1f3200af63 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", @@ -26,15 +27,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; static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset, @@ -43,7 +52,9 @@ static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset, { BDRVPCacheState *s = bs->opaque; - rbcache_search_and_insert(s->req_stats, offset, bytes); + if (s->max_aio_size >= bytes) { + rbcache_search_and_insert(s->req_stats, offset, bytes); + } return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); } @@ -60,6 +71,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,