page-writeback.c: subtract min_free_kbytes from dirtyable memory
authorPaul Szabo <psz@maths.usyd.edu.au>
Sat, 23 Feb 2013 00:34:42 +0000 (16:34 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 24 Feb 2013 01:50:17 +0000 (17:50 -0800)
When calculating amount of dirtyable memory, min_free_kbytes should be
subtracted because it is not intended for dirty pages.

Addresses http://bugs.debian.org/695182

[akpm@linux-foundation.org: fix up min_free_kbytes extern declarations]
[akpm@linux-foundation.org: fix min() warning]
Signed-off-by: Paul Szabo <psz@maths.usyd.edu.au>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/mm.h
kernel/sysctl.c
mm/huge_memory.c
mm/page-writeback.c

index 1d4122bf6f275de8677e721c3a5b2f84108a32ae..437da0ce78c705cf1479ca321c1061ad03931a68 100644 (file)
@@ -1393,6 +1393,9 @@ extern void setup_per_cpu_pageset(void);
 extern void zone_pcp_update(struct zone *zone);
 extern void zone_pcp_reset(struct zone *zone);
 
+/* page_alloc.c */
+extern int min_free_kbytes;
+
 /* nommu.c */
 extern atomic_long_t mmap_pages_allocated;
 extern int nommu_shrink_inode_mappings(struct inode *, size_t, size_t);
index 467d8b923fcdad7a55dce597e80dd39eab170230..95e9e55602a8f98e7eda11c58a017db20f23c4f2 100644 (file)
@@ -105,7 +105,6 @@ extern char core_pattern[];
 extern unsigned int core_pipe_limit;
 #endif
 extern int pid_max;
-extern int min_free_kbytes;
 extern int pid_max_min, pid_max_max;
 extern int sysctl_drop_caches;
 extern int percpu_pagelist_fraction;
index b1cc6591ed8341bbf5183d5c89aafd60d9fd77c1..c63a21d0e9916ee979a0ba44a9ed946043ae43ad 100644 (file)
@@ -105,7 +105,6 @@ static int set_recommended_min_free_kbytes(void)
        struct zone *zone;
        int nr_zones = 0;
        unsigned long recommended_min;
-       extern int min_free_kbytes;
 
        if (!khugepaged_enabled())
                return 0;
index 7300c9d5e1d999f9f68a17590f260de297ad9cbe..cdc377c456c0314ecdf8e20b2cdd881a2d88c814 100644 (file)
@@ -241,6 +241,9 @@ static unsigned long global_dirtyable_memory(void)
        if (!vm_highmem_is_dirtyable)
                x -= highmem_dirtyable_memory(x);
 
+       /* Subtract min_free_kbytes */
+       x -= min_t(unsigned long, x, min_free_kbytes >> (PAGE_SHIFT - 10));
+
        return x + 1;   /* Ensure that we never return 0 */
 }