Currently the VM decides to start doing background writeback of pages if 10% of the systems pages are dirty, and starts doing synchronous writeback of pages if 40% are dirty. This is great for smaller memory systems, but in larger memory systems (>2GB or so), a process can dirty ALL of lowmem (ZONE_NORMAL, 896MB) without hitting the 40% dirty page ratio needed to force the process to do writeback. For this and other reasons, it'd be nice to have a zone aware dirty page balancer. That is precisely what these 2 patches try to achieve. Patch 1/2 - setup_perzone_counters.patch: This patch does the following things: 1) balance_dirty_pages uses the first 6 statistics in struct page_state (nr_dirty, nr_writeback, nr_unstable, nr_page_table_pages, nr_mapped, and nr_slab) to determine when to start writeback. These stats must therefore be maintained on a per-zone basis. Create a new struct perzone_page_state which contains these statistics and embed an array of length NR_CPUS of these structures in struct zone. 2) Add a set of macros mirroring the (mod|inc|dec)_page_state macros called (mod|inc|dec)_perzone_page_state to update the per-zone page state stats. 3) Replace all occurences(*) of (mod|inc|dec)_page_state calls that modify the per-zone stats with the per-zone versions of the macros. 4) Modify the get_page_state and get_full_page_state calls to correctly gather all the page stats. 5) Add a get_page_state_zone call to get the page stats for a specific zone. (*) The (mod|inc|dec)_page_state calls in the NFS code have given me some trouble. To determine which zone's statistics to modify, we must have a struct page handy, but the NFS code does it's statistics updates in bulk, without reference in most cases to the pages. Thus, the NFS code still needs updating, and is noted in the patch. Comments/criticism requested! :) Cheers! -Matt