From patchwork Thu May 9 02:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13659394 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 EAC42C04FFE for ; Thu, 9 May 2024 02:41:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7716F6B0092; Wed, 8 May 2024 22:41:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70E896B0099; Wed, 8 May 2024 22:41:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 201976B0092; Wed, 8 May 2024 22:41:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CB0D36B0092 for ; Wed, 8 May 2024 22:41:21 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4D87B40734 for ; Thu, 9 May 2024 02:41:21 +0000 (UTC) X-FDA: 82097305962.03.3FF8794 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf08.hostedemail.com (Postfix) with ESMTP id 7A764160008 for ; Thu, 9 May 2024 02:41:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.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=1715222479; 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=1WyvHSiqabMlbweH3imD+/02JF/KI4ibApi/mz4PwysQ9jpjpDw67hDOF5XMqXVMzYBsHc SgonsONAdy6odbLDiLOzFo1Yu/7PpgX/OTXOQxWjV+m19/bbSrcGdFr7Qv4NwUyzoBA3It eMOLdFgDEbyvoW7/4T2HAxp9HAoxGkA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715222479; a=rsa-sha256; cv=none; b=a0o/tDCkYR5kF5QNPY3cb+bbM7mHKGUD9MxyMjrYSx/irLo9ECaoNaf/lRjjJ4dXhxRn4r VDK6B1Hxb/YSxn656unDfcGmIZrCRnqYkZROkl+A9qDP52QY8wjrVDqibBBi9W75wDCB3c RHjHSHDSe/lHwhHBkDUDjs7eEm84yww= Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4492dk5p051858; Thu, 9 May 2024 10:39:46 +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 4VZbkH4hbGz2PGl6X; Thu, 9 May 2024 10:36:39 +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; Thu, 9 May 2024 10:39:43 +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: Thu, 9 May 2024 10:39:36 +0800 Message-ID: <20240509023937.1090421-2-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240509023937.1090421-1-zhaoyang.huang@unisoc.com> References: <20240509023937.1090421-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 4492dk5p051858 X-Rspamd-Queue-Id: 7A764160008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 3gkknm9rehmwtu8zgwdmmnsidy3fc1xf X-HE-Tag: 1715222478-636296 X-HE-Meta: U2FsdGVkX1/mGnXkGSqP2bCFW7/7vU8D7wNHqI9R8FqJcBPTirzXwwKvkfCWuCtydFVtdiRfggnPF6zK8BXcKEpNxeT/+LjSYg71s5CHyROJx+Wp7XJ2d3l80UMN8L3oCuotuFp1YcNieiw9VrBbLLAKwwVv26EO1fz3KM3/oHMdqoxgYvaJ4xLP1CTiacfADfTklQICEr7kHqy79aXGIiBxa8t+UDYOtDKGuKReBSwGb+hHl7WGEwvDeKXN8ru/CAZ3jIVUuqWGJLAV5mGth36KeDskVgfi6Q3qLmStoLHxIyEoP0uA8LmWjgyQQ0R2TSrrll4z6EmbnTQpZngSkAhNPHzN7/gwQ8QZUaGvlPr9pM11AnMt3CSjt9ECf/0VnirONOjhvicUGSa57JTEj+3IMC+R5NDIE79Zbl2/LYa2Ph0pzqo4OT4ryUwWCinD3CZGlQVJVEHRKEZ7lj6duie2EzUQontGwx1EjkzII3OyWE+SnHj8CtikpPWPFuxtpjI5M2zCR5C/hoV71VCsfuDdk4aewejTIbwJgUE9UB0n2dnGXPa+JPP/7NHPGESKQsU8l70FQiO01Aak5bVvWXrpe+usAh7RFRU2yW2N3+9L1YoLDBDcxlnyC233cj+VGQTQwKp+0jRjqCApFkdQQoFSphZnj96AGdv8Nymenkwog84CHcJUaP1Dg5fxOPxxaXRMwc3Swas+tXtrsmN6sDQOuJBEplT5/MVhK1ZAlHMmx6P5O02UeAK2IZco9U/ldKGy9EvWK4GQLoz1b2u9H4YPUtiHQLm1NmUNc1nroQFYgjfWGztrjiVmUGIhv+27OO9rQ+eRnoVecUiFO8qEOGWbf5cIggWh/NHl1bqe+sbIxLsQCsXRC85wcZC1Kwq5ltgHsrNX37ucGNcIR7NwpyssrPkxSNW8NALAGR4Sr5P3aJ2CPLzPGB2zxsZvv+wQK5kJBnRCoe3TlpG+QxH k2mhA2HL y+uG31iGEylKR72YUnUROEhpajJxA7mNiRHsnbSPRWgm4AqJJ3gNC08GAW8zY/4+n5FJzsuIUhwWNrgJl+69liuL6ZvbY3NVHITS1mJuc3/vGgpvvPu2r9AW/2axWKwKhezAKoSnQ952KtKPQ4V92TNaVH7Y1ZVC3ZDaT3UEFPGm7N4SFcOdZX+ToB0A9pKgtUVlHWRve2D+0vO0LgvFkQje2KmC+9+ZSdijMaedHrMYl5KY= 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 Thu May 9 02:39:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13659393 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 9A76CC25B4F for ; Thu, 9 May 2024 02:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E94B6B0096; Wed, 8 May 2024 22:41:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 362CA6B0093; Wed, 8 May 2024 22:41:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 054756B0096; Wed, 8 May 2024 22:41:21 -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 CC87B6B0095 for ; Wed, 8 May 2024 22:41:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 62719120B5A for ; Thu, 9 May 2024 02:41:21 +0000 (UTC) X-FDA: 82097305962.01.DC909E9 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by imf19.hostedemail.com (Postfix) with ESMTP id 783211A0010 for ; Thu, 9 May 2024 02:41:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.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=1715222479; 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=U44GkABHvo/aAsdYMzSMKXccnqBmdht6j7L+HIqvEpwzyOMVGxbJPsUYLLkuDtizDETkOB MxZyOGqxooiJbNwB8FXL6FLHqli0+pQeZlEKZowy3vPZZ7tvTRo1MyIDBW91ZK71j9lCn2 QZoBFqcMMlJG5gtMAAKRenkk72JX/LQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715222479; a=rsa-sha256; cv=none; b=cHOnZY2l9ZQdib45RI5C3ahSllBmpZ1y0BlIjXlj8KUWG6V7afuv3l+OYx3lmp1VESGuVU up+hbdjolmeJ+B5Q0yJ7zBrmkTczREDjDgWMis49PjT4Oz4TvX4FBv4SmpNzTLXA5LM1/b ccXGz2CoCpDBG0DtteDLfHDPSAPdOpM= Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4492dpDj051905; Thu, 9 May 2024 10:39:51 +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 4VZbkN3NW5z2PGl6X; Thu, 9 May 2024 10:36:44 +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; Thu, 9 May 2024 10:39:48 +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: Thu, 9 May 2024 10:39:37 +0800 Message-ID: <20240509023937.1090421-3-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240509023937.1090421-1-zhaoyang.huang@unisoc.com> References: <20240509023937.1090421-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 4492dpDj051905 X-Rspamd-Server: rspam01 X-Stat-Signature: 5qqi15zg7j1ttczp3gsesdumzgjkbx43 X-Rspam-User: X-Rspamd-Queue-Id: 783211A0010 X-HE-Tag: 1715222478-915128 X-HE-Meta: U2FsdGVkX189JEgaxjtdwt1nOV3WPhGhLxB6zF9oGByr61g9umN+dnOj8s8ekZNI79oyguVOn0vkk83OvChyRpIJdz8L0yTPAq3aSIXV0Mz3Mhk8EHgKfxNjCeu56pTGC5QpnkL3MuMmEx4gmQp029cJZWgpu4tLJ6WVN+a5Ql8xTkh5eMvJnw75TdXEds1xUzH6uvOP1Lok67K9+U6+vQDU+ORqe2DW12ld6KA/k2OdFq4ElHEx2ZiJX3rMfPBJQbwz7R9GTkTOZ/qCdTRP1W2RhsNV7Ti+vwXSspz5ApzLnb51+EYe1i6fd90zaP8VL6wYsmrmVkQHqBsm+eCfogZO4qlh59toz0DHxUjklL9hZGPxjKlTF62ZlTSgyeLrYY+dXrgvkyYZyzrx6WkrDwNNdmYzIBM3ndEc3ErcETkKTEhvp0SvsStfMRYWQxCi5z13UrlwGOKPvGkc6Aqk6bNnVMaKCW0pMP4ODVGuR183SE7diI/ajBt2T45Brj7GjrzUMsK/7LBI2ALu/bXn5XGN+dSkl1EYtkAM+AiyOIt64dJg9hE0IsAGEupxqSDUjUJ+EZRTuy0BYAZDSS81lUHqvxba6d1+kYdyZ20lL18tiG8KzGtY18YAkxJCurKAvInjAlf6E522/CDd97CkgQUrml0vEZnSH4mhaRuaNaL6mJtIRgT9yn6JiWwTnflSq5uORNAJdQHJLjYlIr9VIYrI4I3pwHrApTpC7eEIy8Xg3jZtcQFBG9ZdJxJ4TjW2+XAe74FZDYcJEnx7xhuIT+6XN7Lfgh0iMJgFsMSErIVJo3lYEbhMU1THx3oxl34Kar77DCHww3ATKTQNfHAoNCoKM7B7XrPvwecgKviT37GbQLMWFGv8P/n0n9Gu/9YOB8H+JeHBUrnD3C8L9mf9Mw0XuuhrBi8odu46nS/FeJljRDqHNnmy6xZNGXDKNm/Y7r6016HLX8aWo8FyopH M8LDI8IW NDQYmuVtGA4/7cPJKVk6pnG8N6z74hAiX8CGTIzOrJPuXXxbNAKeCVIXoB6qxtaYhpVGZGGmlle7rRQGJpvjlOTpMOqYhDRZG5RqBxQcYvj7g+2KIxlZdH+mAbDvr62VZ58WQRMsp6FxGDzM6sDk8b7UHqQhQy3uLq3PW1V/2IuJ2PhbUHv2XwpemJQJ0F2KAPVNohqIDgqwxopE= 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;