Commit edc79b2a46ed854595e40edcf3f8b37f9f14aa3f
Committed by
Linus Torvalds
1 parent
d08b3851da
Exists in
master
and in
20 other branches
[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>
Showing 3 changed files with 14 additions and 2 deletions Side-by-side Diff
include/linux/writeback.h
... | ... | @@ -116,6 +116,7 @@ |
116 | 116 | loff_t pos, loff_t count); |
117 | 117 | int sync_page_range_nolock(struct inode *inode, struct address_space *mapping, |
118 | 118 | loff_t pos, loff_t count); |
119 | +void set_page_dirty_balance(struct page *page); | |
119 | 120 | |
120 | 121 | /* pdflush.c */ |
121 | 122 | extern int nr_pdflush_threads; /* Global so it can be exported to sysctl |
mm/memory.c
... | ... | @@ -49,6 +49,7 @@ |
49 | 49 | #include <linux/module.h> |
50 | 50 | #include <linux/delayacct.h> |
51 | 51 | #include <linux/init.h> |
52 | +#include <linux/writeback.h> | |
52 | 53 | |
53 | 54 | #include <asm/pgalloc.h> |
54 | 55 | #include <asm/uaccess.h> |
... | ... | @@ -1571,7 +1572,7 @@ |
1571 | 1572 | unlock: |
1572 | 1573 | pte_unmap_unlock(page_table, ptl); |
1573 | 1574 | if (dirty_page) { |
1574 | - set_page_dirty(dirty_page); | |
1575 | + set_page_dirty_balance(dirty_page); | |
1575 | 1576 | put_page(dirty_page); |
1576 | 1577 | } |
1577 | 1578 | return ret; |
... | ... | @@ -2218,7 +2219,7 @@ |
2218 | 2219 | unlock: |
2219 | 2220 | pte_unmap_unlock(page_table, ptl); |
2220 | 2221 | if (dirty_page) { |
2221 | - set_page_dirty(dirty_page); | |
2222 | + set_page_dirty_balance(dirty_page); | |
2222 | 2223 | put_page(dirty_page); |
2223 | 2224 | } |
2224 | 2225 | return ret; |
mm/page-writeback.c
... | ... | @@ -244,6 +244,16 @@ |
244 | 244 | pdflush_operation(background_writeout, 0); |
245 | 245 | } |
246 | 246 | |
247 | +void 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 | 258 | * balance_dirty_pages_ratelimited_nr - balance dirty memory state |
249 | 259 | * @mapping: address_space which was dirtied |