[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1540707206-19649-1-git-send-email-hsiangkao@aol.com>
Date: Sun, 28 Oct 2018 14:13:26 +0800
From: Gao Xiang <hsiangkao@....com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Fengguang Wu <fengguang.wu@...el.com>,
Gao Xiang <hsiangkao@....com>
Subject: [PATCH] mm: 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.
Cc: Fengguang Wu <fengguang.wu@...el.com>
Signed-off-by: Gao Xiang <hsiangkao@....com>
---
mm/readahead.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/mm/readahead.c b/mm/readahead.c
index 4e63014..205ac34 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -272,17 +272,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;
}
/*
--
2.7.4
Powered by blists - more mailing lists