[PATCH] mm: make VM_MAX_READAHEAD configurable

From: Ehrhardt Christian
Date: Fri Oct 09 2009 - 07:21:12 EST


From: Christian Ehrhardt <ehrhardt@xxxxxxxxxxxxxxxxxx>

On one hand the define VM_MAX_READAHEAD in include/linux/mm.h is just a default
and can be configured per block device queue.
On the other hand a lot of admins do not use it, therefore it is reasonable to
set a wise default.

This path allows to configure the value via Kconfig mechanisms and therefore
allow the assignment of different defaults dependent on other Kconfig symbols.

Using this, the patch increases the default max readahead for s390 improving
sequential throughput in a lot of scenarios with almost no drawbacks (only
theoretical workloads with a lot concurrent sequential read patterns on a very
low memory system suffer due to page cache trashing as expected).

Signed-off-by: Christian Ehrhardt <ehrhardt@xxxxxxxxxxxxxxxxxx>
---

[diffstat]
include/linux/mm.h | 2 +-
mm/Kconfig | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)

[diff]
Index: linux-2.6/include/linux/mm.h
===================================================================
--- linux-2.6.orig/include/linux/mm.h
+++ linux-2.6/include/linux/mm.h
@@ -1169,7 +1169,7 @@ int write_one_page(struct page *page, in
void task_dirty_inc(struct task_struct *tsk);

/* readahead.c */
-#define VM_MAX_READAHEAD 128 /* kbytes */
+#define VM_MAX_READAHEAD CONFIG_VM_MAX_READAHEAD /* kbytes */
#define VM_MIN_READAHEAD 16 /* kbytes (includes current page) */

int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
Index: linux-2.6/mm/Kconfig
===================================================================
--- linux-2.6.orig/mm/Kconfig
+++ linux-2.6/mm/Kconfig
@@ -288,3 +288,22 @@ config NOMMU_INITIAL_TRIM_EXCESS
of 1 says that all excess pages should be trimmed.

See Documentation/nommu-mmap.txt for more information.
+
+config VM_MAX_READAHEAD
+ int "Default max vm readahead size (16-4096 kbytes)"
+ default "512" if S390
+ default "128"
+ range 16 4096
+ help
+ This entry specifies the default max size used to read ahead
+ sequential access patterns in kilobytes.
+
+ The value can be configured per device queue in /dev, this setting
+ just defines the default.
+
+ The default is 128 which it used to be for years and should suit all
+ kind of linux targets.
+
+ Smaller values might be useful for very memory constrained systems
+ like some embedded systems to avoid page cache trashing, while larger
+ values can be beneficial to server installations.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/