per device dirty throttling -v4
Subsystems (16)
cover per device dirty throttling -v4
The latest version of the per device dirty throttling.
Dropped all the congestion_wait() churn, will contemplate a rename patch. Reworked the BDI statistics to use percpu_counter.
against 2.6.21-rc6-mm1; the first patch is for easy application. Andrew can of course just drop the patch it reverts.
--
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>
PATCH 1/12 revert per-backing_dev-dirty-and-writeback-page-accounting
For ease of application..
--- block/ll_rw_blk.c | 29 ----------------------------- fs/buffer.c | 1 - include/linux/backing-dev.h | 2 -- mm/page-writeback.c | 13 ++----------- mm/truncate.c | 1 - 5 files changed, 2 insertions(+), 44 deletions(-)
block/ll_rw_blk.c +0 -29
@@ -201,8 +201,6 @@ EXPORT_SYMBOL(blk_queue_softirq_done);**/ void blk_queue_make_request (request_queue_t * q,make_request_fn * mfn) { -struct backing_dev_info *bdi = &q->backing_dev_info; -/* * set defaults */
@@ -210,8 +208,6 @@ void blk_queue_make_request(request_queublk_queue_max_phys_segments (q,MAX_PHYS_SEGMENTS );blk_queue_max_hw_segments (q,MAX_HW_SEGMENTS ); q->make_request_fn = mfn; -atomic_long_set (&bdi->nr_dirty,0 ); -atomic_long_set (&bdi->nr_writeback,0 );blk_queue_max_sectors (q,SAFE_MAX_SECTORS );blk_queue_hardsect_size (q,512 );blk_queue_dma_alignment (q,511 );
@@ -3978,19 +3974,6 @@ static ssize_t queue_max_hw_sectors_showreturn queue_var_show (max_hw_sectors_kb, (page)); } -static ssize_t queue_nr_dirty_show (struct request_queue *q,char *page) -{ -return sprintf (page,"%lu\n" , -atomic_long_read (&q->backing_dev_info.nr_dirty)); - -} - -static ssize_t queue_nr_writeback_show (struct request_queue *q,char *page) -{ -return sprintf (page,"%lu\n" , -atomic_long_read (&q->backing_dev_info.nr_writeback)); - -}static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name ="nr_requests" , .mode =S_IRUGO |S_IWUSR },
@@ -4021,16 +4004,6 @@ static struct queue_sysfs_entry queue_ma .show = queue_max_hw_sectors_show, }; -static struct queue_sysfs_entry queue_nr_dirty_entry = { - .attr = {.name ="nr_dirty" , .mode =S_IRUGO }, - .show = queue_nr_dirty_show, -}; - -static struct queue_sysfs_entry queue_nr_writeback_entry = { - .attr = {.name ="nr_writeback" , .mode =S_IRUGO }, - .show = queue_nr_writeback_show, -}; -static struct queue_sysfs_entry queue_iosched_entry = { .attr = {.name ="scheduler" , .mode =S_IRUGO |S_IWUSR }, .show = elv_iosched_show,
@@ -4043,8 +4016,6 @@ static struct attribute *default_attrs[] &queue_initial_ra_entry.attr, &queue_max_hw_sectors_entry.attr, &queue_max_sectors_entry.attr, - &queue_nr_dirty_entry.attr, - &queue_nr_writeback_entry.attr, &queue_iosched_entry.attr, NULL, };
fs/buffer.c +0 -1
@@ -740,7 +740,6 @@ int __set_page_dirty_buffers(struct pageif (page->mapping) {/* Race with truncate? */ if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -atomic_long_inc (&mapping->backing_dev_info->nr_dirty);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
include/linux/backing-dev.h +0 -2
@@ -30,8 +30,6 @@ struct backing_dev_info {unsigned long ra_thrash_bytes;/* estimated thrashing threshold */ unsigned long state;/* Always use atomic bitops on this */ unsigned int capabilities;/* Device capabilities */ -atomic_long_t nr_dirty;/* Pages dirty against this BDI */ -atomic_long_t nr_writeback;/* Pages under writeback against this BDI */ congested_fn *congested_fn;/* Function pointer if device is md/dm */ void *congested_data;/* Pointer to aux data for congested func */ void (*unplug_io_fn)(struct backing_dev_info *,struct page *);
mm/page-writeback.c +2 -11
@@ -828,8 +828,6 @@ int __set_page_dirty_nobuffers(struct paBUG_ON (mapping2 != mapping);if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -atomic_long_inc (&mapping->backing_dev_info-> - nr_dirty);task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
@@ -963,7 +961,6 @@ int clear_page_dirty_for_io(struct page*/ if (TestClearPageDirty (page)) {dec_zone_page_state (page,NR_FILE_DIRTY ); -atomic_long_dec (&mapping->backing_dev_info->nr_dirty);return 1 ; }return 0 ;
@@ -982,13 +979,10 @@ int test_clear_page_writeback(struct pagwrite_lock_irqsave (&mapping->tree_lock, flags); ret =TestClearPageWriteback (page); -if (ret) { +if (ret)radix_tree_tag_clear (&mapping->page_tree,page_index (page),PAGECACHE_TAG_WRITEBACK ); -atomic_long_dec (&mapping->backing_dev_info-> - nr_writeback); - }write_unlock_irqrestore (&mapping->tree_lock, flags); }else { ret =TestClearPageWriteback (page);
@@ -1008,13 +1002,10 @@ int test_set_page_writeback(struct pagewrite_lock_irqsave (&mapping->tree_lock, flags); ret =TestSetPageWriteback (page); -if (!ret) { +if (!ret)radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_WRITEBACK ); -atomic_long_inc (&mapping->backing_dev_info-> - nr_writeback); - }if (!PageDirty (page)) radix_tree_tag_clear(&mapping->page_tree, page_index(page),
mm/truncate.c +0 -1
@@ -70,7 +70,6 @@ void cancel_dirty_page(struct page *pageif (TestClearPageDirty (page)) {struct address_space *mapping = page->mapping;if (mapping &&mapping_cap_account_dirty (mapping)) { -atomic_long_dec (&mapping->backing_dev_info->nr_dirty);dec_zone_page_state (page,NR_FILE_DIRTY );if (account_size)task_io_account_cancelled_write (account_size);
Signature · 5 lines
-- 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>
PATCH 2/12 nfs: remove congestion_end()
In reply to Peter ZijlstraIts redundant, clear_bdi_congested() already wakes the waiters.
--- fs/nfs/write.c | 4 +--- include/linux/backing-dev.h | 1 - mm/backing-dev.c | 13 ------------- 3 files changed, 1 insertion(+), 17 deletions(-)
fs/nfs/write.c +1 -3
@@ -235,10 +235,8 @@ static void nfs_end_page_writeback(strucstruct nfs_server *nfss =NFS_SERVER (inode);end_page_writeback (page); -if (atomic_long_dec_return (&nfss->writeback) <NFS_CONGESTION_OFF_THRESH ) { +if (atomic_long_dec_return (&nfss->writeback) <NFS_CONGESTION_OFF_THRESH )clear_bdi_congested (&nfss->backing_dev_info,WRITE ); -congestion_end (WRITE ); - } }/*
include/linux/backing-dev.h +0 -1
@@ -96,7 +96,6 @@ void clear_bdi_congested(struct backing_void set_bdi_congested (struct backing_dev_info *bdi,int rw);long congestion_wait (int rw,long timeout);long congestion_wait_interruptible (int rw,long timeout); -void congestion_end (int rw);#define bdi_cap_writeback_dirty (bdi) \ (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
mm/backing-dev.c +0 -13
@@ -70,16 +70,3 @@ long congestion_wait_interruptible(int rreturn ret; }EXPORT_SYMBOL (congestion_wait_interruptible); - -/** -* congestion_end - wake up sleepers on a congested backing_dev_info -* @rw: READ or WRITE -*/ -void congestion_end (int rw) -{ -wait_queue_head_t *wqh = &congestion_wqh[rw]; - -if (waitqueue_active (wqh)) -wake_up (wqh); -} -EXPORT_SYMBOL (congestion_end);
Signature · 5 lines
-- 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>
PATCH 3/12 lib: dampen the percpu_counter FBC_BATCH
In reply to Peter ZijlstraWith the current logic the percpu_counter's accuracy delta is quadric wrt the number of cpus in the system, reduce this to O(n ln n).
--- include/linux/percpu_counter.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
include/linux/percpu_counter.h +2 -5
@@ -11,6 +11,7 @@#include <linux/threads.h> #include <linux/percpu.h> #include <linux/types.h> +#include <linux/log2.h> #ifdef CONFIG_SMP
@@ -20,11 +21,7 @@ struct percpu_counter {s32 *counters; }; -#if NR_CPUS >=16 -#define FBC_BATCH (NR_CPUS*2) -#else -#define FBC_BATCH (NR_CPUS*4) -#endif +#define FBC_BATCH (8*ilog2(NR_CPUS))static inline void percpu_counter_init (struct percpu_counter *fbc,s64 amount) {
Signature · 5 lines
-- 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>
PATCH 4/12 lib: percpu_counter_mod64
In reply to Peter ZijlstraAdd percpu_counter_mod64() to allow large modifications.
--- include/linux/percpu_counter.h | 9 +++++++++ lib/percpu_counter.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
include/linux/percpu_counter.h +9 -0
@@ -36,6 +36,7 @@ static inline void percpu_counter_destro }void percpu_counter_mod (struct percpu_counter *fbc,s32 amount); +void percpu_counter_mod64 (struct percpu_counter *fbc,s64 amount);s64 percpu_counter_sum (struct percpu_counter *fbc);static inline s64 percpu_counter_read (struct percpu_counter *fbc)
@@ -81,6 +82,14 @@ percpu_counter_mod(struct percpu_counterpreempt_enable (); } +static inline void +percpu_counter_mod64 (struct percpu_counter *fbc,s64 amount) +{ +preempt_disable (); + fbc->count += amount; +preempt_enable (); +} +static inline s64 percpu_counter_read (struct percpu_counter *fbc) {return fbc->count;
lib/percpu_counter.c +28 -0
@@ -25,6 +25,34 @@ void percpu_counter_mod(struct percpu_co }EXPORT_SYMBOL (percpu_counter_mod); +void percpu_counter_mod64 (struct percpu_counter *fbc,s64 amount) +{ +long count; +s32 *pcount; +int cpu; + +if (amount >=FBC_BATCH || amount <= -FBC_BATCH ) { +spin_lock (&fbc->lock); + fbc->count += amount; +spin_unlock (&fbc->lock); +return ; + } + + cpu =get_cpu (); + pcount =per_cpu_ptr (fbc->counters, cpu); + count = *pcount + amount; +if (count >=FBC_BATCH || count <= -FBC_BATCH ) { +spin_lock (&fbc->lock); + fbc->count += count; + *pcount =0 ; +spin_unlock (&fbc->lock); + }else { + *pcount = count; + } +put_cpu (); +} +EXPORT_SYMBOL (percpu_counter_mod64); +/* * Add up all the per-cpu counts, return the result. This is a more accurate * but much slower version of percpu_counter_read_positive()
Signature · 5 lines
-- 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>
PATCH 5/12 mm: bdi init hooks
In reply to Peter Zijlstraprovide BDI constructor/destructor hooks
--- block/ll_rw_blk.c | 2 ++ drivers/block/rd.c | 6 ++++++ drivers/char/mem.c | 2 ++ drivers/mtd/mtdcore.c | 5 +++++ fs/char_dev.c | 1 + fs/configfs/configfs_internal.h | 2 ++ fs/configfs/inode.c | 8 ++++++++ fs/configfs/mount.c | 2 ++ fs/fuse/inode.c | 2 ++ fs/hugetlbfs/inode.c | 3 +++ fs/nfs/client.c | 3 +++ fs/ocfs2/dlm/dlmfs.c | 6 +++++- fs/ramfs/inode.c | 7 ++++++- fs/sysfs/inode.c | 5 +++++ fs/sysfs/mount.c | 2 ++ fs/sysfs/sysfs.h | 1 + include/linux/backing-dev.h | 7 +++++++ kernel/cpuset.c | 3 +++ mm/shmem.c | 1 + mm/swap.c | 2 ++ 20 files changed, 68 insertions(+), 2 deletions(-)
block/ll_rw_blk.c +2 -0
@@ -1771,6 +1771,7 @@ static void blk_release_queue(struct kobblk_trace_shutdown (q); +bdi_destroy (&q->backing_dev_info);kmem_cache_free (requestq_cachep, q); }
@@ -1836,6 +1837,7 @@ request_queue_t *blk_alloc_queue_node(gf q->kobj.ktype = &queue_ktype;kobject_init (&q->kobj); q->backing_dev_info = default_backing_dev_info; +bdi_init (&q->backing_dev_info); q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q;
drivers/block/rd.c +6 -0
@@ -411,6 +411,9 @@ static void __exit rd_cleanup(void)blk_cleanup_queue (rd_queue[i]); }unregister_blkdev (RAMDISK_MAJOR ,"ramdisk" ); + +bdi_destroy (&rd_file_backing_dev_info); +bdi_destroy (&rd_backing_dev_info); }/*
@@ -421,6 +424,9 @@ static int __init rd_init(void)int i;int err = -ENOMEM ; +bdi_init (&rd_backing_dev_info); +bdi_init (&rd_file_backing_dev_info); +if (rd_blocksize >PAGE_SIZE || rd_blocksize <512 || (rd_blocksize & (rd_blocksize-1 ))) { printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
drivers/char/mem.c +2 -0
@@ -987,6 +987,8 @@ static int __init chr_dev_init(void)MKDEV (MEM_MAJOR , devlist[i].minor), devlist[i].name); +bdi_init (&zero_bdi); +return 0 ; }
fs/char_dev.c +1 -0
@@ -546,6 +546,7 @@ static struct kobject *base_probe(dev_tvoid __init chrdev_init (void ) { cdev_map =kobj_map_init (base_probe, &chrdevs_lock); +bdi_init (&directly_mappable_cdev_bdi); }
fs/fuse/inode.c +2 -0
@@ -415,6 +415,7 @@ static struct fuse_conn *new_conn(void)atomic_set (&fc->num_waiting,0 ); fc->bdi.ra_pages = (VM_MAX_READAHEAD *1024 ) /PAGE_CACHE_SIZE ; fc->bdi.unplug_io_fn = default_unplug_io_fn; +bdi_init (&fc->bdi); fc->reqctr =0 ; fc->blocked =1 ;get_random_bytes (&fc->scramble_key,sizeof (fc->scramble_key));
@@ -428,6 +429,7 @@ void fuse_conn_put(struct fuse_conn *fc)if (fc->destroy_req)fuse_request_free (fc->destroy_req);mutex_destroy (&fc->inst_mutex); +bdi_destroy (&fc->bdi);kfree (fc); } }
fs/nfs/client.c +3 -0
@@ -657,6 +657,8 @@ static void nfs_server_set_fsinfo(structif (server->rsize >NFS_MAX_FILE_IO_SIZE ) server->rsize =NFS_MAX_FILE_IO_SIZE ; server->rpages = (server->rsize +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + +bdi_init (&server->backing_dev_info); server->backing_dev_info.ra_pages = server->rpages *NFS_MAX_READAHEAD ; server->backing_dev_info.ra_pages0 =min_t (unsigned, server->rpages,VM_MIN_READAHEAD >> (PAGE_CACHE_SHIFT -10 ));
@@ -789,6 +791,7 @@ void nfs_free_server(struct nfs_server *nfs_put_client (server->nfs_client);nfs_free_iostats (server->io_stats); +bdi_destroy (&server->backing_dev_info);kfree (server);nfs_release_automount_timer ();dprintk ("<-- nfs_free_server()\n" );
include/linux/backing-dev.h +7 -0
@@ -36,6 +36,13 @@ struct backing_dev_info {void *unplug_io_data; }; +static inline void bdi_init (struct backing_dev_info *bdi) +{ +} + +static inline void bdi_destroy (struct backing_dev_info *bdi) +{ +}/* * Flags in backing_dev_info::capability
drivers/mtd/mtdcore.c +5 -0
@@ -60,6 +60,7 @@ int add_mtd_device(struct mtd_info *mtd)break ; } } +bdi_init (mtd->backing_dev_info);BUG_ON (mtd->writesize ==0 );mutex_lock (&mtd_table_mutex);
@@ -142,6 +143,10 @@ int del_mtd_device (struct mtd_info *mtd }mutex_unlock (&mtd_table_mutex); + +if (mtd->backing_dev_info) +bdi_destroy (mtd->backing_dev_info); +return ret; }
fs/hugetlbfs/inode.c +3 -0
@@ -819,6 +819,8 @@ static int __init init_hugetlbfs_fs(void out:if (error)kmem_cache_destroy (hugetlbfs_inode_cachep); +else +bdi_init (&hugetlbfs_backing_dev_info);return error; }
@@ -826,6 +828,7 @@ static void __exit exit_hugetlbfs_fs(voi {kmem_cache_destroy (hugetlbfs_inode_cachep);unregister_filesystem (&hugetlbfs_fs_type); +bdi_destroy (&hugetlbfs_backing_dev_info); }module_init (init_hugetlbfs_fs)
fs/ocfs2/dlm/dlmfs.c +5 -1
@@ -614,8 +614,10 @@ bail:kmem_cache_destroy (dlmfs_inode_cache);if (cleanup_worker)destroy_workqueue (user_dlm_worker); - }else + }else { +bdi_init (&dlmfs_backing_dev_info);printk ("OCFS2 User DLM kernel interface loaded\n" ); + }return status; }
@@ -627,6 +629,8 @@ static void __exit exit_dlmfs_fs(void)destroy_workqueue (user_dlm_worker);kmem_cache_destroy (dlmfs_inode_cache); + +bdi_destroy (&dlmfs_backing_dev_info); }MODULE_AUTHOR ("Oracle" );
fs/configfs/configfs_internal.h +2 -0
@@ -55,6 +55,8 @@ extern int configfs_is_root(struct confiextern struct inode *configfs_new_inode (mode_t mode,struct configfs_dirent *);extern int configfs_create (struct dentry *,int mode,int (*init)(struct inode *)); +extern void configfs_inode_init (void ); +extern void configfs_inode_exit (void );extern int configfs_create_file (struct config_item *,const struct configfs_attribute *); extern int configfs_make_dirent(struct configfs_dirent *,
fs/configfs/inode.c +8 -0
@@ -255,4 +255,12 @@ void configfs_hash_and_remove(struct denmutex_unlock (&dir->d_inode->i_mutex); } +void __init configfs_inode_init (void ) +{ +bdi_init (&configfs_backing_dev_info); +} +void __exit configfs_inode_exit(void) +{ +bdi_destroy (&configfs_backing_dev_info); +}
fs/configfs/mount.c +2 -0
@@ -156,6 +156,7 @@ static int __init configfs_init(void) configfs_dir_cachep =NULL ; } +configfs_inode_init (); out:return err; }
@@ -166,6 +167,7 @@ static void __exit configfs_exit(void)subsystem_unregister (&config_subsys);kmem_cache_destroy (configfs_dir_cachep); configfs_dir_cachep =NULL ; +configfs_inode_exit (); }MODULE_AUTHOR ("Oracle" );
fs/ramfs/inode.c +6 -1
@@ -210,12 +210,17 @@ static struct file_system_type rootfs_fsstatic int __init init_ramfs_fs (void ) { -return register_filesystem (&ramfs_fs_type); +int ret; + ret =register_filesystem (&ramfs_fs_type); +if (!ret) +bdi_init (&ramfs_backing_dev_info); +return ret; } static void __exit exit_ramfs_fs(void) {unregister_filesystem (&ramfs_fs_type); +bdi_destroy (&ramfs_backing_dev_info); }module_init (init_ramfs_fs)
fs/sysfs/inode.c +5 -0
@@ -299,3 +299,8 @@ int sysfs_hash_and_remove(struct dentryreturn found ?0 : -ENOENT ; } + +void __init sysfs_inode_init (void ) +{ +bdi_init (&sysfs_backing_dev_info); +}
fs/sysfs/mount.c +2 -0
@@ -108,6 +108,8 @@ int __init sysfs_init(void) }else goto out_err; out: +if (!err) +sysfs_inode_init ();return err; out_err:kmem_cache_destroy (sysfs_dir_cachep);
fs/sysfs/sysfs.h +1 -0
@@ -16,6 +16,7 @@ extern struct kmem_cache *sysfs_dir_cachextern void sysfs_delete_inode (struct inode *inode);extern struct inode *sysfs_new_inode (mode_t mode,struct sysfs_dirent *);extern int sysfs_create (struct dentry *,int mode,int (*init)(struct inode *)); +extern void sysfs_inode_init (void );extern int sysfs_dirent_exist (struct sysfs_dirent *,const unsigned char *); extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
kernel/cpuset.c +3 -0
@@ -1921,6 +1921,7 @@ int __init cpuset_init_early(void) tsk->cpuset = &top_cpuset; tsk->cpuset->mems_generation = cpuset_mems_generation++; +return 0 ; }
@@ -1963,6 +1964,8 @@ int __init cpuset_init(void)/* memory_pressure_enabled is in root cpuset only */ if (err ==0 ) err =cpuset_add_file (root, &cft_memory_pressure_enabled); +if (!err) +bdi_init (&cpuset_backing_dev_info); out:return err; }
mm/shmem.c +1 -0
@@ -2478,6 +2478,7 @@ static int __init init_tmpfs(void)printk (KERN_ERR "Could not kern_mount tmpfs\n" ); goto out1; } +bdi_init (&shmem_backing_dev_info);return 0 ; out1:
mm/swap.c +2 -0
@@ -550,6 +550,8 @@ void __init swap_setup(void) {unsigned long megs = num_physpages >> (20 -PAGE_SHIFT ); +bdi_init (swapper_space.backing_dev_info); +/* Use a smaller cluster for small-memory machines */ if (megs <16 ) page_cluster =2 ;
Signature · 5 lines
-- 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>
PATCH 6/12 mm: scalable bdi statistics counters.
In reply to Peter ZijlstraProvide scalable per backing_dev_info statistics counters.
--- include/linux/backing-dev.h | 50 ++++++++++++++++++++++++++++++++++++++++++-- mm/backing-dev.c | 26 ++++++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-)
include/linux/backing-dev.h +48 -2
@@ -8,6 +8,7 @@#ifndef _LINUX_BACKING_DEV_H#define _LINUX_BACKING_DEV_H +#include <linux/percpu_counter.h> #include <asm/atomic.h> struct page ;
@@ -24,6 +25,10 @@ enum bdi_state {typedef int (congested_fn )(void *,int ); +enum bdi_stat_item { +NR_BDI_STAT_ITEMS +}; +struct backing_dev_info {unsigned long ra_pages;/* max readahead in PAGE_CACHE_SIZE units */ unsigned long ra_pages0;/* min readahead on start of file */
@@ -34,14 +39,55 @@ struct backing_dev_info {void *congested_data;/* Pointer to aux data for congested func */ void (*unplug_io_fn)(struct backing_dev_info *,struct page *);void *unplug_io_data; + +struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS ]; }; -static inline void bdi_init (struct backing_dev_info *bdi) +void bdi_init (struct backing_dev_info *bdi); +void bdi_destroy (struct backing_dev_info *bdi); + +static inline void __mod_bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item,s32 amount) +{ +percpu_counter_mod (&bdi->bdi_stat[item], amount); +} + +static inline void __inc_bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +__mod_bdi_stat (bdi, item,1 ); +} + +static inline void inc_bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +unsigned long flags; + +local_irq_save (flags); +__inc_bdi_stat (bdi, item); +local_irq_restore (flags); +} + +static inline void __dec_bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) { +__mod_bdi_stat (bdi, item,-1 ); +} + +static inline void dec_bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +unsigned long flags; + +local_irq_save (flags); +__dec_bdi_stat (bdi, item); +local_irq_restore (flags); } -static inline void bdi_destroy (struct backing_dev_info *bdi) +static inline s64 bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) { +return percpu_counter_read_positive (&bdi->bdi_stat[item]); }/*
mm/backing-dev.c +26 -0
@@ -5,6 +5,30 @@#include <linux/sched.h> #include <linux/module.h> +void bdi_init (struct backing_dev_info *bdi) +{ +int i; + +if (!(bdi_cap_writeback_dirty (bdi) ||bdi_cap_account_dirty (bdi))) +return ; + +for (i =0 ; i <NR_BDI_STAT_ITEMS ; i++) +percpu_counter_init (&bdi->bdi_stat[i],0 ); +} +EXPORT_SYMBOL (bdi_init); + +void bdi_destroy (struct backing_dev_info *bdi) +{ +int i; + +if (!(bdi_cap_writeback_dirty (bdi) ||bdi_cap_account_dirty (bdi))) +return ; + +for (i =0 ; i <NR_BDI_STAT_ITEMS ; i++) +percpu_counter_destroy (&bdi->bdi_stat[i]); +} +EXPORT_SYMBOL (bdi_destroy); +static wait_queue_head_t congestion_wqh[2 ] = {__WAIT_QUEUE_HEAD_INITIALIZER (congestion_wqh[0 ]),__WAIT_QUEUE_HEAD_INITIALIZER (congestion_wqh[1 ])
@@ -70,3 +94,5 @@ long congestion_wait_interruptible(int rreturn ret; }EXPORT_SYMBOL (congestion_wait_interruptible); + +
Signature · 5 lines
-- 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>
PATCH 7/12 mm: count dirty pages per BDI
In reply to Peter ZijlstraCount per BDI dirty pages.
--- fs/buffer.c | 1 + include/linux/backing-dev.h | 1 + mm/page-writeback.c | 2 ++ mm/truncate.c | 1 + 4 files changed, 5 insertions(+)
fs/buffer.c +1 -0
@@ -740,6 +740,7 @@ int __set_page_dirty_buffers(struct pageif (page->mapping) {/* Race with truncate? */ if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY );task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
mm/page-writeback.c +2 -0
@@ -828,6 +828,7 @@ int __set_page_dirty_nobuffers(struct paBUG_ON (mapping2 != mapping);if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY );task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
@@ -961,6 +962,7 @@ int clear_page_dirty_for_io(struct page*/ if (TestClearPageDirty (page)) {dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_bdi_stat (mapping->backing_dev_info,BDI_DIRTY );return 1 ; }return 0 ;
mm/truncate.c +1 -0
@@ -71,6 +71,7 @@ void cancel_dirty_page(struct page *pagestruct address_space *mapping = page->mapping;if (mapping &&mapping_cap_account_dirty (mapping)) {dec_zone_page_state (page,NR_FILE_DIRTY ); +dec_bdi_stat (mapping->backing_dev_info,BDI_DIRTY );if (account_size)task_io_account_cancelled_write (account_size); }
include/linux/backing-dev.h +1 -0
@@ -26,6 +26,7 @@ enum bdi_state {typedef int (congested_fn )(void *,int );enum bdi_stat_item { +BDI_DIRTY ,NR_BDI_STAT_ITEMS };
Signature · 5 lines
-- 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>
PATCH 8/12 mm: count writeback pages per BDI
In reply to Peter ZijlstraCount per BDI writeback pages.
--- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
mm/page-writeback.c +10 -2
@@ -977,14 +977,18 @@ int test_clear_page_writeback(struct pagint ret;if (mapping) { +struct backing_dev_info *bdi = mapping->backing_dev_info;unsigned long flags;write_lock_irqsave (&mapping->tree_lock, flags); ret =TestClearPageWriteback (page); -if (ret) +if (ret) {radix_tree_tag_clear (&mapping->page_tree,page_index (page),PAGECACHE_TAG_WRITEBACK ); +if (bdi_cap_writeback_dirty (bdi)) +__dec_bdi_stat (bdi,BDI_WRITEBACK ); + }write_unlock_irqrestore (&mapping->tree_lock, flags); }else { ret =TestClearPageWriteback (page);
@@ -1000,14 +1004,18 @@ int test_set_page_writeback(struct pageint ret;if (mapping) { +struct backing_dev_info *bdi = mapping->backing_dev_info;unsigned long flags;write_lock_irqsave (&mapping->tree_lock, flags); ret =TestSetPageWriteback (page); -if (!ret) +if (!ret) {radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_WRITEBACK ); +if (bdi_cap_writeback_dirty (bdi)) +__inc_bdi_stat (bdi,BDI_WRITEBACK ); + }if (!PageDirty (page)) radix_tree_tag_clear(&mapping->page_tree, page_index(page),
include/linux/backing-dev.h +1 -0
@@ -27,6 +27,7 @@ typedef int (congested_fn)(void *, int);enum bdi_stat_item {BDI_DIRTY , +BDI_WRITEBACK ,NR_BDI_STAT_ITEMS };
Signature · 5 lines
-- 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>
PATCH 9/12 mm: count unstable pages per BDI
In reply to Peter ZijlstraCount per BDI unstable pages.
--- fs/nfs/write.c | 4 ++++ include/linux/backing-dev.h | 1 + 2 files changed, 5 insertions(+)
fs/nfs/write.c +4 -0
@@ -449,6 +449,7 @@ nfs_mark_request_commit(struct nfs_page nfsi->ncommit++;spin_unlock (&nfsi->req_lock);inc_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); +inc_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); __mark_inode_dirty(inode, I_DIRTY_DATASYNC); }#endif
@@ -509,6 +510,7 @@ static void nfs_cancel_commit_list(strucwhile (!list_empty (head)) { req =nfs_list_entry (head->next);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE );nfs_list_remove_request (req);nfs_inode_remove_request (req);nfs_unlock_request (req);
@@ -1234,6 +1236,7 @@ nfs_commit_list(struct inode *inode, strnfs_list_remove_request (req);nfs_mark_request_commit (req);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE );nfs_clear_page_writeback (req); }return -ENOMEM ;
@@ -1258,6 +1261,7 @@ static void nfs_commit_done(struct rpc_t req =nfs_list_entry (data->pages.next);nfs_list_remove_request (req);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); dprintk("NFS: commit (%s/%Ld %d@%Ld)", req->wb_context->dentry->d_inode->i_sb->s_id,
include/linux/backing-dev.h +1 -0
@@ -28,6 +28,7 @@ typedef int (congested_fn)(void *, int);enum bdi_stat_item {BDI_DIRTY ,BDI_WRITEBACK , +BDI_UNSTABLE ,NR_BDI_STAT_ITEMS };
Signature · 5 lines
-- 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>
Miklos Szeredi
maintainerRe: [PATCH 09/12] mm: count unstable pages per BDI
Quoted 2 lines
Count per BDI unstable pages.
I'm wondering, is it really worth having this category separate from per BDI brity pages?
With the exception of the export to sysfs, always the sum of unstable
+ dirty is used.
Miklos
--
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 09/12] mm: count unstable pages per BDI
Quoted 8 lines · Miklos Szeredi
Quoted 2 lines
Count per BDI unstable pages.
I'm wondering, is it really worth having this category separate from per BDI brity pages?
With the exception of the export to sysfs, always the sum of unstable
+ dirty is used.
I guess you are right, but it offends my sense of aesthetics to break symmetry with the zone statistics. However, it has the added advantage of only needing 2 deltas as well.
--
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 09/12] mm: count unstable pages per BDI
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Miklos Szeredi
Quoted 2 lines
Count per BDI unstable pages.
I'm wondering, is it really worth having this category separate from per BDI brity pages?
Quoted 6 lines
Quoted 2 lines
With the exception of the export to sysfs, always the sum of unstable
+ dirty is used.I guess you are right, but it offends my sense of aesthetics to break symmetry with the zone statistics. However, it has the added advantage of only needing 2 deltas as well.
I guess, this should do.
--- fs/buffer.c | 2 +- fs/nfs/write.c | 11 +++++++---- include/linux/backing-dev.h | 3 +-- mm/page-writeback.c | 16 +++++++--------- mm/truncate.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-)
fs/buffer.c +1 -1
@@ -733,7 +733,7 @@ int __set_page_dirty_buffers(struct pageif (page->mapping) {/* Race with truncate? */ if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIM );task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
fs/nfs/write.c +7 -4
@@ -456,7 +456,7 @@ nfs_mark_request_commit(struct nfs_page nfsi->ncommit++;spin_unlock (&nfsi->req_lock);inc_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); -inc_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); +inc_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_RECLAIM ); __mark_inode_dirty(inode, I_DIRTY_DATASYNC); }#endif
@@ -518,7 +518,8 @@ static void nfs_cancel_commit_list(strucwhile (!list_empty (head)) { req =nfs_list_entry (head->next);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); -dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info, +BDI_RECLAIM );nfs_list_remove_request (req);nfs_inode_remove_request (req);nfs_unlock_request (req);
@@ -1247,7 +1248,8 @@ nfs_commit_list(struct inode *inode, strnfs_list_remove_request (req);nfs_mark_request_commit (req);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); -dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info, +BDI_RECLAIM );nfs_clear_page_writeback (req); }return -ENOMEM ;
@@ -1272,7 +1274,8 @@ static void nfs_commit_done(struct rpc_t req =nfs_list_entry (data->pages.next);nfs_list_remove_request (req);dec_zone_page_state (req->wb_page,NR_UNSTABLE_NFS ); -dec_bdi_stat (req->wb_page->mapping->backing_dev_info,BDI_UNSTABLE ); +dec_bdi_stat (req->wb_page->mapping->backing_dev_info, +BDI_RECLAIM ); dprintk("NFS: commit (%s/%Ld %d@%Ld)", req->wb_context->dentry->d_inode->i_sb->s_id,
include/linux/backing-dev.h +1 -2
@@ -26,9 +26,8 @@ enum bdi_state {typedef int (congested_fn )(void *,int );enum bdi_stat_item { -BDI_DIRTY , +BDI_RECLAIM ,BDI_WRITEBACK , -BDI_UNSTABLE ,BDI_WRITEOUT ,NR_BDI_STAT_ITEMS };
mm/page-writeback.c +7 -9
@@ -300,8 +300,7 @@ static void balance_dirty_pages(struct aget_dirty_limits (&background_thresh, &dirty_thresh, &bdi_thresh, bdi); - bdi_nr_reclaimable =bdi_stat (bdi,BDI_DIRTY ) + -bdi_stat (bdi,BDI_UNSTABLE ); + bdi_nr_reclaimable =bdi_stat (bdi,BDI_RECLAIM ); bdi_nr_writeback =bdi_stat (bdi,BDI_WRITEBACK );if (bdi_nr_reclaimable + bdi_nr_writeback <= bdi_thresh)break ;
@@ -321,16 +320,14 @@ static void balance_dirty_pages(struct aget_dirty_limits (&background_thresh, &dirty_thresh, &bdi_thresh, bdi); -if (bdi_thresh <3 *bdi_stat_delta ()) { +if (bdi_thresh <2 *bdi_stat_delta ()) { bdi_nr_reclaimable = -bdi_stat_sum (bdi,BDI_DIRTY ) + -bdi_stat_sum (bdi,BDI_UNSTABLE ); +bdi_stat_sum (bdi,BDI_RECLAIM ); bdi_nr_writeback =bdi_stat_sum (bdi,BDI_WRITEBACK ); }else { bdi_nr_reclaimable = -bdi_stat (bdi,BDI_DIRTY ) + -bdi_stat (bdi,BDI_UNSTABLE ); +bdi_stat (bdi,BDI_RECLAIM ); bdi_nr_writeback =bdi_stat (bdi,BDI_WRITEBACK ); }
@@ -907,7 +904,8 @@ int __set_page_dirty_nobuffers(struct paBUG_ON (mapping2 != mapping);if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info, +BDI_RECLAIM );task_io_account_write (PAGE_CACHE_SIZE ); } radix_tree_tag_set(&mapping->page_tree,
@@ -1034,7 +1032,7 @@ int clear_page_dirty_for_io(struct pageset_page_dirty (page);if (TestClearPageDirty (page)) {dec_zone_page_state (page,NR_FILE_DIRTY ); -dec_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +dec_bdi_stat (mapping->backing_dev_info,BDI_RECLAIM );return 1 ; }return 0 ;
mm/truncate.c +1 -1
@@ -71,7 +71,7 @@ void cancel_dirty_page(struct page *pagestruct address_space *mapping = page->mapping;if (mapping &&mapping_cap_account_dirty (mapping)) {dec_zone_page_state (page,NR_FILE_DIRTY ); -dec_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +dec_bdi_stat (mapping->backing_dev_info,BDI_RECLAIM );if (account_size)task_io_account_cancelled_write (account_size); }
--
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 09/12] mm: count unstable pages per BDI
Quoted 8 lines · Peter Zijlstra
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Miklos Szeredi
Quoted 2 lines
Count per BDI unstable pages.
I'm wondering, is it really worth having this category separate from per BDI brity pages?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
With the exception of the export to sysfs, always the sum of unstable
+ dirty is used.I guess you are right, but it offends my sense of aesthetics to break symmetry with the zone statistics. However, it has the added advantage of only needing 2 deltas as well.
I guess, this should do.
OK, the compiler told me I messed up :-/. I'll respin the whole series and repost tomorrow or something...
--
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>
Miklos Szeredi
maintainerRe: [PATCH 09/12] mm: count unstable pages per BDI
In reply to Peter Zijlstrafs/buffer.c int __set_page_dirty_buffers(struct page · line 736
Quoted 10 lines
Index:
linux-2.6/fs/buffer.c
===================================================================fs/buffer.c +1
-1@@ -733,7 +733,7 @@ int __set_page_dirty_buffers(struct pageif (page->mapping) {/* Race with truncate? */ if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIM );
This name suggests it's _under_ reclaim, which is not true. You might rather want to call it BDI_RECLAIMABLE, or something similar in meaning.
Miklos
--
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 09/12] mm: count unstable pages per BDI
Quoted 6 lines · Miklos Szeredi
Quoted 6 lines
Index:
linux-2.6/fs/buffer.c
===================================================================fs/buffer.c +0
-0@@ -733,7 +733,7 @@ int __set_page_dirty_buffers(struct pageif (page->mapping) {/* Race with truncate? */
Quoted 8 lines
fs/buffer.c int __set_page_dirty_buffers(struct page · line 736
Quoted 4 lines
fs/buffer.c +1
-1if (mapping_cap_account_dirty (mapping)) {__inc_zone_page_state (page,NR_FILE_DIRTY ); -__inc_bdi_stat (mapping->backing_dev_info,BDI_DIRTY ); +__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIM );This name suggests it's _under_ reclaim, which is not true. You might rather want to call it
BDI_RECLAIMABLE, or something similar in meaning.
Yeah, my fingers got lazy on me :-) will instruct them to type more.
--
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>
PATCH 10/12 mm: expose BDI statistics in sysfs.
In reply to Peter ZijlstraExpose the per BDI stats in /sys/block/<dev>/queue/*
--- block/ll_rw_blk.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
block/ll_rw_blk.c +32 -0
@@ -3976,6 +3976,20 @@ static ssize_t queue_max_hw_sectors_showreturn queue_var_show (max_hw_sectors_kb, (page)); } +static ssize_t queue_nr_dirty_show (struct request_queue *q,char *page) +{ +return sprintf (page,"%lld\n" ,bdi_stat (&q->backing_dev_info,BDI_DIRTY )); +} + +static ssize_t queue_nr_writeback_show (struct request_queue *q,char *page) +{ +return sprintf (page,"%lld\n" ,bdi_stat (&q->backing_dev_info,BDI_WRITEBACK )); +} + +static ssize_t queue_nr_unstable_show (struct request_queue *q,char *page) +{ +return sprintf (page,"%lld\n" ,bdi_stat (&q->backing_dev_info,BDI_UNSTABLE )); +}static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name ="nr_requests" , .mode =S_IRUGO |S_IWUSR },
@@ -4006,6 +4020,21 @@ static struct queue_sysfs_entry queue_ma .show = queue_max_hw_sectors_show, }; +static struct queue_sysfs_entry queue_dirty_entry = { + .attr = {.name ="dirty_pages" , .mode =S_IRUGO }, + .show = queue_nr_dirty_show, +}; + +static struct queue_sysfs_entry queue_writeback_entry = { + .attr = {.name ="writeback_pages" , .mode =S_IRUGO }, + .show = queue_nr_writeback_show, +}; + +static struct queue_sysfs_entry queue_unstable_entry = { + .attr = {.name ="unstable_pages" , .mode =S_IRUGO }, + .show = queue_nr_unstable_show, +}; +static struct queue_sysfs_entry queue_iosched_entry = { .attr = {.name ="scheduler" , .mode =S_IRUGO |S_IWUSR }, .show = elv_iosched_show,
@@ -4018,6 +4047,9 @@ static struct attribute *default_attrs[] &queue_initial_ra_entry.attr, &queue_max_hw_sectors_entry.attr, &queue_max_sectors_entry.attr, + &queue_dirty_entry.attr, + &queue_writeback_entry.attr, + &queue_unstable_entry.attr, &queue_iosched_entry.attr, NULL, };
Signature · 5 lines
-- 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>
PATCH 11/12 mm: per device dirty threshold
In reply to Peter ZijlstraScale writeback cache per backing device, proportional to its writeout speed.
By decoupling the BDI dirty thresholds a number of problems we currently have will go away, namely:
- mutual interference starvation (for any number of BDIs);
- deadlocks with stacked BDIs (loop, FUSE and local NFS mounts).
It might be that all dirty pages are for a single BDI while other BDIs are idling. By giving each BDI a 'fair' share of the dirty limit, each one can have dirty pages outstanding and make progress.
A global threshold also creates a deadlock for stacked BDIs; when A writes to B, and A generates enough dirty pages to get throttled, B will never start writeback until the dirty pages go away. Again, by giving each BDI its own 'independent' dirty limit, this problem is avoided.
So the problem is to determine how to distribute the total dirty limit across the BDIs fairly and efficiently. A DBI that has a large dirty limit but does not have any dirty pages outstanding is a waste.
What is done is to keep a floating proportion between the DBIs based on writeback completions. This way faster/more active devices get a larger share than slower/idle devices.
--- include/linux/backing-dev.h | 48 +++++++++++ mm/backing-dev.c | 3 mm/page-writeback.c | 185 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 207 insertions(+), 29 deletions(-)
include/linux/backing-dev.h +48 -0
@@ -29,6 +29,7 @@ enum bdi_stat_item {BDI_DIRTY ,BDI_WRITEBACK ,BDI_UNSTABLE , +BDI_WRITEOUT , NR_BDI_STAT_ITEMS };
@@ -44,6 +45,13 @@ struct backing_dev_info {void *unplug_io_data;struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS ]; + +/* +* data used for scaling the writeback cache +*/ +spinlock_t lock;/* protect the cycle count */ +unsigned long cycles;/* writeout cycles */ +int dirty_exceeded; };void bdi_init (struct backing_dev_info *bdi);
@@ -55,6 +63,12 @@ static inline void __mod_bdi_stat(structpercpu_counter_mod (&bdi->bdi_stat[item], amount); } +static inline void __mod_bdi_stat64 (struct backing_dev_info *bdi, +enum bdi_stat_item item,s64 amount) +{ +percpu_counter_mod64 (&bdi->bdi_stat[item], amount); +} +static inline void __inc_bdi_stat (struct backing_dev_info *bdi,enum bdi_stat_item item) {
@@ -87,12 +101,46 @@ static inline void dec_bdi_stat(struct blocal_irq_restore (flags); } +static inline s64 __bdi_stat (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +return percpu_counter_read (&bdi->bdi_stat[item]); +} +static inline s64 bdi_stat (struct backing_dev_info *bdi,enum bdi_stat_item item) {return percpu_counter_read_positive (&bdi->bdi_stat[item]); } +static inline s64 __bdi_stat_sum (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +return percpu_counter_sum (&bdi->bdi_stat[item]); +} + +static inline s64 bdi_stat_sum (struct backing_dev_info *bdi, +enum bdi_stat_item item) +{ +s64 sum; +unsigned long flags; + +local_irq_save (flags); + sum =__bdi_stat_sum (bdi, item); +local_irq_restore (flags); + +return sum; +} + +static inline unsigned long bdi_stat_delta (void ) +{ +#ifdef CONFIG_SMP +return NR_CPUS *FBC_BATCH ; +#else +return 1UL ; +#endif +} +/* * Flags in backing_dev_info::capability * - The first two flags control whether dirty pages will contribute to the
mm/page-writeback.c +156 -29
275 lines not on this page · raw message
mm/backing-dev.c +3 -0
@@ -12,6 +12,9 @@ void bdi_init(struct backing_dev_info *bif (!(bdi_cap_writeback_dirty (bdi) ||bdi_cap_account_dirty (bdi)))return ; +spin_lock_init (&bdi->lock); + bdi->cycles =0 ; + bdi->dirty_exceeded =0 ;for (i =0 ; i <NR_BDI_STAT_ITEMS ; i++)percpu_counter_init (&bdi->bdi_stat[i],0 ); }
Signature · 5 lines
-- 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>
Miklos Szeredi
maintainerRe: [PATCH 11/12] mm: per device dirty threshold
include/linux/backing-dev.h static inline void dec_bdi_stat(struct b · line 138
Quoted 4 lines
include/linux/backing-dev.h +4
-0+static inline unsigned long bdi_stat_delta (void ) +{ +#ifdef CONFIG_SMP +return NR_CPUS *FBC_BATCH ;
Shouln't this be multiplied by the number of counters to sum? I.e. 3 if dirty and unstable are separate, and 2 if they are not.
Miklos
--
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 11/12] mm: per device dirty threshold
Quoted 7 lines · Miklos Szeredi
Review
Quoted 4 lines
(quoted diff) +4
-0+static inline unsigned long bdi_stat_delta(void) +{ +#ifdef CONFIG_SMP + return NR_CPUS * FBC_BATCH;Shouln't this be multiplied by the number of counters to sum? I.e. 3 if dirty and unstable are separate, and 2 if they are not.
Ah, yes, good catch. How about this:
---
Since we're adding 3 stat counters, tripple the per counter delta as well.
--- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page-writeback.c +1 -1
@@ -321,7 +321,7 @@ static void balance_dirty_pages(struct aget_dirty_limits (&background_thresh, &dirty_thresh, &bdi_thresh, bdi); -if (bdi_thresh <bdi_stat_delta ()) { +if (bdi_thresh <3 *bdi_stat_delta ()) { bdi_nr_reclaimable =bdi_stat_sum (bdi,BDI_DIRTY ) +bdi_stat_sum (bdi,BDI_UNSTABLE );
--
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>
PATCH 12/12 debug: expose BDI statistics in sysfs.
In reply to Peter ZijlstraExpose the per BDI stats in /sys/block/<dev>/queue/*
--- block/ll_rw_blk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ mm/page-writeback.c | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-)
block/ll_rw_blk.c +49 -0
@@ -3991,6 +3991,37 @@ static ssize_t queue_nr_unstable_show(streturn sprintf (page,"%lld\n" ,bdi_stat (&q->backing_dev_info,BDI_UNSTABLE )); } +extern void get_writeout_scale (struct backing_dev_info *,int *,int *); + +static ssize_t queue_nr_cache_ratio_show (struct request_queue *q,char *page) +{ +int scale, div; + +get_writeout_scale (&q->backing_dev_info, &scale, &div); + scale *=1024 ; + scale /= div; + +return sprintf (page,"%d\n" , scale); +} + +extern void +get_dirty_limits (long *pbackground,long *pdirty,long *pbdi_dirty, +struct backing_dev_info *bdi); + +static ssize_t queue_nr_cache_size_show (struct request_queue *q,char *page) +{ +long background, dirty, bdi_dirty; +get_dirty_limits (&background, &dirty, &bdi_dirty, &q->backing_dev_info); +return sprintf (page,"%ld\n" , bdi_dirty); +} + +static ssize_t queue_nr_cache_total_show (struct request_queue *q,char *page) +{ +long background, dirty, bdi_dirty; +get_dirty_limits (&background, &dirty, &bdi_dirty, &q->backing_dev_info); +return sprintf (page,"%ld\n" , dirty); +} +static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name ="nr_requests" , .mode =S_IRUGO |S_IWUSR }, .show = queue_requests_show,
@@ -4035,6 +4066,21 @@ static struct queue_sysfs_entry queue_un .show = queue_nr_unstable_show, }; +static struct queue_sysfs_entry queue_cache_ratio_entry = { + .attr = {.name ="cache_ratio" , .mode =S_IRUGO }, + .show = queue_nr_cache_ratio_show, +}; + +static struct queue_sysfs_entry queue_cache_size_entry = { + .attr = {.name ="cache_size" , .mode =S_IRUGO }, + .show = queue_nr_cache_size_show, +}; + +static struct queue_sysfs_entry queue_cache_total_entry = { + .attr = {.name ="cache_total" , .mode =S_IRUGO }, + .show = queue_nr_cache_total_show, +}; +static struct queue_sysfs_entry queue_iosched_entry = { .attr = {.name ="scheduler" , .mode =S_IRUGO |S_IWUSR }, .show = elv_iosched_show,
@@ -4050,6 +4096,9 @@ static struct attribute *default_attrs[] &queue_dirty_entry.attr, &queue_writeback_entry.attr, &queue_unstable_entry.attr, + &queue_cache_ratio_entry.attr, + &queue_cache_size_entry.attr, + &queue_cache_total_entry.attr, &queue_iosched_entry.attr, NULL, };
mm/page-writeback.c +1 -1
@@ -237,7 +237,7 @@ static unsigned long determine_dirtyablereturn x +1 ;/* Ensure that we never return 0 */ } -static void +void get_dirty_limits (long *pbackground,long *pdirty,long *pbdi_dirty,struct backing_dev_info *bdi) {
Signature · 5 lines
-- 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>