aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2006-09-26 02:30:58 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:48:44 -0400
commitedc79b2a46ed854595e40edcf3f8b37f9f14aa3f (patch)
treec1120bebede9660ab00f9439aa7a84ab9434ac38 /mm
parentd08b3851da41d0ee60851f2c75b118e1f7a5fc89 (diff)
[PATCH] mm: balance dirty pages
Now that we can detect writers of shared mappings, throttle them. Avoids OOM by surprise. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c5
-rw-r--r--mm/page-writeback.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/mm/memory.c b/mm/memory.c
index fa941b169071..dd7d7fc5ed60 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -49,6 +49,7 @@
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/delayacct.h> 50#include <linux/delayacct.h>
51#include <linux/init.h> 51#include <linux/init.h>
52#include <linux/writeback.h>
52 53
53#include <asm/pgalloc.h> 54#include <asm/pgalloc.h>
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
@@ -1571,7 +1572,7 @@ gotten:
1571unlock: 1572unlock:
1572 pte_unmap_unlock(page_table, ptl); 1573 pte_unmap_unlock(page_table, ptl);
1573 if (dirty_page) { 1574 if (dirty_page) {
1574 set_page_dirty(dirty_page); 1575 set_page_dirty_balance(dirty_page);
1575 put_page(dirty_page); 1576 put_page(dirty_page);
1576 } 1577 }
1577 return ret; 1578 return ret;
@@ -2218,7 +2219,7 @@ retry:
2218unlock: 2219unlock:
2219 pte_unmap_unlock(page_table, ptl); 2220 pte_unmap_unlock(page_table, ptl);
2220 if (dirty_page) { 2221 if (dirty_page) {
2221 set_page_dirty(dirty_page); 2222 set_page_dirty_balance(dirty_page);
2222 put_page(dirty_page); 2223 put_page(dirty_page);
2223 } 2224 }
2224 return ret; 2225 return ret;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 1c87430b7a25..b9f4c6f1be86 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -244,6 +244,16 @@ static void balance_dirty_pages(struct address_space *mapping)
244 pdflush_operation(background_writeout, 0); 244 pdflush_operation(background_writeout, 0);
245} 245}
246 246
247void set_page_dirty_balance(struct page *page)
248{
249 if (set_page_dirty(page)) {
250 struct address_space *mapping = page_mapping(page);
251
252 if (mapping)
253 balance_dirty_pages_ratelimited(mapping);
254 }
255}
256
247/** 257/**
248 * balance_dirty_pages_ratelimited_nr - balance dirty memory state 258 * balance_dirty_pages_ratelimited_nr - balance dirty memory state
249 * @mapping: address_space which was dirtied 259 * @mapping: address_space which was dirtied