]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] mm: balance dirty pages
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Tue, 26 Sep 2006 06:30:58 +0000 (23:30 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 26 Sep 2006 15:48:44 +0000 (08:48 -0700)
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>
include/linux/writeback.h
mm/memory.c
mm/page-writeback.c

index 0422036af4ebb2ba99c3ca7f05775aa53a03226a..56a23a0e7f2eb218a91fd889fb86bbdb3471bcef 100644 (file)
@@ -116,6 +116,7 @@ int sync_page_range(struct inode *inode, struct address_space *mapping,
                        loff_t pos, loff_t count);
 int sync_page_range_nolock(struct inode *inode, struct address_space *mapping,
                           loff_t pos, loff_t count);
+void set_page_dirty_balance(struct page *page);
 
 /* pdflush.c */
 extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
index fa941b169071d4573b3deb6bb0dd0cb2f2856c17..dd7d7fc5ed609267f15f7ead6bcc19838cb4b408 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/module.h>
 #include <linux/delayacct.h>
 #include <linux/init.h>
+#include <linux/writeback.h>
 
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
@@ -1571,7 +1572,7 @@ gotten:
 unlock:
        pte_unmap_unlock(page_table, ptl);
        if (dirty_page) {
-               set_page_dirty(dirty_page);
+               set_page_dirty_balance(dirty_page);
                put_page(dirty_page);
        }
        return ret;
@@ -2218,7 +2219,7 @@ retry:
 unlock:
        pte_unmap_unlock(page_table, ptl);
        if (dirty_page) {
-               set_page_dirty(dirty_page);
+               set_page_dirty_balance(dirty_page);
                put_page(dirty_page);
        }
        return ret;
index 1c87430b7a25ea40f74397502e285d5b1fed671f..b9f4c6f1be8603be6cc76c13de40393aedc86202 100644 (file)
@@ -244,6 +244,16 @@ static void balance_dirty_pages(struct address_space *mapping)
                pdflush_operation(background_writeout, 0);
 }
 
+void set_page_dirty_balance(struct page *page)
+{
+       if (set_page_dirty(page)) {
+               struct address_space *mapping = page_mapping(page);
+
+               if (mapping)
+                       balance_dirty_pages_ratelimited(mapping);
+       }
+}
+
 /**
  * balance_dirty_pages_ratelimited_nr - balance dirty memory state
  * @mapping: address_space which was dirtied