ksm: fix deadlock with munlock in exit_mmap
[firefly-linux-kernel-4.4.55.git] / mm / page-writeback.c
index 12c3d843ce93106acf23a5139243ec3a8dccd33c..5f378dd588027c227dc95551e27e4b6431e5df60 100644 (file)
@@ -380,7 +380,8 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
                struct zone *z =
                        &NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
 
-               x += zone_page_state(z, NR_FREE_PAGES) + zone_lru_pages(z);
+               x += zone_page_state(z, NR_FREE_PAGES) +
+                    zone_reclaimable_pages(z);
        }
        /*
         * Make sure that the number of highmem pages is never larger
@@ -404,7 +405,7 @@ unsigned long determine_dirtyable_memory(void)
 {
        unsigned long x;
 
-       x = global_page_state(NR_FREE_PAGES) + global_lru_pages();
+       x = global_page_state(NR_FREE_PAGES) + global_reclaimable_pages();
 
        if (!vm_highmem_is_dirtyable)
                x -= highmem_dirtyable_memory(x);
@@ -485,6 +486,7 @@ static void balance_dirty_pages(struct address_space *mapping)
        unsigned long bdi_thresh;
        unsigned long pages_written = 0;
        unsigned long write_chunk = sync_writeback_pages();
+       unsigned long pause = 1;
 
        struct backing_dev_info *bdi = mapping->backing_dev_info;
 
@@ -561,7 +563,15 @@ static void balance_dirty_pages(struct address_space *mapping)
                if (pages_written >= write_chunk)
                        break;          /* We've done our duty */
 
-               schedule_timeout(1);
+               schedule_timeout_interruptible(pause);
+
+               /*
+                * Increase the delay for each loop, up to our previous
+                * default of taking a 100ms nap.
+                */
+               pause <<= 1;
+               if (pause > HZ / 10)
+                       pause = HZ / 10;
        }
 
        if (bdi_nr_reclaimable + bdi_nr_writeback < bdi_thresh &&
@@ -582,16 +592,8 @@ static void balance_dirty_pages(struct address_space *mapping)
        if ((laptop_mode && pages_written) ||
            (!laptop_mode && ((nr_writeback = global_page_state(NR_FILE_DIRTY)
                                          + global_page_state(NR_UNSTABLE_NFS))
-                                         > background_thresh))) {
-               struct writeback_control wbc = {
-                       .bdi            = bdi,
-                       .sync_mode      = WB_SYNC_NONE,
-                       .nr_to_write    = nr_writeback,
-               };
-
-
-               bdi_start_writeback(&wbc);
-       }
+                                         > background_thresh)))
+               bdi_start_writeback(bdi, nr_writeback);
 }
 
 void set_page_dirty_balance(struct page *page, int page_mkwrite)