aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGao Xiang <[email protected]>2018-12-28 00:33:34 -0800
committerLinus Torvalds <[email protected]>2018-12-28 12:11:46 -0800
commit20ff1c950500380c6f74ec1a0d6f4eafab673ef6 (patch)
tree917edac99a1ab31b2f643c796330315981f30480
parent368686a95e55fd66b88542b5b23d802a4886b1aa (diff)
mm/readahead.c: simplify get_next_ra_size()
It's a trivial simplification for get_next_ra_size() and clear enough for humans to understand. It also fixes potential overflow if ra->size(< ra_pages) is too large. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]> Reviewed-by: Fengguang Wu <[email protected]> Reviewed-by: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--mm/readahead.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/mm/readahead.c b/mm/readahead.c
index f3d6f9656a3c..1ae16522412a 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -270,17 +270,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
* return it as the new window size.
*/
static unsigned long get_next_ra_size(struct file_ra_state *ra,
- unsigned long max)
+ unsigned long max)
{
unsigned long cur = ra->size;
- unsigned long newsize;
if (cur < max / 16)
- newsize = 4 * cur;
- else
- newsize = 2 * cur;
-
- return min(newsize, max);
+ return 4 * cur;
+ if (cur <= max / 2)
+ return 2 * cur;
+ return max;
}
/*