Make vm_max_readahead configurable at run-time
Subsystems (8)
PATCH 1/1 Make vm_max_readahead configurable at run-time
Make vm_max_readahead configurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their default read_ahead_kb.
---
block/blk-core.c +1 -1
@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +5 -1
@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD 128/* kbytes */ +extern unsigned long vm_max_readahead; + +int sysctl_vm_max_readahead_handler (struct ctl_table *,int , +void __user *,size_t *,loff_t *);int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);
mm/backing-dev.c +1 -1
@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,
mm/readahead.c +13 -0
@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead =INITIAL_VM_MAX_READAHEAD ; + +int sysctl_vm_max_readahead_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
kernel/sysctl.c +7 -1
@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead, + .maxlen = sizeof(vm_max_readahead), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_handler, + }, { } };
Documentation/sysctl/vm.txt +7 -0
@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery
@@ -263,6 +264,12 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be used. + +============================================================== + max_map_count: This file contains the maximum number of memory map areas a process
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 4 lines · On Tue, 9 Feb 2010 16:59:26 +0530 Nikanth Karthikesan <[email protected]> wrote:
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.
hm, I guess that's useful.
include/linux/mm.h int write_one_page(struct page *page, in · line 1195
Quoted 2 lines
include/linux/mm.h +2
-0+int sysctl_vm_max_readahead_handler (struct ctl_table *,int , +void __user *,size_t *,loff_t *);
I don't particuarly like the practice of leaving out the identifiers. They're useful for documentation purposes and it's irritating when you look at a declaration for some real reason, only to find that the identifiers were left out.
Quoted 25 lines
int force_page_cache_readahead(struct
address_space*mapping, struct file *filp,
pgoff_toffset, unsigned longnr_to_read);
Index:linux-2.6/mm/backing-dev.c
===================================================================mm/backing-dev.c +1
-1@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,Index:
linux-2.6/mm/readahead.c
===================================================================mm/readahead.c +2
-0@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead =INITIAL_VM_MAX_READAHEAD ; +
mm/readahead.c line 31
Quoted 10 lines
mm/readahead.c +10
-0+int sysctl_vm_max_readahead_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +}
Hang on. This doesn't only affect newly-added disks. It also affects presently-mounted filesystems which are using default_backing_dev_info. xfs, btrfs, blockdevs, nilfs, raw, mtd.
What's the effect of this change? (It should be in the changelog)
mm/readahead.c
Quoted 9 lines
mm/readahead.c +7
-1#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead, + .maxlen = sizeof(vm_max_readahead), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_handler, + },
It'd be nice if the in-kernel and /proc/identifiers were more similar. That would require that vm_max_readahead be renamed to vm_max_readahead_kb. We could not bother, I guess. But vm_max_readahead_kb is a better identifier.
Quoted 16 lines
{ }
};Index:
linux-2.6/Documentation/sysctl/vm.txt
===================================================================Documentation/sysctl/vm.txt +1
-0@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery
Documentation/sysctl/vm.txt The minimum value is 1 (1/1 -> 100%). · line 270
Quoted 7 lines
Documentation/sysctl/vm.txt +4
-0@@ -263,6 +264,12 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be used. +
I think we could provide a more detailed description than this, please.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Nikanth Karthikesan
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.Signed-off-by Nikanth Karthikesan <[email protected]>
Could you help us understand how you use this? The patch is straight forward except some of the objections pointed out by Andrew, but the help text below should help the user understand the trade-offs of increasing or lowering the value.
block/blk-core.c struct request_queue *blk_alloc_queue_no · line 502
Quoted 12 lines
---
Index:
linux-2.6/block/blk-core.c
===================================================================block/blk-core.c +1
-1@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead *1024 ) /PAGE_CACHE_SIZE ;
Why not use (vm_max_readahead >> (PAGE_CACHE_SHIFT - 10))? While you are looking at it, might as well clean it up :) I am quite sure the compiler gets it right, but might as well be sure.
fs/fuse/inode.c static int fuse_bdi_init(struct fuse_con · line 873
Quoted 13 lines
block/blk-core.c +0
-0q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;Index:
linux-2.6/fs/fuse/inode.c
===================================================================fs/fuse/inode.c +1
-1@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead *1024 ) /PAGE_CACHE_SIZE ;
Ditto
Quoted 41 lines
fs/fuse/inode.c +0
-0fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +5
-1@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD 128/* kbytes */ +extern unsigned long vm_max_readahead; + +int sysctl_vm_max_readahead_handler (struct ctl_table *,int , +void __user *,size_t *,loff_t *);int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);Index:
linux-2.6/mm/backing-dev.c
===================================================================mm/backing-dev.c +1
-1@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,Index:
linux-2.6/mm/readahead.c
===================================================================mm/readahead.c +0
-0@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h>
mm/readahead.c line 29
Quoted 10 lines
mm/readahead.c +10
-0+unsigned long vm_max_readahead =INITIAL_VM_MAX_READAHEAD ; + +int sysctl_vm_max_readahead_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead >> (PAGE_CACHE_SHIFT -10 ); +
Aaah.. here you got it right, please be consistent and use the same thing everywhere.
Quoted 56 lines
mm/readahead.c +3
-0+return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero. Index:
linux-2.6/kernel/sysctl.c
===================================================================kernel/sysctl.c +7
-1@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead, + .maxlen = sizeof(vm_max_readahead), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_handler, + }, { } };Index:
linux-2.6/Documentation/sysctl/vm.txt
===================================================================Documentation/sysctl/vm.txt +7
-1@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery@@ -263,6 +264,12 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be used. + +============================================================== + max_map_count: This file contains the maximum number of memory map areas a process --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 2 lines
Three Cheers, Balbir
PATCH v2 1/1 Make vm_max_readahead configurable at run-time
Incorporated coding-style changes, better changelog and documentation as suggested by Andrew and Balbir.
Thanks
Nikanth
Make vm_max_readahead configurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their default read_ahead_kb.
Also filesystems which use default_backing_dev_info would also use this new value, even if they were already mounted.
Currently xfs, btrfs, nilfs, raw, mtd use the default_backing_dev_info.
---
block/blk-core.c +1 -1
@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +5 -1
@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD_KB 128 +extern unsigned long vm_max_readahead_kb; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos);int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);
mm/backing-dev.c +2 -1
@@ -18,7 +18,8 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD_KB + >> (PAGE_CACHE_SHIFT -10 ), .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,
mm/readahead.c +13 -0
@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =INITIAL_VM_MAX_READAHEAD_KB ; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead_kb >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
kernel/sysctl.c +7 -1
@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead_kb, + .maxlen = sizeof(vm_max_readahead_kb), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_kb_handler, + }, { } };
Documentation/sysctl/vm.txt +13 -0
@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery
@@ -263,6 +264,18 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be +used, when new disks would be added to the system. + +Also filesystems which use default_backing_dev_info would also +use this new value, even if they were already mounted. + +xfs, btrfs, nilfs, raw, mtd use the default_backing_dev_info. + +============================================================== + max_map_count: This file contains the maximum number of memory map areas a process
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Nikanth,
Quoted 3 lines
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.
Do you have use case, or customer demand for it?
Quoted 4 lines
Also filesystems which use
default_backing_dev_infowould also use this new value, even if they were already mounted.Currently xfs, btrfs, nilfs, raw, mtd use the
default_backing_dev_info.
This sounds like bad interface, in that users will be confused by the tricky details of "works for new devices" and "works for some fs".
One more tricky point is, btrfs/md/dm readahead size may not be influenced if some of the component disks are hot added.
So this patch is only going to work for hot-plugged disks that contains _standalone_ filesystem. Is this typical use case in servers?
Thanks,
Fengguang
Quoted 126 lines
Signed-off-by Nikanth Karthikesan <[email protected]>---
Index:
linux-2.6/block/blk-core.c
===================================================================block/blk-core.c +1
-1@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;Index:
linux-2.6/fs/fuse/inode.c
===================================================================fs/fuse/inode.c +1
-1@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +5
-1@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD_KB 128 +extern unsigned long vm_max_readahead_kb; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos);int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);Index:
linux-2.6/mm/backing-dev.c
===================================================================mm/backing-dev.c +2
-1@@ -18,7 +18,8 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD_KB + >> (PAGE_CACHE_SHIFT -10 ), .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,Index:
linux-2.6/mm/readahead.c
===================================================================mm/readahead.c +13
-0@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =INITIAL_VM_MAX_READAHEAD_KB ; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *length,loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead_kb >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero. Index:
linux-2.6/kernel/sysctl.c
===================================================================kernel/sysctl.c +7
-1@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead_kb, + .maxlen = sizeof(vm_max_readahead_kb), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_kb_handler, + }, { } };Index:
linux-2.6/Documentation/sysctl/vm.txt
===================================================================Documentation/sysctl/vm.txt +6
-0@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery@@ -263,6 +264,18 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be +used, when new disks would be added to the system. +
Documentation/sysctl/vm.txt The minimum value is 1 (1/1 -> 100%). · line 281
Quoted 10 lines
Documentation/sysctl/vm.txt +7
-0+Also filesystems which use default_backing_dev_info would also +use this new value, even if they were already mounted. + +xfs, btrfs, nilfs, raw, mtd use the default_backing_dev_info. + +============================================================== + max_map_count: This file contains the maximum number of memory map areas a process
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · On Wednesday 10 February 2010 16:35:51 Wu Fengguang wrote:
Nikanth,
Quoted 3 lines
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.Do you have use case, or customer demand for it?
No body requested for it. But when doing some performance testing with readahead_kb re-compiling would be a pain, and thought that having a configurable default might be useful.
Quoted 5 lines
Quoted 4 lines
Also filesystems which use
default_backing_dev_infowould also use this new value, even if they were already mounted.Currently xfs, btrfs, nilfs, raw, mtd use the
default_backing_dev_info.
Quoted 9 lines
This sounds like bad interface, in that users will be confused by the tricky details of "works for new devices" and "works for some fs".
One more tricky point is, btrfs/md/dm readahead size may not be influenced if some of the component disks are hot added.
So this patch is only going to work for hot-plugged disks that contains _standalone_ filesystem. Is this typical use case in servers?
Yes, it would work only if the top-level disk is hot-plugged/created.
Thanks
Nikanth
Quoted 139 lines
Thanks,
FengguangQuoted 135 lines
Signed-off-by Nikanth Karthikesan <[email protected]>---
Index:
linux-2.6/block/blk-core.c
===================================================================block/blk-core.c +1
-1@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;Index:
linux-2.6/fs/fuse/inode.c
===================================================================fs/fuse/inode.c +1
-1@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +4
-1@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD_KB 128 +extern unsigned long vm_max_readahead_kb; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, + void __user *buffer, size_t *length, loff_t *ppos); int force_page_cache_readahead(struct address_space *mapping, structfile *filp,
pgoff_toffset, unsigned longnr_to_read);
Index:linux-2.6/mm/backing-dev.c
===================================================================mm/backing-dev.c +2
-1@@ -18,7 +18,8 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD_KB + >> (PAGE_CACHE_SHIFT -10 ), .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,Index:
linux-2.6/mm/readahead.c
===================================================================mm/readahead.c +12
-0@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =INITIAL_VM_MAX_READAHEAD_KB ; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, + void __user *buffer, size_t *length, loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead_kb >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
Index:linux-2.6/kernel/sysctl.c
===================================================================kernel/sysctl.c +7
-1@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead_kb, + .maxlen = sizeof(vm_max_readahead_kb), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_kb_handler, + }, { } };Index:
linux-2.6/Documentation/sysctl/vm.txt
===================================================================Documentation/sysctl/vm.txt +13
-0@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery@@ -263,6 +264,18 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be +used, when new disks would be added to the system. + +Also filesystems which use default_backing_dev_info would also +use this new value, even if they were already mounted. + +xfs, btrfs, nilfs, raw, mtd use the default_backing_dev_info. + +============================================================== + max_map_count: This file contains the maximum number of memory map areas a process
Quoted 7 lines · Nikanth Karthikesan
Quoted 6 lines · On Wednesday 10 February 2010 16:35:51 Wu Fengguang wrote:
Nikanth,
Quoted 3 lines
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.
Quoted 6 lines
Quoted 2 lines
Do you have use case, or customer demand for it?
No body requested for it. But when doing some performance testing with
readahead_kbre-compiling would be a pain, and thought that having a configurable default might be useful.
I wonder why you need to recompile kernel in the tests. There are three interfaces to change readahead size in runtime:
blockdev --setra 1024 /dev/sda
echo 512 > /sys/block/*/queue/read_ahead_kb
echo 512 > /sys/devices/virtual/bdi/*/read_ahead_kbQuoted 8 lines
Quoted 8 lines
Quoted 4 lines
Also filesystems which use
default_backing_dev_infowould also use this new value, even if they were already mounted.Currently xfs, btrfs, nilfs, raw, mtd use the
default_backing_dev_info.This sounds like bad interface, in that users will be confused by the tricky details of "works for new devices" and "works for some fs".
Quoted 8 lines
Quoted 6 lines
One more tricky point is, btrfs/md/dm readahead size may not be influenced if some of the component disks are hot added.
So this patch is only going to work for hot-plugged disks that contains _standalone_ filesystem. Is this typical use case in servers?
Yes, it would work only if the top-level disk is hot-plugged/created.
Or maybe what you really want is a kernel parameter for setting the default readahead size at boot time?
In another thread, Christian Ehrhardt recommended to add a config option for it. If you like it, I can also do the kernel parameter by the way.
Thanks,
Fengguang
Quoted 134 lines
Quoted 134 lines
Quoted 134 lines
Signed-off-by Nikanth Karthikesan <[email protected]>---
Index:
linux-2.6/block/blk-core.c
===================================================================block/blk-core.c +1
-1@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;Index:
linux-2.6/fs/fuse/inode.c
===================================================================fs/fuse/inode.c +1
-1@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;Index:
linux-2.6/include/linux/mm.h
===================================================================include/linux/mm.h +4
-1@@ -1188,7 +1188,11 @@ int write_one_page(struct page *page, invoid task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define INITIAL_VM_MAX_READAHEAD_KB 128 +extern unsigned long vm_max_readahead_kb; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, + void __user *buffer, size_t *length, loff_t *ppos); int force_page_cache_readahead(struct address_space *mapping, structfile *filp,
pgoff_toffset, unsigned longnr_to_read);
Index:linux-2.6/mm/backing-dev.c
===================================================================mm/backing-dev.c +2
-1@@ -18,7 +18,8 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =INITIAL_VM_MAX_READAHEAD_KB + >> (PAGE_CACHE_SHIFT -10 ), .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,Index:
linux-2.6/mm/readahead.c
===================================================================mm/readahead.c +12
-0@@ -17,6 +17,19 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =INITIAL_VM_MAX_READAHEAD_KB ; + +int sysctl_vm_max_readahead_kb_handler (struct ctl_table *table,int write, + void __user *buffer, size_t *length, loff_t *ppos) +{ +proc_doulongvec_minmax (table, write, buffer, length, ppos); + + default_backing_dev_info.ra_pages = + vm_max_readahead_kb >> (PAGE_CACHE_SHIFT -10 ); + +return 0 ; +} +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
Index:linux-2.6/kernel/sysctl.c
===================================================================kernel/sysctl.c +7
-1@@ -1273,7 +1273,13 @@ static struct ctl_table vm_table[] = { .extra2 = &one, },#endif - + { + .procname = "max_readahead_kb", + .data = &vm_max_readahead_kb, + .maxlen = sizeof(vm_max_readahead_kb), + .mode = 0644, + .proc_handler = sysctl_vm_max_readahead_kb_handler, + }, { } };Index:
linux-2.6/Documentation/sysctl/vm.txt
===================================================================Documentation/sysctl/vm.txt +13
-0@@ -31,6 +31,7 @@ Currently, these files are in /proc/sys/ - laptop_mode - legacy_va_layout - lowmem_reserve_ratio +- max_readahead_kb - max_map_count - memory_failure_early_kill - memory_failure_recovery@@ -263,6 +264,18 @@ The minimum value is 1 (1/1 -> 100%). ============================================================== +max_readahead_kb: + +This file contains the default maximum readahead that would be +used, when new disks would be added to the system. + +Also filesystems which use default_backing_dev_info would also +use this new value, even if they were already mounted. + +xfs, btrfs, nilfs, raw, mtd use the default_backing_dev_info. + +============================================================== + max_map_count:
Quoted 2 lines
Quoted 2 lines
Documentation/sysctl/vm.txt The minimum value is 1 (1/1 -> 100%). · line 281
Quoted 1 line
Documentation/sysctl/vm.txt +0
-0This file contains the maximum number of memory map areas a process
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · On Thursday 11 February 2010 10:43:41 Wu Fengguang wrote:
Quoted 7 lines · Nikanth Karthikesan
Quoted 6 lines · On Wednesday 10 February 2010 16:35:51 Wu Fengguang wrote:
Nikanth,
Quoted 3 lines
Make
vm_max_readaheadconfigurable at run-time. Expose a sysctl knob in procfs to change it. This would ensure that new disks added would use this value as their defaultread_ahead_kb.Quoted 5 lines
Quoted 1 line
Do you have use case, or customer demand for it?
No body requested for it. But when doing some performance testing with
readahead_kbre-compiling would be a pain, and thought that having a configurable default might be useful.
Quoted 7 lines
I wonder why you need to recompile kernel in the tests. There are three interfaces to change readahead size in runtime:
blockdev --setra 1024 /dev/sda echo 512 > /sys/block/*/queue/read_ahead_kb echo 512 > /sys/devices/virtual/bdi/*/read_ahead_kb
Right, I did use that. But thought that a global tunable would be better. :-)
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 5 lines
Also filesystems which use
default_backing_dev_infowould also use this new value, even if they were already mounted.Currently xfs, btrfs, nilfs, raw, mtd use the
default_backing_dev_info.This sounds like bad interface, in that users will be confused by the tricky details of "works for new devices" and "works for some fs".
One more tricky point is, btrfs/md/dm readahead size may not be influenced if some of the component disks are hot added.
So this patch is only going to work for hot-plugged disks that contains _standalone_ filesystem. Is this typical use case in servers?
Quoted 9 lines
Quoted 1 line
Yes, it would work only if the top-level disk is hot-plugged/created.
Or maybe what you really want is a kernel parameter for setting the default readahead size at boot time?
In another thread, Christian Ehrhardt recommended to add a config option for it. If you like it, I can also do the kernel parameter by the way.
Kernel parameter seems to be the right way to go. Does the attached patch look good?
Thanks
Nikanth
From: Nikanth Karthikesan <[email protected]>
Add new kernel parameter "readahead", which would be used as the value of VM_MAX_READAHEAD.
---
Documentation/kernel-parameters.txt +2 -0
@@ -2148,6 +2148,8 @@ and is between 256 and 4096 characters. It is defined in the file Format: <reboot_mode>[,<reboot_mode2>[,...]] See arch/*/kernel/reboot.c or arch/*/kernel/process.c + readahead= Default readahead value for block devices. + relax_domain_level= [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cgroups/cpusets.txt.
block/blk-core.c +1 -1
@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,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 = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +3 -1
@@ -1188,9 +1188,11 @@ int write_one_page(struct page *page, int wait);void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define DEFAULT_VM_MAX_READAHEAD 128/* kbytes */ #define VM_MIN_READAHEAD 16/* kbytes (includes current page) */ +extern unsigned long vm_max_readahead_kb; +int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);
init/main.c +11 -0
@@ -70,6 +70,7 @@#include <linux/sfi.h> #include <linux/shmem_fs.h> #include <trace/boot.h> +#include <linux/backing-dev.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -249,6 +250,16 @@ static int __init loglevel(char *str)early_param ("loglevel" , loglevel); +static int __init readahead (char *str) +{ + vm_max_readahead_kb =memparse (str, &str) /1024ULL ; + default_backing_dev_info.ra_pages = vm_max_readahead_kb + *1024 /PAGE_CACHE_SIZE ; +return 0 ; +} + +early_param ("readahead" , readahead); +/* * Unknown boot options get handed to init, unless they look like * unused parameters (modprobe will find them in /proc/cmdline).
mm/backing-dev.c +1 -1
@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =DEFAULT_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,
mm/readahead.c +2 -0
@@ -17,6 +17,8 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =DEFAULT_VM_MAX_READAHEAD ; +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
PATCH v2 1/1 Make VM_MAX_READAHEAD a kernel parameter
[Changes since v1: Added null check for parameter without value]
From: Nikanth Karthikesan <[email protected]>
Add new kernel parameter "readahead", which would be used as the value of VM_MAX_READAHEAD.
---
Documentation/kernel-parameters.txt +2 -0
@@ -2148,6 +2148,8 @@ and is between 256 and 4096 characters. It is defined in the file Format: <reboot_mode>[,<reboot_mode2>[,...]] See arch/*/kernel/reboot.c or arch/*/kernel/process.c + readahead= Default readahead value for block devices. + relax_domain_level= [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cgroups/cpusets.txt.
block/blk-core.c +1 -1
@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,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 = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +3 -1
@@ -1188,9 +1188,11 @@ int write_one_page(struct page *page, int wait);void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define DEFAULT_VM_MAX_READAHEAD 128/* kbytes */ #define VM_MIN_READAHEAD 16/* kbytes (includes current page) */ +extern unsigned long vm_max_readahead_kb; +int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);
init/main.c +13 -0
@@ -70,6 +70,7 @@#include <linux/sfi.h> #include <linux/shmem_fs.h> #include <trace/boot.h> +#include <linux/backing-dev.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -249,6 +250,18 @@ static int __init loglevel(char *str)early_param ("loglevel" , loglevel); +static int __init readahead (char *str) +{ +if (!str) +return -EINVAL ; + vm_max_readahead_kb =memparse (str, &str) /1024ULL ; + default_backing_dev_info.ra_pages = vm_max_readahead_kb + *1024 /PAGE_CACHE_SIZE ; +return 0 ; +} + +early_param ("readahead" , readahead); +/* * Unknown boot options get handed to init, unless they look like * unused parameters (modprobe will find them in /proc/cmdline).
mm/backing-dev.c +1 -1
@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =DEFAULT_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,
mm/readahead.c +2 -0
@@ -17,6 +17,8 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =DEFAULT_VM_MAX_READAHEAD ; +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
init/main.c static int __init loglevel(char *str) · line 257
Quoted 5 lines
init/main.c +5
-0+static int __init readahead (char *str) +{ + if (!str) + return -EINVAL; + vm_max_readahead_kb = memparse(str, &str) / 1024ULL;
Just wondering, shouldn't you check whether the str had a valid value [memparse (str, &next); next > str ..] and if it didn't, then use the DEFAULT_VM_MAX_READAHEAD ? Otherwise, incase of a invalid value, the readahead value will become zero.
init/main.c static int __init loglevel(char *str) · line 264
Quoted 7 lines
+ default_backing_dev_info.ra_pages =
vm_max_readahead_kb
+ * 1024 /PAGE_CACHE_SIZE;
+ return 0;init/main.c +4
-0+} + +early_param ("readahead" , readahead); +
-Ankit
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Quoted 11 lines · On Thursday 11 February 2010 16:45:24 Ankit Jain wrote:
Review
Quoted 5 lines
(quoted diff) +5
-0+static int __init readahead(char *str) +{ + if (!str) + return -EINVAL; + vm_max_readahead_kb = memparse(str, &str) / 1024ULL;Just wondering, shouldn't you check whether the str had a valid value [memparse (str, &next); next > str ..] and if it didn't, then use the
DEFAULT_VM_MAX_READAHEAD? Otherwise, incase of a invalid value, the readahead value will become zero.
Thanks for the review. Here is the fixed patch that checks whether all of the parameters value is consumed.
Thanks
Nikanth
From: Nikanth Karthikesan <[email protected]>
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.
---
Documentation/kernel-parameters.txt +2 -0
@@ -2148,6 +2148,8 @@ and is between 256 and 4096 characters. It is defined in the file Format: <reboot_mode>[,<reboot_mode2>[,...]] See arch/*/kernel/reboot.c or arch/*/kernel/process.c + readahead= Default readahead value for block devices. + relax_domain_level= [KNL, SMP] Set scheduler's default relax_domain_level. See Documentation/cgroups/cpusets.txt.
block/blk-core.c +1 -1
@@ -499,7 +499,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,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 = (vm_max_readahead_kb *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +3 -1
@@ -1188,9 +1188,11 @@ int write_one_page(struct page *page, int wait);void task_dirty_inc (struct task_struct *tsk);/* readahead.c */ -#define VM_MAX_READAHEAD 128/* kbytes */ +#define DEFAULT_VM_MAX_READAHEAD 128/* kbytes */ #define VM_MIN_READAHEAD 16/* kbytes (includes current page) */ +extern unsigned long vm_max_readahead_kb; +int force_page_cache_readahead (struct address_space *mapping,struct file *filp,pgoff_t offset,unsigned long nr_to_read);
init/main.c +19 -0
@@ -70,6 +70,7 @@#include <linux/sfi.h> #include <linux/shmem_fs.h> #include <trace/boot.h> +#include <linux/backing-dev.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -249,6 +250,24 @@ static int __init loglevel(char *str)early_param ("loglevel" , loglevel); +static int __init readahead (char *str) +{ +unsigned long readahead_kb; + +if (!str) +return -EINVAL ; + readahead_kb =memparse (str, &str) /1024ULL ; +if (*str !='\0' ) +return -EINVAL ; + + vm_max_readahead_kb = readahead_kb; + default_backing_dev_info.ra_pages = vm_max_readahead_kb + *1024 /PAGE_CACHE_SIZE ; +return 0 ; +} + +early_param ("readahead" , readahead); +/* * Unknown boot options get handed to init, unless they look like * unused parameters (modprobe will find them in /proc/cmdline).
mm/backing-dev.c +1 -1
@@ -18,7 +18,7 @@ EXPORT_SYMBOL(default_unplug_io_fn);struct backing_dev_info default_backing_dev_info = { .name ="default" , - .ra_pages =VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , + .ra_pages =DEFAULT_VM_MAX_READAHEAD *1024 /PAGE_CACHE_SIZE , .state =0 , .capabilities =BDI_CAP_MAP_COPY , .unplug_io_fn = default_unplug_io_fn,
mm/readahead.c +2 -0
@@ -17,6 +17,8 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +unsigned long vm_max_readahead_kb =DEFAULT_VM_MAX_READAHEAD ; +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Nikanth,
Quoted 5 lines
From: Nikanth Karthikesan <[email protected]>
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.
The patch looks good to me, though it conflicts with my patches. Do you mind me including a modified version in my readahead patchset?
Thanks,
Fengguang
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Quoted 11 lines · On Thursday 11 February 2010 20:46:51 Wu Fengguang wrote:
Nikanth,
Quoted 5 lines
From: Nikanth Karthikesan <[email protected]>
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.The patch looks good to me, though it conflicts with my patches. Do you mind me including a modified version in my readahead patchset?
Sure, go ahead.
Thanks
Nikanth
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
In reply to Nikanth KarthikesanQuoted 34 lines · Nikanth Karthikesan
Quoted 11 lines · On Thursday 11 February 2010 16:45:24 Ankit Jain wrote:
init/main.c static int __init loglevel(char *str)
Quoted 5 lines
init/main.c +5
-0+static int __init readahead (char *str) +{ +if (!str) +return -EINVAL ; + vm_max_readahead_kb =memparse (str, &str) /1024ULL ;Just wondering, shouldn't you check whether the str had a valid value [memparse (str, &next); next > str ..] and if it didn't, then use the
DEFAULT_VM_MAX_READAHEAD? Otherwise, incase of a invalid value, the readahead value will become zero.Thanks for the review. Here is the fixed patch that checks whether all of the parameters value is consumed.
Thanks
NikanthFrom: Nikanth Karthikesan <[email protected]>
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.Signed-off-by Nikanth Karthikesan <[email protected]>---
Documentation/kernel-parameters.txt +0
-0
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 2152
Quoted 5 lines
Documentation/kernel-parameters.txt +2
-0@@ -2148,6 +2148,8 @@ and is between 256 and 4096 characters. It is defined in the file Format: <reboot_mode>[,<reboot_mode2>[,...]] See arch/*/kernel/reboot.c or arch/*/kernel/process.c + readahead= Default readahead value for block devices. +
I think the description should define the units (kb) and valid value ranges e.g. page size to something not excessive - say 65536kb. The above description is, IMO, useless without refering to the source to find out this information....
[snip]
Documentation/kernel-parameters.txt static int __init loglevel(char *str) · line 261
Quoted 13 lines
Documentation/kernel-parameters.txt +9
-0@@ -249,6 +250,24 @@ static int __init loglevel(char *str) early_param("loglevel", loglevel); +static int __init readahead(char *str) +{ + unsigned long readahead_kb; + + if (!str) + return -EINVAL; + readahead_kb = memparse(str, &str) / 1024ULL; + if (*str != '\0') + return -EINVAL;
And readahead_kb needs to be validated against the range of valid values here.
Documentation/kernel-parameters.txt static int __init loglevel(char *str) · line 270
Quoted 9 lines
Documentation/kernel-parameters.txt +9
-0+ + vm_max_readahead_kb = readahead_kb; + default_backing_dev_info.ra_pages = vm_max_readahead_kb + * 1024 / PAGE_CACHE_SIZE; + return 0; +} + +early_param("readahead", readahead); +
Cheers,
Dave.
Signature · 8 lines
Dave Chinner [email protected] -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Quoted 37 lines · On Monday 15 February 2010 03:07:24 Dave Chinner wrote:
Quoted 36 lines · Nikanth Karthikesan
Quoted 10 lines · On Thursday 11 February 2010 16:45:24 Ankit Jain wrote:
init/main.c static int __init loglevel(char *str)
Quoted 5 lines
init/main.c +5
-0+static int __init readahead (char *str) +{ +if (!str) +return -EINVAL ; + vm_max_readahead_kb =memparse (str, &str) /1024ULL ;Just wondering, shouldn't you check whether the str had a valid value [memparse (str, &next); next > str ..] and if it didn't, then use the
DEFAULT_VM_MAX_READAHEAD? Otherwise, incase of a invalid value, the readahead value will become zero.Thanks for the review. Here is the fixed patch that checks whether all of the parameters value is consumed.
Thanks
NikanthFrom: Nikanth Karthikesan <[email protected]>
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.Signed-off-by Nikanth Karthikesan <[email protected]>---
(quoted diff) +0
-0
b/Documentation/kernel-parameters.txtindex 736d456..354e6f1 100644Documentation/kernel-parameters.txt +0
-0@@ -2148,6 +2148,8 @@ and is between 256 and 4096 characters. It isdefined in the file Format: <reboot_mode>[,<reboot_mode2>[,...]]
Seearch/*/kernel/reboot.corarch/*/kernel/process.c
Quoted 8 lines
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. It is defined in the file · line 2152
Quoted 2 lines
Documentation/kernel-parameters.txt +2
-0+ readahead= Default readahead value for block devices. +I think the description should define the units (kb) and valid value ranges e.g. page size to something not excessive - say 65536kb. The above description is, IMO, useless without refering to the source to find out this information....
The parameter can be specified with/without any suffix(k/m/g) that memparse() helper function can accept. So it can take 1M, 1024k, 1050620. I checked other parameters that use memparse() to get similar values and they didn't document it. May be this should be described here.
Quoted 6 lines
[snip]
Quoted 4 lines
Documentation/kernel-parameters.txt +0
-0@@ -249,6 +250,24 @@ static int __init loglevel(char *str) early_param("loglevel", loglevel);
Quoted 13 lines
Documentation/kernel-parameters.txt static int __init loglevel(char *str) · line 261
Quoted 9 lines
Documentation/kernel-parameters.txt +9
-0+static int __init readahead(char *str) +{ + unsigned long readahead_kb; + + if (!str) + return -EINVAL; + readahead_kb = memparse(str, &str) / 1024ULL; + if (*str != '\0') + return -EINVAL;And
readahead_kbneeds to be validated against the range of valid values here.
I didn't want to impose artificial restrictions. I think Wu's patch set would be adding some restrictions, like minimum readahead. He could fix it when he modifies the patch to include in his patch set.
Quoted 10 lines
Documentation/kernel-parameters.txt static int __init loglevel(char *str) · line 270
Quoted 9 lines
Documentation/kernel-parameters.txt +9
-0+ + vm_max_readahead_kb = readahead_kb; + default_backing_dev_info.ra_pages = vm_max_readahead_kb + * 1024 / PAGE_CACHE_SIZE; + return 0; +} + +early_param("readahead", readahead); +
Thanks for reviewing.
Thanks
Nikanth
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Nikanth,
Quoted 9 lines
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ readahead= Default readahead value for block devices. +I think the description should define the units (kb) and valid value ranges e.g. page size to something not excessive - say 65536kb. The above description is, IMO, useless without refering to the source to find out this information....
Quoted 4 lines
The parameter can be specified with/without any suffix(k/m/g) that
memparse()helper function can accept. So it can take 1M, 1024k, 1050620. I checked other parameters that usememparse()to get similar values and they didn't document it. May be this should be described here.
Hope this helps clarify things to user:
+ readahead=nn[KM]
+ Default max readahead size for block devices.
+ Range: 0; 4k - 128m
Quoted 7 lines
Quoted 3 lines
And
readahead_kbneeds to be validated against the range of valid values here.I didn't want to impose artificial restrictions. I think Wu's patch set would be adding some restrictions, like minimum readahead. He could fix it when he modifies the patch to include in his patch set.
OK, I imposed a larger bound -- 128MB.
And values 1-4095 (more exactly: PAGE_CACHE_SIZE) are prohibited mainly to catch "readahead=128" where the user really means to do 128 _KB_ readahead.
Christian, with this patch and more patches to scale down readahead size on small memory/device size, I guess it's no longer necessary to introduce a CONFIG_READAHEAD_SIZE?
Thanks,
Fengguang
---
make default readahead size a kernel parameter
From: Nikanth Karthikesan <[email protected]>
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.
--- Documentation/kernel-parameters.txt | 4 ++++ block/blk-core.c | 3 +-- fs/fuse/inode.c | 2 +- include/linux/mm.h | 2 ++ mm/readahead.c | 26 ++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-)
Documentation/kernel-parameters.txt +4 -0
@@ -2174,6 +2174,10 @@ and is between 256 and 4096 characters. 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
block/blk-core.c +1 -2
@@ -498,8 +498,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; - 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" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = max_readahead_pages; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
include/linux/mm.h +2 -0
@@ -1187,6 +1187,8 @@ void task_dirty_inc(struct task_struct *#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);
mm/readahead.c +26 -0
@@ -19,6 +19,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.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
Quoted 3 lines
Christian, with this patch and more patches to scale down readahead size on small memory/device size, I guess it's no longer necessary to introduce a
CONFIG_READAHEAD_SIZE?
This is the memory size based readahead limit :)
Thanks,
Fengguang
---
readahead: limit readahead size for small memory systems
When lifting the default readahead size from 128KB to 512KB, make sure it won't add memory pressure to small memory systems.
For read-ahead, the memory pressure is mainly readahead buffers consumed by too many concurrent streams. The context readahead can adapt readahead size to thrashing threshold well. So in principle we don't need to adapt the default _max_ read-ahead size to memory pressure.
For read-around, the memory pressure is mainly read-around misses on executables/libraries. Which could be reduced by scaling down read-around size on fast "reclaim passes".
This patch presents a straightforward solution: to limit default readahead size proportional to available system memory, ie.
512MB mem => 512KB readahead size 128MB mem => 128KB readahead size
32MB mem => 32KB readahead size (minimal)
Strictly speaking, only read-around size has to be limited. However we don't bother to seperate read-around size from read-ahead size for now.
--- mm/readahead.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
mm/readahead.c +25 -0
@@ -19,6 +19,9 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +#define MIN_READAHEAD_PAGES DIV_ROUND_UP(VM_MIN_READAHEAD*1024, PAGE_CACHE_SIZE) + +static int __init user_defined_readahead_size;static int __init config_readahead_size (char *str) {unsigned long bytes;
@@ -36,11 +39,33 @@ static int __init config_readahead_size( bytes =128 <<20 ; } + user_defined_readahead_size =1 ; default_backing_dev_info.ra_pages = bytes /PAGE_CACHE_SIZE ;return 0 ; }early_param ("readahead" , config_readahead_size); +static int __init readahead_init (void ) +{ +/* +* Scale down default readahead size for small memory systems. +* For example, a 64MB box will do 64KB read-ahead/read-around +* instead of the default 512KB. +* +* Note that the default readahead size will also be scaled down +* for small devices in add_disk(). +*/ +if (!user_defined_readahead_size) { +unsigned long max =roundup_pow_of_two (totalram_pages /1024 ); +if (default_backing_dev_info.ra_pages > max) + default_backing_dev_info.ra_pages = max; +if (default_backing_dev_info.ra_pages <MIN_READAHEAD_PAGES ) + default_backing_dev_info.ra_pages =MIN_READAHEAD_PAGES ; + } +return 0 ; +} +fs_initcall (readahead_init); +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
In reply to Wu FengguangQuoted 15 lines
(quoted diff) +15
-0+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;
Review
Quoted 10 lines
(quoted diff) +10
-0+ 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);
This further optimizes away max_readahead_pages :)
---
make default readahead size a kernel parameter
From: Nikanth Karthikesan <[email protected]>
Add new kernel parameter "readahead", which allows user to override the static VM_MAX_READAHEAD=512kb.
--- Documentation/kernel-parameters.txt | 4 ++++ block/blk-core.c | 3 +-- fs/fuse/inode.c | 2 +- mm/readahead.c | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-)
Documentation/kernel-parameters.txt +4 -0
@@ -2174,6 +2174,10 @@ and is between 256 and 4096 characters. 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
block/blk-core.c +1 -2
@@ -498,8 +498,7 @@ struct request_queue *blk_alloc_queue_no q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; - q->backing_dev_info.ra_pages = - (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + q->backing_dev_info.ra_pages = default_backing_dev_info.ra_pages; q->backing_dev_info.state =0 ; q->backing_dev_info.capabilities =BDI_CAP_MAP_COPY ; q->backing_dev_info.name ="block" ;
fs/fuse/inode.c +1 -1
@@ -870,7 +870,7 @@ static int fuse_bdi_init(struct fuse_conint err; fc->bdi.name ="fuse" ; - fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; + fc->bdi.ra_pages = default_backing_dev_info.ra_pages; fc->bdi.unplug_io_fn = default_unplug_io_fn;/* fuse does it's own writeback accounting */ fc->bdi.capabilities =BDI_CAP_NO_ACCT_WB ;
mm/readahead.c +22 -0
@@ -19,6 +19,28 @@#include <linux/pagevec.h> #include <linux/pagemap.h> +static int __init config_readahead_size (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 ; + } + + default_backing_dev_info.ra_pages = bytes /PAGE_CACHE_SIZE ; +return 0 ; +} +early_param ("readahead" , config_readahead_size); +/* * Initialise a struct file's readahead state. Assumes that the caller has * memset *ra to zero.
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
In reply to Wu FengguangQuoted 10 lines · Wu Fengguang
Nikanth,
Quoted 1 line
I didn't want to impose artificial restrictions. I think Wu's patch set would be adding some restrictions, like minimum readahead. He could fix it when he modifies the patch to include in his patch set.
OK, I imposed a larger bound -- 128MB.
And values 1-4095 (more exactly:PAGE_CACHE_SIZE) are prohibited mainly to catch "readahead=128" where the user really means to do 128 _KB_ readahead.Christian, with this patch and more patches to scale down readahead size on small memory/device size, I guess it's no longer necessary to introduce a
CONFIG_READAHEAD_SIZE?
Yes as I mentioned before a kernel parameter supersedes a config symbol in my opinion too. -> agreed
Quoted 3 lines
Thanks,
Fengguang
---
Signature · 2 lines
Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, System z Linux Performance
Re: [PATCH v2] Make VM_MAX_READAHEAD a kernel parameter
In reply to Wu FengguangQuoted 18 lines · Wu Fengguang
Nikanth,
Quoted 9 lines
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ readahead= Default readahead value for block devices. +I think the description should define the units (kb) and valid value ranges e.g. page size to something not excessive - say 65536kb. The above description is, IMO, useless without refering to the source to find out this information....
Quoted 4 lines
The parameter can be specified with/without any suffix(k/m/g) that
memparse()helper function can accept. So it can take 1M, 1024k, 1050620. I checked other parameters that usememparse()to get similar values and they didn't document it. May be this should be described here.Hope this helps clarify things to user:
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. · line 2179
Quoted 3 lines
Documentation/kernel-parameters.txt +3
-0+ readahead=nn[KM] + Default max readahead size for block devices. + Range: 0; 4k - 128m
Yes, that is exactly what I was thinA,ing of. Thanks.
Cheers,
Dave.
Signature · 8 lines
Dave Chinner [email protected] -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>