]> git.hungrycats.org Git - linux/commitdiff
[PATCH] overcommit symbolic constants
authorAndries E. Brouwer <andries.brouwer@cwi.nl>
Thu, 30 Sep 2004 01:41:37 +0000 (18:41 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 30 Sep 2004 01:41:37 +0000 (18:41 -0700)
Played a bit with overcommit the past hour.

Am not entirely satisfied with the no overcommit mode 2 -
programs segfault when the system is close to that boundary.
So, instead of the somewhat larger patch that I planned to send,
just symbolic names for the modes.

Documentation/vm/overcommit-accounting
arch/arm/mm/init.c
arch/arm26/mm/init.c
include/linux/mman.h
mm/mmap.c
mm/nommu.c
security/commoncap.c
security/dummy.c
security/selinux/hooks.c

index e0fd0b8f037aae48ce5e5acea377025e6d180da9..9db560eba20395979d95610c09ff8dc3ff3c73d4 100644 (file)
@@ -1,4 +1,4 @@
-The Linux kernel supports three overcommit handling modes
+The Linux kernel supports the following overcommit handling modes
 
 0      -       Heuristic overcommit handling. Obvious overcommits of
                address space are refused. Used for a typical system. It
@@ -7,10 +7,10 @@ The Linux kernel supports three overcommit handling modes
                allocate slighly more memory in this mode. This is the 
                default.
 
-1      -       No overcommit handling. Appropriate for some scientific
+1      -       Always overcommit. Appropriate for some scientific
                applications.
 
-2      -       (NEW) strict overcommit. The total address space commit
+2      -       Don't overcommit. The total address space commit
                for the system is not permitted to exceed swap + a
                configurable percentage (default is 50) of physical RAM.
                Depending on the percentage you use, in most situations
@@ -27,7 +27,7 @@ Gotchas
 
 The C language stack growth does an implicit mremap. If you want absolute
 guarantees and run close to the edge you MUST mmap your stack for the 
-largest size you think you will need. For typical stack usage is does
+largest size you think you will need. For typical stack usage this does
 not matter much but it's a corner case if you really really care
 
 In mode 2 the MAP_NORESERVE flag is ignored. 
index bbf23e1bc336135779be3057d56293373752a2bd..927b380ba7d412403d1d3bd61dff22006df3e79d 100644 (file)
@@ -590,7 +590,7 @@ void __init mem_init(void)
                 * anywhere without overcommit, so turn
                 * it on by default.
                 */
-               sysctl_overcommit_memory = 1;
+               sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
        }
 }
 
index ae5ced10d987df785670d20d74c07fa4c0e65238..17f7dc3e9fb4cd43bf460bcf55f2b85e23e53a83 100644 (file)
@@ -376,7 +376,7 @@ void __init mem_init(void)
         * Turn on overcommit on tiny machines
         */
        if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
-               sysctl_overcommit_memory = 1;
+               sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
                printk("Turning on overcommit\n");
        }
 }
index 07da84fcbd153d36c255af397f318e230fe15b6d..18a5689ef748c569b43dfbaf9fe3bcde0243fc31 100644 (file)
@@ -10,6 +10,9 @@
 #define MREMAP_MAYMOVE 1
 #define MREMAP_FIXED   2
 
+#define OVERCOMMIT_GUESS               0
+#define OVERCOMMIT_ALWAYS              1
+#define OVERCOMMIT_NEVER               2
 extern int sysctl_overcommit_memory;
 extern int sysctl_overcommit_ratio;
 extern atomic_t vm_committed_space;
index 6738d1b397bce40013ffb0538451038a83842878..4bd891b1bea0a4de3fc5a05f6c7d7b6519f1ef93 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -54,7 +54,7 @@ pgprot_t protection_map[16] = {
        __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
 };
 
-int sysctl_overcommit_memory = 0;      /* default is heuristic overcommit */
+int sysctl_overcommit_memory = OVERCOMMIT_GUESS;  /* heuristic overcommit */
 int sysctl_overcommit_ratio = 50;      /* default is 50% */
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
 atomic_t vm_committed_space = ATOMIC_INIT(0);
@@ -907,7 +907,7 @@ munmap_back:
                return -ENOMEM;
 
        if (accountable && (!(flags & MAP_NORESERVE) ||
-                       sysctl_overcommit_memory > 1)) {
+                           sysctl_overcommit_memory == OVERCOMMIT_NEVER)) {
                if (vm_flags & VM_SHARED) {
                        /* Check memory availability in shmem_file_setup? */
                        vm_flags |= VM_ACCOUNT;
index 114c0ccb4ee61c424afcc28164e4c27ccb8e449b..dd4b66b8c9a6dff09e59a33cda029a035521f65f 100644 (file)
@@ -30,7 +30,7 @@ unsigned long max_mapnr;
 unsigned long num_physpages;
 unsigned long askedalloc, realalloc;
 atomic_t vm_committed_space = ATOMIC_INIT(0);
-int sysctl_overcommit_memory; /* default is heuristic overcommit */
+int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
 int sysctl_overcommit_ratio = 50; /* default is 50% */
 
 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
index 217bbab2701e9398beee40351f439ac5b73d6c08..ed0d6136f6fc9ebaa8176deb5fdb3f1348ea8261 100644 (file)
@@ -314,10 +314,10 @@ int cap_vm_enough_memory(long pages)
        /*
         * Sometimes we want to use more memory than we have
         */
-       if (sysctl_overcommit_memory == 1)
+       if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
                return 0;
 
-       if (sysctl_overcommit_memory == 0) {
+       if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
                unsigned long n;
 
                free = get_page_cache_size();
index 05d9885886eba10c245a30c18f3861ee66340cef..a9e69659533ebd97692317469bfc54a8556ef21a 100644 (file)
@@ -121,10 +121,10 @@ static int dummy_vm_enough_memory(long pages)
        /*
         * Sometimes we want to use more memory than we have
         */
-       if (sysctl_overcommit_memory == 1)
+       if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
                return 0;
 
-       if (sysctl_overcommit_memory == 0) {
+       if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
                free = get_page_cache_size();
                free += nr_free_pages();
                free += nr_swap_pages;
index 3dbd39c5a1db75a742cb64046cdc328e17c9c89c..d25ed880944ad4301b5f99d6cb6640170a5b1bfd 100644 (file)
@@ -1554,10 +1554,10 @@ static int selinux_vm_enough_memory(long pages)
         /*
         * Sometimes we want to use more memory than we have
         */
-       if (sysctl_overcommit_memory == 1)
+       if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
                return 0;
 
-       if (sysctl_overcommit_memory == 0) {
+       if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
                free = get_page_cache_size();
                free += nr_free_pages();
                free += nr_swap_pages;