From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 12/27] nfs: lower writeback threshold proportionally to dirty threshold Date: Thu, 03 Mar 2011 14:45:17 +0800 Message-ID: <20110303074950.195446002@intel.com> References: <20110303064505.718671603@intel.com> Cc: Jan Kara , Trond Myklebust , Wu Fengguang To: Andrew Morton Return-path: CC: Christoph Hellwig CC: Dave Chinner CC: Theodore Ts'o CC: Chris Mason CC: Peter Zijlstra CC: Mel Gorman CC: Rik van Riel CC: KOSAKI Motohiro CC: Greg Thelen CC: Minchan Kim CC: Vivek Goyal CC: Andrea Righi CC: Balbir Singh Cc: linux-mm Cc: Cc: LKML Content-Disposition: inline; filename=nfs-congestion-thresh.patch Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org nfs_congestion_kb is to control the max allowed writeback and in-commit pages. It's not reasonable for them to outnumber dirty and to-commit pages. So each of them should not take more than 1/4 dirty threshold. Considering that nfs_init_writepagecache() is called on fresh boot, at the time dirty_thresh is much higher than the real dirty limit after lots of user space memory consumptions, use 1/8 instead. We might update nfs_congestion_kb when global dirty limit is changed at runtime, but whatever, do it simple first. CC: Trond Myklebust Signed-off-by: Wu Fengguang --- fs/nfs/write.c | 13 +++++++++++++ mm/page-writeback.c | 1 + 2 files changed, 14 insertions(+) --- linux-next.orig/fs/nfs/write.c 2011-03-03 14:04:01.000000000 +0800 +++ linux-next/fs/nfs/write.c 2011-03-03 14:04:01.000000000 +0800 @@ -1651,6 +1651,9 @@ out: int __init nfs_init_writepagecache(void) { + unsigned long background_thresh; + unsigned long dirty_thresh; + nfs_wdata_cachep = kmem_cache_create("nfs_write_data", sizeof(struct nfs_write_data), 0, SLAB_HWCACHE_ALIGN, @@ -1688,6 +1691,16 @@ int __init nfs_init_writepagecache(void) if (nfs_congestion_kb > 256*1024) nfs_congestion_kb = 256*1024; + /* + * Limit to 1/8 dirty threshold, so that writeback+in_commit pages + * won't overnumber dirty+to_commit pages. + */ + global_dirty_limits(&background_thresh, &dirty_thresh); + dirty_thresh <<= PAGE_SHIFT - 10; + + if (nfs_congestion_kb > dirty_thresh / 8) + nfs_congestion_kb = dirty_thresh / 8; + return 0; } --- linux-next.orig/mm/page-writeback.c 2011-03-03 14:04:01.000000000 +0800 +++ linux-next/mm/page-writeback.c 2011-03-03 14:04:01.000000000 +0800 @@ -431,6 +431,7 @@ void global_dirty_limits(unsigned long * *pbackground = background; *pdirty = dirty; } +EXPORT_SYMBOL_GPL(global_dirty_limits); /** * bdi_dirty_limit - @bdi's share of dirty throttling threshold -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org