]> git.hungrycats.org Git - linux/commitdiff
[PATCH] scale the initial value of min_free_kbytes
authorAndrew Morton <akpm@osdl.org>
Mon, 29 Dec 2003 13:42:58 +0000 (05:42 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 29 Dec 2003 13:42:58 +0000 (05:42 -0800)
This tunable refers to the amount of free memory which the VM will attempt to
sustain.  It is mainly needed for atomic allocations (eg, networking
receive).

It is currently hardwired to 1024k, which is far too large for small machines
and too small for large machines.

Rework it to be 128k on tiny machines and 16M on huge machines.

include/linux/mmzone.h
init/main.c
mm/page_alloc.c

index bea51c4f5b22f3a582ade07e1471a1f4a6efab66..c85e050c31041116b2c20685f32e6c53b871360a 100644 (file)
@@ -284,8 +284,6 @@ struct ctl_table;
 struct file;
 int min_free_kbytes_sysctl_handler(struct ctl_table *, int, struct file *, 
                                          void *, size_t *);
-extern void setup_per_zone_pages_min(void);
-
 
 #ifdef CONFIG_NUMA
 #define MAX_NR_MEMBLKS BITS_PER_LONG /* Max number of Memory Blocks */
index 8fee009060dc2ad25a973aec85a057b6ad14d5bd..78536ea28c9f176b1ab2138abf1450ba7270c6cc 100644 (file)
@@ -396,7 +396,6 @@ asmlinkage void __init start_kernel(void)
        lock_kernel();
        printk(linux_banner);
        setup_arch(&command_line);
-       setup_per_zone_pages_min();
        setup_per_cpu_areas();
 
        /*
index f7e0ff65f06284cedc14182dfad3197c4a6a29c8..49f9d1ca3625c612120e81aaea22d6a87f2b574f 100644 (file)
@@ -1589,7 +1589,7 @@ void __init page_alloc_init(void)
  *     that the pages_{min,low,high} values for each zone are set correctly 
  *     with respect to min_free_kbytes.
  */
-void setup_per_zone_pages_min(void)
+static void setup_per_zone_pages_min(void)
 {
        unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10);
        unsigned long lowmem_pages = 0;
@@ -1632,6 +1632,45 @@ void setup_per_zone_pages_min(void)
        }
 }
 
+/*
+ * Initialise min_free_kbytes.
+ *
+ * For small machines we want it small (128k min).  For large machines
+ * we want it large (16MB max).  But it is not linear, because network
+ * bandwidth does not increase linearly with machine size.  We use
+ *
+ *     min_free_kbytes = sqrt(lowmem_kbytes)
+ *
+ * which yields
+ *
+ * 16MB:       128k
+ * 32MB:       181k
+ * 64MB:       256k
+ * 128MB:      362k
+ * 256MB:      512k
+ * 512MB:      724k
+ * 1024MB:     1024k
+ * 2048MB:     1448k
+ * 4096MB:     2048k
+ * 8192MB:     2896k
+ * 16384MB:    4096k
+ */
+static int __init init_per_zone_pages_min(void)
+{
+       unsigned long lowmem_kbytes;
+
+       lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
+
+       min_free_kbytes = int_sqrt(lowmem_kbytes);
+       if (min_free_kbytes < 128)
+               min_free_kbytes = 128;
+       if (min_free_kbytes > 16384)
+               min_free_kbytes = 16384;
+       setup_per_zone_pages_min();
+       return 0;
+}
+module_init(init_per_zone_pages_min)
+
 /*
  * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so 
  *     that we can call setup_per_zone_pages_min() whenever min_free_kbytes