diff options
author | Wu Fengguang <fengguang.wu@intel.com> | 2011-11-18 20:14:04 -0800 |
---|---|---|
committer | Ziyan <jaraidaniel@gmail.com> | 2016-01-08 10:36:19 +0100 |
commit | 7b502d63994494a984d6270c41dd50ab4930dbfc (patch) | |
tree | 01c6832fc11f216762d6cc427e9280b963401382 | |
parent | e847aac49c7179cc54279f7624cabb2e6670318b (diff) | |
download | kernel_samsung_tuna-7b502d63994494a984d6270c41dd50ab4930dbfc.zip kernel_samsung_tuna-7b502d63994494a984d6270c41dd50ab4930dbfc.tar.gz kernel_samsung_tuna-7b502d63994494a984d6270c41dd50ab4930dbfc.tar.bz2 |
make default readahead size a kernel parameter
From: Nikanth Karthikesan <knikanth@suse.de>
Add new kernel parameter "readahead", which would be used instead of the
value of VM_MAX_READAHEAD. If the parameter is not specified, the default
of 128kb would be used.
Change-Id: I58540d4c3570d23befb9b9f1e27998e832eae88b
CC: Ankit Jain <radical@gmail.com>
CC: Dave Chinner <david@fromorbit.com>
CC: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: D. Andrei Măceș <dmaces@nd.edu>
-rw-r--r-- | Documentation/kernel-parameters.txt | 4 | ||||
-rw-r--r-- | block/blk-core.c | 3 | ||||
-rw-r--r-- | fs/fuse/inode.c | 2 | ||||
-rw-r--r-- | include/linux/mm.h | 2 | ||||
-rw-r--r-- | mm/readahead.c | 26 |
5 files changed, 34 insertions, 3 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3899234..b82f69fd 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -2198,6 +2198,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Run specified binary instead of /init from the ramdisk, used for early userspace startup. See initrd. + readahead=nn[KM] + Default max readahead size for block devices. + Range: 0; 4k - 128m + reboot= [BUGS=X86-32,BUGS=ARM,BUGS=IA-64] Rebooting mode Format: <reboot_mode>[,<reboot_mode2>[,...]] See arch/*/kernel/reboot.c or arch/*/kernel/process.c diff --git a/block/blk-core.c b/block/blk-core.c index 35ae52d..8d881b0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -413,8 +413,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) if (!q) return NULL; - q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; + q->backing_dev_info.ra_pages = max_readahead_pages; q->backing_dev_info.state = 0; q->backing_dev_info.capabilities = BDI_CAP_MAP_COPY; q->backing_dev_info.name = "block"; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 69a1e0f..a32d532 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -884,7 +884,7 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb) int err; fc->bdi.name = "fuse"; - fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; + fc->bdi.ra_pages = max_readahead_pages; /* fuse does it's own writeback accounting */ fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB; diff --git a/include/linux/mm.h b/include/linux/mm.h index 815d809..2a3b05a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1473,6 +1473,8 @@ void task_dirty_inc(struct task_struct *tsk); #define VM_MAX_READAHEAD 128 /* kbytes */ #define VM_MIN_READAHEAD 16 /* kbytes (includes current page) */ +extern unsigned long max_readahead_pages; + int force_page_cache_readahead(struct address_space *mapping, struct file *filp, pgoff_t offset, unsigned long nr_to_read); diff --git a/mm/readahead.c b/mm/readahead.c index 867f9dd..df60df9 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -18,6 +18,32 @@ #include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long max_readahead_pages = VM_MAX_READAHEAD * 1024 / PAGE_CACHE_SIZE; + +static int __init readahead(char *str) +{ + unsigned long bytes; + + if (!str) + return -EINVAL; + bytes = memparse(str, &str); + if (*str != '\0') + return -EINVAL; + + if (bytes) { + if (bytes < PAGE_CACHE_SIZE) /* missed 'k'/'m' suffixes? */ + return -EINVAL; + if (bytes > 128 << 20) /* limit to 128MB */ + bytes = 128 << 20; + } + + max_readahead_pages = bytes / PAGE_CACHE_SIZE; + default_backing_dev_info.ra_pages = max_readahead_pages; + return 0; +} + +early_param("readahead", readahead); + /* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero. |