aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swap_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swap_state.c')
-rw-r--r--mm/swap_state.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 71ce2d1ccbf7..ed91091d1e68 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -242,6 +242,17 @@ int add_to_swap(struct page *page)
242 * clear SWAP_HAS_CACHE flag. 242 * clear SWAP_HAS_CACHE flag.
243 */ 243 */
244 goto fail; 244 goto fail;
245 /*
246 * Normally the page will be dirtied in unmap because its pte should be
247 * dirty. A special case is MADV_FREE page. The page'e pte could have
248 * dirty bit cleared but the page's SwapBacked bit is still set because
249 * clearing the dirty bit and SwapBacked bit has no lock protected. For
250 * such page, unmap will not set dirty bit for it, so page reclaim will
251 * not write the page out. This can cause data corruption when the page
252 * is swap in later. Always setting the dirty bit for the page solves
253 * the problem.
254 */
255 set_page_dirty(page);
245 256
246 return 1; 257 return 1;
247 258