linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] cleanup ahead window calculation
@ 2005-01-25 11:59 Oleg Nesterov
  2005-01-25 21:47 ` Steven Pratt
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2005-01-25 11:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ram Pai, Steven Pratt, Andrew Morton

This patch moves some code into the get_next_ra_size()
and renames it into 'set_next_ahead_window'.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.11-rc2/mm/readahead.c~	2005-01-25 15:17:13.000000000 +0300
+++ 2.6.11-rc2/mm/readahead.c	2005-01-25 16:51:50.000000000 +0300
@@ -85,20 +85,23 @@ static unsigned long get_init_ra_size(un
  * not for each call to readahead.  If a cache miss occured, reduce next I/O
  * size, else increase depending on how close to max we are.
  */
-static unsigned long get_next_ra_size(unsigned long cur, unsigned long max,
-				unsigned long min, unsigned long * flags)
+static void set_next_ahead_window(struct file_ra_state *ra,
+				unsigned long max, unsigned long min)
 {
 	unsigned long newsize;
+	unsigned long cur = ra->size;
 
-	if (*flags & RA_FLAG_MISS) {
+	ra->ahead_start = ra->start + cur;
+
+	if (ra->flags & RA_FLAG_MISS) {
+		ra->flags &= ~RA_FLAG_MISS;
 		newsize = max((cur - 2), min);
-		*flags &= ~RA_FLAG_MISS;
-	} else if (cur < max / 16) {
+	} else if (cur < max / 16)
 		newsize = 4 * cur;
-	} else {
+	else
 		newsize = 2 * cur;
-	}
-	return min(newsize, max);
+
+	ra->ahead_size = min(newsize, max);
 }
 
 #define list_to_page(head) (list_entry((head)->prev, struct page, lru))
@@ -457,9 +460,7 @@ page_cache_readahead(struct address_spac
 		 * immediately.
 		 */
 		if (req_size >= max) {
-			ra->ahead_size = get_next_ra_size(ra->size, max, min,
-							  &ra->flags);
-			ra->ahead_start = ra->start + ra->size;
+			set_next_ahead_window(ra, max, min);
 			blockable_page_cache_readahead(mapping, filp,
 				 ra->ahead_start, ra->ahead_size, ra, 1);
 		}
@@ -497,9 +498,7 @@ page_cache_readahead(struct address_spac
 			ra->size = ra->ahead_size;
 		}
 
-		ra->ahead_size = get_next_ra_size(ra->size, max, min,
-							&ra->flags);
-		ra->ahead_start = ra->start + ra->size;
+		set_next_ahead_window(ra, max, min);
 
 		block = ((offset + newsize - 1) >= ra->ahead_start);
 		if (!blockable_page_cache_readahead(mapping, filp,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] cleanup ahead window calculation
  2005-01-25 11:59 [PATCH 3/4] cleanup ahead window calculation Oleg Nesterov
@ 2005-01-25 21:47 ` Steven Pratt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Pratt @ 2005-01-25 21:47 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Ram Pai, Andrew Morton

Not sure how much better this is, but it doesn't hurt anything.

Steve

Oleg Nesterov wrote:

>This patch moves some code into the get_next_ra_size()
>and renames it into 'set_next_ahead_window'.
>
>Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>
>--- 2.6.11-rc2/mm/readahead.c~	2005-01-25 15:17:13.000000000 +0300
>+++ 2.6.11-rc2/mm/readahead.c	2005-01-25 16:51:50.000000000 +0300
>@@ -85,20 +85,23 @@ static unsigned long get_init_ra_size(un
>  * not for each call to readahead.  If a cache miss occured, reduce next I/O
>  * size, else increase depending on how close to max we are.
>  */
>-static unsigned long get_next_ra_size(unsigned long cur, unsigned long max,
>-				unsigned long min, unsigned long * flags)
>+static void set_next_ahead_window(struct file_ra_state *ra,
>+				unsigned long max, unsigned long min)
> {
> 	unsigned long newsize;
>+	unsigned long cur = ra->size;
> 
>-	if (*flags & RA_FLAG_MISS) {
>+	ra->ahead_start = ra->start + cur;
>+
>+	if (ra->flags & RA_FLAG_MISS) {
>+		ra->flags &= ~RA_FLAG_MISS;
> 		newsize = max((cur - 2), min);
>-		*flags &= ~RA_FLAG_MISS;
>-	} else if (cur < max / 16) {
>+	} else if (cur < max / 16)
> 		newsize = 4 * cur;
>-	} else {
>+	else
> 		newsize = 2 * cur;
>-	}
>-	return min(newsize, max);
>+
>+	ra->ahead_size = min(newsize, max);
> }
> 
> #define list_to_page(head) (list_entry((head)->prev, struct page, lru))
>@@ -457,9 +460,7 @@ page_cache_readahead(struct address_spac
> 		 * immediately.
> 		 */
> 		if (req_size >= max) {
>-			ra->ahead_size = get_next_ra_size(ra->size, max, min,
>-							  &ra->flags);
>-			ra->ahead_start = ra->start + ra->size;
>+			set_next_ahead_window(ra, max, min);
> 			blockable_page_cache_readahead(mapping, filp,
> 				 ra->ahead_start, ra->ahead_size, ra, 1);
> 		}
>@@ -497,9 +498,7 @@ page_cache_readahead(struct address_spac
> 			ra->size = ra->ahead_size;
> 		}
> 
>-		ra->ahead_size = get_next_ra_size(ra->size, max, min,
>-							&ra->flags);
>-		ra->ahead_start = ra->start + ra->size;
>+		set_next_ahead_window(ra, max, min);
> 
> 		block = ((offset + newsize - 1) >= ra->ahead_start);
> 		if (!blockable_page_cache_readahead(mapping, filp,
>  
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-25 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 11:59 [PATCH 3/4] cleanup ahead window calculation Oleg Nesterov
2005-01-25 21:47 ` Steven Pratt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).