From patchwork Wed May 15 01:23:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13664514 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E025C04FFE for ; Wed, 15 May 2024 01:25:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DB1B8D0059; Tue, 14 May 2024 21:25:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08BB08D004F; Tue, 14 May 2024 21:25:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E95548D0059; Tue, 14 May 2024 21:25:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CA1418D004F for ; Tue, 14 May 2024 21:25:09 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 812EB140893 for ; Wed, 15 May 2024 01:25:09 +0000 (UTC) X-FDA: 82118886738.04.1DDD980 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf15.hostedemail.com (Postfix) with ESMTP id BBCC5A0002 for ; Wed, 15 May 2024 01:25:05 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715736307; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oiG4O2hCRGEcQ6a9VnNAx6PGi18rQEH1MASbp3fUJb4=; b=DAoyOg1ejBQez/PpMRBm9/l8a+6miY8xdcojxCiG0MXDRaStK91t9dNo0eFKgrWeTb0VRw 0dJgAVWAEFPmw+keplBkvIK/NXWx5u2WGOFk56TP6L8afbsLrdXd+DTyNLdibfbTIDLIl7 rOwlrzboYLqKE8L8etssnKeOhgP1X+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715736307; a=rsa-sha256; cv=none; b=oT2tHp/UqmFLaGFA+b0i1OGFpooBETL1wt93PmjslaXLCpU1LPNjLYwLk7sBDyG9u7mJST Hv0l2nc9nsC25sm4UL4qckiPVZwCR5K9eEen+f/8cjcBWjhJ27iIljJ7p1SX8ciZMWatZQ a7wS8SVQJlfRq7WCenWUlxcWaJ2/Ywc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 44F1O5Om051360; Wed, 15 May 2024 09:24:05 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4VfFly3fXQz2QDRDk; Wed, 15 May 2024 09:20:46 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 15 May 2024 09:24:03 +0800 From: "zhaoyang.huang" To: Andrew Morton , Matthew Wilcox , Jens Axboe , Tejun Heo , Josef Bacik , Baolin Wang , , , , , Zhaoyang Huang , Subject: [RFC PATCH 1/2] block: introduce helper function to calculate bps budgt Date: Wed, 15 May 2024 09:23:49 +0800 Message-ID: <20240515012350.1166350-2-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240515012350.1166350-1-zhaoyang.huang@unisoc.com> References: <20240515012350.1166350-1-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 44F1O5Om051360 X-Rspam-User: X-Stat-Signature: hoq68k1qrjej9u8opaz7oknye5s51u7o X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BBCC5A0002 X-HE-Tag: 1715736305-142926 X-HE-Meta: U2FsdGVkX1/Nx1CyKLDY5Hx8KOw8/RjBbgsMv3SDZK35fLxqktAziWQGIjSUd5IN/b0vsFbwn0JwZLNNUcjgE2UHP3AwiCiequGouBX/8cZWLgx4ix21Vi2OEdHFeC7NnxwwUZZBXUvqim4eyBy3Wnx2cINj9ctje2OT/rhEoJgdlbdh+iTJtIfEDVEZA4c/4SmrIZT4rDc9p3gExAqA7wyEN3ubf9T+eUE8EKqtqAtOGbp6HG6m0mTuYkGHTBsS9dEfESyg72YzXC3dGLy5lRddpu9Qx75bbgSTBVHLu9R3eZbtHM3LNnnwZ4dmJEixbVtODswwd6jYrnKwTMf52j1om1Huoi7X2FUK5QCAHREK8DBHVx1jMuOoMzHWKSxPbwWoSxR9IxxwNPBo3jq65J4P7W+K+zZ3LiXOclMw8MPRCdcWSdcRYILCk68SYnO0YxwZwgOM61DIsO8ym84Y0aoMOCA7VGd5ssgZWiHGSHZOr1vEDHsQnGZoE8ZsR7qZcAgK3UxZJfD3b2FIipLzDgRHadKhQ/MCeJiCEnDOoU9PYX1EVg5VqK9wXrcXy+ojbR86Pn4V2zz8WLcJTB+yZdYAHLFvmeTmQSUYgza2uI5h2JkSntWzCyC1NYd8pRin0X4rg3cYHm6d4kZkbOnCw0V26/wN/U1NGwJ1A7s1TeqwjLSObGZYMTVoQO1awHrGOW+Xv8rB1T8x7qlem29JBr9J2iVsdYO3ru+K7ItJ1aunw51rybleZY7pD+vpqFeQiqBw9gQUC3CecExKMhQHIsiwUSQO8dcRpajd6g0FshR8yXar4iB24tAmfGSPbKvaHzJuHqzim/usd8wUk4eNJMpXcDLjIbkUHzqz5OfyHN/GfeDOKy2TwJnpB0sE10sNP54omtvlK0/Is2kwJttC112DNZL6qWjlG6h9Xw5Xb5Y45DsQOaL6SrS5zHqPTzqff3GsOviR4TS77N6gVj9 hBssyqtM 8njB2cwF9Yyc8zMf2LkIvrPvVXyWnapwfiWsMDRXATMPDIXkXdRlbjvVUjBbw4x8vRuzxcXLI9LhLT9D1VuPHI0o6KaJkKZ0HsxT5x9NtTWCfam5pWPO56hFDGsOlboGxz0+hsARdDjUM5pix7FNORTac/TjQWGQGyaNS/7TkuigR2/GBatEI+3l0zJYRkUYaI5DlxJu+IfNU9/CgviIJ8hCGoLwcTENm6KxrDQI8t/xNJ5A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhaoyang Huang The 'over-sized' bio under blk throttle control will be delayed to launch which breaks original IO timing and have the immediate BW be not within the bps limit. Introduce a helper function to calculate block device's budgt which provide the allowed bytes for current bio. Signed-off-by: Zhaoyang Huang --- block/blk-throttle.c | 44 ++++++++++++++++++++++++++++++++++++++ include/linux/blk-cgroup.h | 10 +++++++++ 2 files changed, 54 insertions(+) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index f4850a6f860b..41c75258183d 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "blk.h" #include "blk-cgroup-rwstat.h" #include "blk-stat.h" @@ -2365,6 +2366,49 @@ void blk_throtl_bio_endio(struct bio *bio) } #endif +unsigned long blk_throttle_budgt(struct block_device *bdev) +{ + struct request_queue *q = bdev_get_queue(bdev); + struct blkcg *blkcg; + struct blkcg_gq *blkg; + struct throtl_grp *tg; + long long bytes_allowed = 0; + unsigned long jiffy_elapsed, jiffy_elapsed_rnd; + u64 bps_limit; + + if (!q) + return U64_MAX; + + rcu_read_lock(); + spin_lock_irq(&q->queue_lock); + blkcg = css_to_blkcg(task_css(current, io_cgrp_id)); + if (!blkcg) + goto out; + + blkg = blkg_lookup(blkcg, q); + if (!blkg || !blkg_tryget(blkg)) + goto out; + + tg = blkg_to_tg(blkg); + bps_limit = tg_bps_limit(tg, READ); + if (bps_limit == U64_MAX) + goto out; + + jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[READ]; + if (!jiffy_elapsed) + jiffy_elapsed_rnd = tg->td->throtl_slice; + + jiffy_elapsed_rnd = roundup(jiffy_elapsed_rnd, tg->td->throtl_slice); + bytes_allowed = calculate_bytes_allowed(bps_limit, jiffy_elapsed_rnd) + + tg->carryover_bytes[READ]; + blkg_put(blkg); +out: + spin_unlock_irq(&q->queue_lock); + rcu_read_unlock(); + return bytes_allowed; +} + + int blk_throtl_init(struct gendisk *disk) { struct request_queue *q = disk->queue; diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index dd5841a42c33..ba79fa464e0a 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -15,10 +15,12 @@ */ #include +#include struct bio; struct cgroup_subsys_state; struct gendisk; +struct block_device; #define FC_APPID_LEN 129 @@ -45,6 +47,14 @@ static inline struct cgroup_subsys_state *bio_blkcg_css(struct bio *bio) } #endif /* CONFIG_BLK_CGROUP */ +#ifdef CONFIG_BLK_DEV_THROTTLING +unsigned long blk_throttle_budgt(struct block_device *bdev); +#else +static inline unsigned long blk_throttle_budgt(struct block_device *bdev) +{ + return U64_MAX; +} +#endif int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len); char *blkcg_get_fc_appid(struct bio *bio); From patchwork Wed May 15 01:23:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13664515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1B35C41513 for ; Wed, 15 May 2024 01:25:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2898C8D005B; Tue, 14 May 2024 21:25:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26D458D005A; Tue, 14 May 2024 21:25:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 101AE8D005A; Tue, 14 May 2024 21:25:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E90968D004F for ; Tue, 14 May 2024 21:25:10 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 77CE88028F for ; Wed, 15 May 2024 01:25:09 +0000 (UTC) X-FDA: 82118886738.06.A521A7A Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf26.hostedemail.com (Postfix) with ESMTP id A5494140008 for ; Wed, 15 May 2024 01:25:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf26.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715736307; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=byEvaHsYWbx9jsAJ3lZFFRsCWbGZ8O9IdN+pwgQo25o=; b=i0frCZkHyxBSvVEB3QGg2MTVk2XMs7reX9ZL2vTBL8ZsKGBVrtxVhwWlG8zUfWAv6duj06 Wtgs+UvmnCLR+pBmG74/ixrIt9OARJRElDMIzNp3o+rr95JY+m37L0w8zu0Vyr5OJJm8z0 pdGwDQAk5BvKtGaXMlpa8SfVh+6IGik= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715736307; a=rsa-sha256; cv=none; b=L+xnUTDRau1PtSLfa+CS3oSpElGZ10Au3EXjDRp2YkTyOQZ1a7MamoAG2HmFvf32F/WOXg F/KvC4FaEyGEiqwLOv6g9vt5bbEgs0ajKJP9SrgB+rJ8fFZWs7pSemvYYua2/cNlXN6gEd myVVsr/r70JTZpfQfA3dNDQ3DCnjl7Q= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf26.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 44F1O7LZ051706; Wed, 15 May 2024 09:24:07 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4VfFm04QmWz2PDtZH; Wed, 15 May 2024 09:20:48 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 15 May 2024 09:24:05 +0800 From: "zhaoyang.huang" To: Andrew Morton , Matthew Wilcox , Jens Axboe , Tejun Heo , Josef Bacik , Baolin Wang , , , , , Zhaoyang Huang , Subject: [RFC PATCH 2/2] mm: introduce budgt control in readahead Date: Wed, 15 May 2024 09:23:50 +0800 Message-ID: <20240515012350.1166350-3-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240515012350.1166350-1-zhaoyang.huang@unisoc.com> References: <20240515012350.1166350-1-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 44F1O7LZ051706 X-Stat-Signature: zrbwr3ugmtbsx7p64oo5k139yxf754eh X-Rspamd-Queue-Id: A5494140008 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1715736306-417092 X-HE-Meta: U2FsdGVkX19fcdzqj9LbX7ZPO1L9upkpY8lHfZcs3pUOSp7LaG4zTqJxXkQHFrbvim5Khe+oYsC2Nzu2mew3tH0844dQRra3ZPCXwAlSFMJBd5tSF/v5Dtb4AVoj2R9yuXtv2yv0D16BJnsLl+qL9dzVpRo2QSeg2VskKlw3F7snaltwUCMhhIvhDU69nWwintXfjgSWqjtEa5oKCEiUbiLfx7usP/ojAXuslZQ+KaeOew5Ad2JJJ5Buw9OEvzYphITD6KkAoiGtwircyBK9kICgTsalm6knInUG9tQj+PVh/ljcwEt9WuhHYvEJ/kbxXMFZw+LuhjP2N5W5unKWjIqThqfeL5wrsqmUDqOMQes2wv0xsoWujK+fvKgxufWwjsxVNa/HfoGW20KtyWjQTPIrkWfNMtYqpnPLg9sfUhZPe/8rWEq+u8ni5avJFrfeJ7g9+RufU2paKf5iKb6aXwfLLz9PlYEOAZSOc4nnlJEn+agTeJ1BDzvUcoyhQ6s44/XJIAIYuT1kPYBzgXzhJWvgRxlWWq/PxaGD51+C8AdEWFadiL1Dxpd4iyxV5cDF4N1ZKoc04PYPAB1CMxRyDu667nardAjglHQGPXJa7/V0VvMuFzTlOL0uPsIk9tmZn6ndQIYNISnvoxo8xRhfHnj1Ct88yaVLMcssEC+tShuzsiaTDQq6BsfqNDGqI2SXX03b3x+75ZPcZoHZqr12LmzjCoocqPrF06qRActo6IY8UHBDpu8rFZ+P2GeQcm//xoLjECElYMslNIIv+999DnHLUHXOUokcVD3NpDF13alqgeqiOvbwYYtubvWX0rf4y8lMIdXOcyIl2Nr3eGWDv7tb8o8ahQ5ucYCf7lRpsdLzkM5vBHQLU1GJMdbgDT4RUAZv8CpF2c6XNtJTlvd31/FEFQPCqhMoAVkZD/eJNzKnlqrgbVpMimCXlpjRA1GZtNewUoY7yQQ5yIZ/95P tp3bOsNZ sGynN2eHUCKR8hZTgd9rJh2rcLIMs0ccLZXYV7oB3N+W1yCWmvgkamMJ2GHwzXBl+NMlqlLds7VAfpT1Q74dcJhtStVT9qLlkUC0LLGYszYVsqw1CyXu5VDS1inZD0wkkHb9AmCgPrztYzs76Z4FRkqGCbhDsU+EZeib1fKf/UPtFcK9kaaUafgPJW+WzFJ0JE38dnvSqBSs7Gos= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhaoyang Huang Currently, readahead's size is decided mainly by page cache's status like hit/miss or hole size which could lead to suspension of following bio which is over the size of blk-throttle allowed size when BLK_THROTTLING is on. Introduce the budgt value here to have the bio's size be within the legal size. Signed-off-by: Zhaoyang Huang --- mm/readahead.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 130c0e7df99f..2b6120ced6f9 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -128,6 +128,7 @@ #include #include #include +#include #include "internal.h" @@ -358,16 +359,23 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) * Get the previous window size, ramp it up, and * return it as the new window size. */ -static unsigned long get_next_ra_size(struct file_ra_state *ra, +static unsigned long get_next_ra_size(struct readahead_control *ractl, unsigned long max) { - unsigned long cur = ra->size; + unsigned long cur = ractl->ra->size; + struct inode *inode = ractl->mapping->host; + unsigned long budgt = inode->i_sb->s_bdev ? + blk_throttle_budgt(inode->i_sb->s_bdev) : 0; + unsigned long val = max; if (cur < max / 16) - return 4 * cur; + val = 4 * cur; if (cur <= max / 2) - return 2 * cur; - return max; + val = 2 * cur; + + val = budgt ? min(budgt / PAGE_SIZE, val) : val; + + return val; } /* @@ -437,6 +445,8 @@ static int try_context_readahead(struct address_space *mapping, unsigned long max) { pgoff_t size; + unsigned long budgt = mapping->host->i_sb->s_bdev ? + blk_throttle_budgt(mapping->host->i_sb->s_bdev) : 0; size = count_history_pages(mapping, index, max); @@ -455,7 +465,7 @@ static int try_context_readahead(struct address_space *mapping, size *= 2; ra->start = index; - ra->size = min(size + req_size, max); + ra->size = min3(budgt / PAGE_SIZE, size + req_size, max); ra->async_size = 1; return 1; @@ -552,6 +562,8 @@ static void ondemand_readahead(struct readahead_control *ractl, pgoff_t index = readahead_index(ractl); pgoff_t expected, prev_index; unsigned int order = folio ? folio_order(folio) : 0; + unsigned long budgt = ractl->mapping->host->i_sb->s_bdev ? + blk_throttle_budgt(ractl->mapping->host->i_sb->s_bdev) : 0; /* * If the request exceeds the readahead window, allow the read to @@ -574,7 +586,7 @@ static void ondemand_readahead(struct readahead_control *ractl, 1UL << order); if (index == expected || index == (ra->start + ra->size)) { ra->start += ra->size; - ra->size = get_next_ra_size(ra, max_pages); + ra->size = get_next_ra_size(ractl, max_pages); ra->async_size = ra->size; goto readit; } @@ -599,7 +611,7 @@ static void ondemand_readahead(struct readahead_control *ractl, ra->start = start; ra->size = start - index; /* old async_size */ ra->size += req_size; - ra->size = get_next_ra_size(ra, max_pages); + ra->size = get_next_ra_size(ractl, max_pages); ra->async_size = ra->size; goto readit; } @@ -631,6 +643,9 @@ static void ondemand_readahead(struct readahead_control *ractl, * standalone, small random read * Read as is, and do not pollute the readahead state. */ + if (budgt) + req_size = min(budgt / PAGE_SIZE, req_size); + do_page_cache_ra(ractl, req_size, 0); return; @@ -647,7 +662,7 @@ static void ondemand_readahead(struct readahead_control *ractl, * Take care of maximum IO pages as above. */ if (index == ra->start && ra->size == ra->async_size) { - add_pages = get_next_ra_size(ra, max_pages); + add_pages = get_next_ra_size(ractl, max_pages); if (ra->size + add_pages <= max_pages) { ra->async_size = add_pages; ra->size += add_pages;