Skip to contentSkip to conversation

readahead sysctl parameters fix

PATCH New Fengguang Wu 1 participant 2 messages Nov 29, 2006 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 readahead sysctl parameters fix

- do no extra readahead when (readahead_ratio == 1)
- define readahead_hit_rate inside CONFIG_ADAPTIVE_READAHEAD ifdefs

---

include/linux/mm.h +1 -1
@@ -1074,7 +1074,7 @@ extern int readahead_ratio;
 
 static inline int prefer_adaptive_readahead(void)
 {
-	return readahead_ratio > 1;
+	return readahead_ratio != 1;
 }
 
 /* Do stack extension */
Documentation/sysctl/vm.txt +1 -1
@@ -234,7 +234,7 @@ plenty of memory(>>2MB per reader), a bi
 readahead_ratio also selects the readahead logic:
 	VALUE	CODE PATH
 	-------------------------------------------
-	    0	disable readahead totally
+	    0	read as is, no extra readahead
 	    1	select the stock readahead logic
 	2-100	select the adaptive readahead logic
 
mm/readahead.c +1 -1
@@ -40,10 +40,10 @@
 /* Set read-ahead size to ##% of the thrashing-threshold. */
 int readahead_ratio = 50;
 EXPORT_SYMBOL_GPL(readahead_ratio);
-#endif
 
 /* Readahead as long as cache hit ratio keeps above 1/##. */
 int readahead_hit_rate = 0;
+#endif /* CONFIG_ADAPTIVE_READAHEAD */
 
 /*
  * Detailed classification of read-ahead behaviors.

--

#2 lore raw

PATCH 2/2 readahead nfsd case: fix uninitialized ra_min/ra_max

In reply to a message not in the archive

ra_min/ra_max are not initialized, fix it.

New benchmark numbers on

	hda: ST3250820A, ATA DISK drive
	hda: max request size: 512KiB
	hda: 488397168 sectors (250059 MB) w/8192KiB Cache, CHS=30401/255/63, UDMA(100)

with nfs mount

	mount -o tcp,rsize=$((rsize<<10)) localhost:$EXPORT $MNT

rsize stock adaptive
==================================
f

      8k       3.07    2.51    -18.2%
     32k       2.40    2.17     -9.6%
    128k       2.40    2.35     -2.1%
ff
      8k      12.44    6.40    -48.6%
     32k      14.62    5.46    -62.7%
    128k      15.79    5.19    -67.1%
d
      8k       2.84    2.48    -12.7%
     32k       2.53    1.99    -21.3%
    128k       2.18    2.00     -8.3%
dd
      8k       8.16    7.99     -2.1%
     32k       8.27    6.88    -16.8%
    128k       7.75    6.97    -10.1%

The 4 patterns tested are:
f: single file read
ff: double file parallel read
d: single dir read
dd: double dir parallel read

---

mm/readahead.c +11 -8
@@ -1616,6 +1616,10 @@ page_cache_readahead_adaptive(struct add
 	unsigned long ra_max;
 	int ret;
 
+	/* no read-ahead */
+	if (!ra->ra_pages)
+		return 0;
+
 	if (page) {
 		ClearPageReadahead(page);
 
@@ -1635,9 +1639,6 @@ page_cache_readahead_adaptive(struct add
 						offset + LAPTOP_POLL_INTERVAL))
 				return 0;
 		}
-	} else if (ra->flags & RA_FLAG_NFSD) { /* nfsd read */
-		ra_size = max_sane_readahead(req_size);
-		goto readit;
 	}
 
 	if (page)
@@ -1647,11 +1648,13 @@ page_cache_readahead_adaptive(struct add
 
 	get_readahead_bounds(ra, &ra_min, &ra_max);
 
-	/* read-ahead disabled? */
-	if (unlikely(!ra_max || !readahead_ratio)) {
-		ra_size = max_sane_readahead(req_size);
+	/* read as is */
+	if (!readahead_ratio)
+		goto readit;
+
+	/* nfsd read */
+	if (!page && (ra->flags & RA_FLAG_NFSD))
 		goto readit;
-	}
 
 	/*
 	 * Start of file.
@@ -1698,11 +1701,11 @@ page_cache_readahead_adaptive(struct add
 		return 0;
 	}
 
+readit:
 	/*
 	 * Random read.
 	 */
 	ra_size = min(req_size, ra_max);
-readit:
 	ra_size = __do_page_cache_readahead(mapping, filp, offset, ra_size, 0);
 
 	ra_account(ra, RA_EVENT_RANDOM_READ, ra_size);

--