strict VM overcommit
Subsystems (9)
PATCH 1/1 strict VM overcommit
The attached patch implements strict VM overcommit on top of the rmap VM.
The basis for this is Alan Cox's work in 2.4-ac. This is a port of the strict VM overcommit out of 2.4-ac and into the standard kernel with the following changes:
- one or two bugfixes (have sent/will send to Alan)
- some cleanups, mostly for coding style
- I did not bring over the debugging code
- new overcommit policy for swapless machines
So what is strict VM overcommit? We introduce new overcommit policies that attempt to never succeed an allocation that can not be fulfilled by the backing store and consequently never OOM. This is achieved through strict accounting of the committed address space and a policy to allow/refuse allocations based on that accounting.
In the strictest of modes, it should be impossible to allocate more memory than available and impossible to OOM. All memory failures should be pushed down to the allocation routines -- malloc, mmap, etc.
The new modes are available via sysctl (same as before). See Documentation/vm/overcommit-accounting for more information.
Again, Alan deserves the credit for the design of all this.
The patch is against 2.4.19-pre7-rmap13b but should apply to later releases with little trouble.
Enjoy,
Robert Love
Documentation/sysctl/vm.txt +5 -1
@@ -167,7 +167,11 @@ programs that malloc() huge amounts of memory "just-in-case" and don't use much of it. -Look at: mm/mmap.c::vm_enough_memory() for more information. +Flag values of 2 - 4 introduce a new "strict overcommit" +policy that attempt to prevent any overcommit of memory. + +See Documentation/vm/overcommit-accounting and +mm/mmap.c::vm_enough_memory() for more information. ==============================================================
Documentation/vm/overcommit-accounting +77 -0
77 lines not on this page · raw message
fs/exec.c +7 -2
@@ -308,8 +308,13 @@ mpnt =kmem_cache_alloc (vm_area_cachep,SLAB_KERNEL );if (!mpnt) -return -ENOMEM ; - +return -ENOMEM ; + +if (!vm_enough_memory ((STACK_TOP - (PAGE_MASK & (unsigned long ) bprm->p)) >>PAGE_SHIFT ,1 )) { +kmem_cache_free (vm_area_cachep, mpnt); +return -ENOMEM ; + } +down_write (¤t->mm->mmap_sem); { mpnt->vm_mm = current->mm;
fs/proc/proc_misc.c +8 -3
@@ -131,12 +131,14 @@return proc_calc_metrics (page, start, off, count, eof, len); } +extern atomic_t vm_committed_space; +static int meminfo_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data) {struct sysinfo i;int len; -int pg_size ; +int pg_size, committed;/* * display in kilobytes.
@@ -146,6 +148,7 @@si_meminfo (&i);si_swapinfo (&i); pg_size =atomic_read (&page_cache_size) - i.bufferram ; + committed =atomic_read (&vm_committed_space); len =sprintf (page," total: used: free: shared: buffers: cached:\n" "Mem: %8Lu %8Lu %8Lu %8Lu %8Lu %8Lu\n"
@@ -175,7 +178,8 @@"LowTotal: %8lu kB\n" "LowFree: %8lu kB\n" "SwapTotal: %8lu kB\n" -"SwapFree: %8lu kB\n" , +"SwapFree: %8lu kB\n" +"Committed_AS: %8u kB\n" ,K (i.totalram),K (i.freeram), K(i.sharedram),
@@ -191,7 +195,8 @@K (i.totalram-i.totalhigh),K (i.freeram-i.freehigh),K (i.totalswap), - K(i.freeswap)); +K (i.freeswap), + K(committed));return proc_calc_metrics (page, start, off, count, eof, len);#undef B
include/linux/mm.h +5 -29
@@ -100,8 +100,9 @@#define VM_DONTCOPY 0x00020000/* Do not copy this vma on fork */ #define VM_DONTEXPAND 0x00040000/* Cannot expand with mremap() */ #define VM_RESERVED 0x00080000/* Don't unmap it from swap_out */ +#define VM_ACCOUNT 0x00100000/* Is a VM accounted object */ -#define VM_STACK_FLAGS 0x00000177 +#define VM_STACK_FLAGS (0x00000177 | VM_ACCOUNT)#define VM_READHINTMASK (VM_SEQ_READ | VM_RAND_READ)#define VM_ClearReadHint (v) (v)->vm_flags &= ~VM_READHINTMASK
@@ -603,7 +604,7 @@return ret; } -extern int do_munmap (struct mm_struct *,unsigned long ,size_t ); +extern int do_munmap (struct mm_struct *,unsigned long ,size_t ,int );extern unsigned long do_brk (unsigned long ,unsigned long );
@@ -671,33 +672,8 @@return gfp_mask; } -/* vma is the first one with address < vma->vm_end, -* and even address < vma->vm_start. Have to extend vma. */ -static inline int expand_stack (struct vm_area_struct * vma,unsigned long address) -{ -unsigned long grow; - -/* -* vma->vm_start/vm_end cannot change under us because the caller is required -* to hold the mmap_sem in write mode. We need to get the spinlock only -* before relocating the vma range ourself. -*/ - address &=PAGE_MASK ; -spin_lock (&vma->vm_mm->page_table_lock); - grow = (vma->vm_start - address) >>PAGE_SHIFT ; -if (vma->vm_end - address > current->rlim[RLIMIT_STACK ].rlim_cur || - ((vma->vm_mm->total_vm + grow) <<PAGE_SHIFT ) > current->rlim[RLIMIT_AS ].rlim_cur) { -spin_unlock (&vma->vm_mm->page_table_lock); -return -ENOMEM ; - } - vma->vm_start = address; - vma->vm_pgoff -= grow; - vma->vm_mm->total_vm += grow; -if (vma->vm_flags &VM_LOCKED ) - vma->vm_mm->locked_vm += grow; -spin_unlock (&vma->vm_mm->page_table_lock); -return 0 ; -} +/* Do stack extension */ +extern int expand_stack (struct vm_area_struct * vma,unsigned long address);/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct *find_vma (struct mm_struct * mm,unsigned long addr);
include/linux/mman.h +4 -0
@@ -6,4 +6,8 @@#define MREMAP_MAYMOVE 1#define MREMAP_FIXED 2 +extern int vm_enough_memory (long pages,int charge); +extern void vm_unacct_memory (long pages); +extern void vm_unacct_vma (struct vm_area_struct *vma); +#endif /* _LINUX_MMAN_H */
ipc/shm.c +1 -1
@@ -679,7 +679,7 @@ shmdnext = shmd->vm_next;if (shmd->vm_ops == &shm_vm_ops && shmd->vm_start - (shmd->vm_pgoff <<PAGE_SHIFT ) == (ulong ) shmaddr) { -do_munmap (mm, shmd->vm_start, shmd->vm_end - shmd->vm_start); +do_munmap (mm, shmd->vm_start, shmd->vm_end - shmd->vm_start,1 ); retval =0 ; } }
kernel/fork.c +17 -1
@@ -21,6 +21,7 @@#include <linux/completion.h> #include <linux/namespace.h> #include <linux/personality.h> +#include <linux/mman.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -132,6 +133,7 @@ {struct vm_area_struct * mpnt, *tmp, **pprev;int retval; +unsigned long charge =0 ;flush_cache_mm (current->mm); mm->locked_vm =0 ;
@@ -159,6 +161,17 @@ retval = -ENOMEM ;if (mpnt->vm_flags &VM_DONTCOPY )continue ; + +/* +* FIXME: shared writable map accounting should be one off +*/ +if (mpnt->vm_flags &VM_ACCOUNT ) { +unsigned int len = (mpnt->vm_end - mpnt->vm_start) >>PAGE_SHIFT ; +if (!vm_enough_memory (len,1 )) + goto fail_nomem; + charge += len; + } + tmp =kmem_cache_alloc (vm_area_cachep,SLAB_KERNEL );if (!tmp) goto fail_nomem;
@@ -203,9 +216,12 @@ retval =0 ;build_mmap_rb (mm); -fail_nomem: +out:flush_tlb_mm (current->mm);return retval; +fail_nomem: +vm_unacct_memory (charge); + goto out; } spinlock_t mmlist_lock __cacheline_aligned = SPIN_LOCK_UNLOCKED;
mm/mmap.c +184 -61
407 lines not on this page · raw message
mm/mprotect.c +15 -2
@@ -1,7 +1,10 @@/* -* linux/mm/mprotect.c +* mm/mprotect.c * * (C) Copyright 1994 Linus Torvalds +* +* Address space accounting code <[email protected]> +* (C) Copyright 2002 Red Hat Inc, All Rights Reserved */ #include <linux/slab.h> #include <linux/smp_lock.h>
@@ -241,6 +244,7 @@ {pgprot_t newprot;int error; +unsigned long charged =0 ;if (newflags == vma->vm_flags) { *pprev = vma;
@@ -257,9 +261,18 @@else error =mprotect_fixup_middle (vma, pprev, start, end, newflags, newprot); -if (error) +if (error) { +if (newflags &PROT_WRITE ) +vm_unacct_memory (charged);return error; + } +/* +* Delayed accounting for reduction of memory use - done last to +* avoid allocation races +*/ +if (charged && !(newflags &PROT_WRITE )) +vm_unacct_memory (charged);change_protection (start, end, newprot);return 0 ; }
mm/mremap.c +26 -11
@@ -1,7 +1,10 @@/* -* linux/mm/remap.c +* mm/remap.c * * (C) Copyright 1996 Linus Torvalds +* +* Address space accounting code <[email protected]> +* (C) Copyright 2002 Red Hat Inc, All Rights Reserved */ #include <linux/slab.h>
@@ -13,8 +16,6 @@#include <asm/uaccess.h> #include <asm/pgalloc.h> -extern int vm_enough_memory (long pages); -static inline pte_t *get_one_pte (struct mm_struct *mm,unsigned long addr) {pgd_t * pgd;
@@ -197,7 +198,11 @@ new_vma->vm_ops->open (new_vma);insert_vm_struct (current->mm, new_vma); } -do_munmap (current->mm, addr, old_len); +/* +* The old VMA has been accounted for, +* don't double account +*/ +do_munmap (current->mm, addr, old_len,0 ); current->mm->total_vm += new_len >>PAGE_SHIFT ;if (new_vma->vm_flags &VM_LOCKED ) { current->mm->locked_vm += new_len >>PAGE_SHIFT ;
@@ -212,6 +217,8 @@return -ENOMEM ; } +extern int sysctl_overcommit_memory;/* FIXME!! */ +/* * Expand (or shrink) an existing mapping, potentially moving it at the * same time (controlled by the MREMAP_MAYMOVE flag and available VM space)
@@ -225,6 +232,7 @@ {struct vm_area_struct *vma;unsigned long ret = -EINVAL ; +unsigned long charged =0 ;if (flags & ~(MREMAP_FIXED |MREMAP_MAYMOVE )) goto out;
@@ -254,16 +262,17 @@if ((addr <= new_addr) && (addr+old_len) > new_addr) goto out; -do_munmap (current->mm, new_addr, new_len); +do_munmap (current->mm, new_addr, new_len,1 ); }/* * Always allow a shrinking remap: that just unmaps * the unnecessary pages.. +* do_munmap does all the needed commit accounting */ ret = addr;if (old_len >= new_len) { -do_munmap (current->mm, addr+new_len, old_len - new_len); +do_munmap (current->mm, addr+new_len, old_len - new_len,1 );if (!(flags &MREMAP_FIXED ) || (new_addr == addr)) goto out; }
@@ -293,11 +302,14 @@if ((current->mm->total_vm <<PAGE_SHIFT ) + (new_len - old_len) > current->rlim[RLIMIT_AS ].rlim_cur) goto out; -/* Private writable mapping? Check memory availability.. */ -if ((vma->vm_flags & (VM_SHARED |VM_WRITE )) ==VM_WRITE && - !(flags &MAP_NORESERVE ) && - !vm_enough_memory ((new_len - old_len) >>PAGE_SHIFT )) - goto out; + +if (sysctl_overcommit_memory >1 ) + flags &= ~MAP_NORESERVE ; +if (vma->vm_flags &VM_ACCOUNT ) { + charged = (new_len - old_len) >>PAGE_SHIFT ; +if (!vm_enough_memory (charged,1 )) + goto out_nc; + }/* old_len exactly to the end of the area.. * And we're not relocating the area.
@@ -344,6 +356,9 @@ ret =move_vma (vma, addr, old_len, new_len, new_addr); } out: +if (ret & ~PAGE_MASK ) +vm_unacct_memory (charged); +out_nc:return ret; }
mm/shmem.c +53 -7
142 lines not on this page · raw message
PATCH 1/1 strict VM overcommit for stock 2.4
A version of Alan's strict VM overcommit for the stock VM is available for 2.4.19-rc1 at:
ftp://ftp.kernel.org/pub/linux/kernel/people/rml/vm/strict-overcommit/2.4/vm-strict-overcommit-rml-2.4.19-rc1-1.patch
This is the same code I posted yesterday (see "[PATCH] strict VM overcommit for" from 20020711) except for the stock non-rmap VM in 2.4.
Hugh Dickins sent me a few fixes, mostly for shmfs accounting, that he recently discovered... that code is not yet merged but will be, probably after this weekend.
I still encourage testing and comments.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 1 line · Robert Love
I still encourage testing and comments.
Quickly looking through the patch I can't see what prevents total loss of control at constant memory pressure. For more please see:
http://www.uwsg.iu.edu/hypermail/linux/kernel/0108.2/0310.html Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 2 lines · Szakacsits Szabolcs
Quickly looking through the patch I can't see what prevents total loss of control at constant memory pressure. For more please see:
I do not see anything in this email related to the issue at hand.
First, if the VM is broke that is an orthogonal issue that needs to be fixed separately.
Specifically, what livelock situation are you insinuating? If we only allow allocation that are met by the backing store, we cannot get anywhere near OOM.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 1 line · Robert Love
I do not see anything in this email related to the issue at hand.
You solve a problem and introduce a potentially more serious one. Strict overcommit is requisite but not satisfactory.
Quoted 3 lines
Specifically, what livelock situation are you insinuating? If we only allow allocation that are met by the backing store, we cannot get anywhere near OOM.
This is what I would do first [make sure you don't hit any resource, malloc, kernel memory mapping, etc limits -- this is a simulation that must eat all available memory continually]:
main(){void *x;while(1)if(x=malloc(4096))memset(x,666,4096);}
When the above used up all the memory try to ssh/login to the box as root and clean up the mess. Can you do it?
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 7 lines · Robert Love
Quoted 5 lines · Szakacsits Szabolcs
This is what I would do first [make sure you don't hit any resource, malloc, kernel memory mapping, etc limits -- this is a simulation that must eat all available memory continually]:
main(){void *x;while(1)if(x=malloc(4096))memset(x,666,4096);}
Quoted 5 lines
Quoted 2 lines
When the above used up all the memory try to ssh/login to the box as root and clean up the mess. Can you do it?
- with strict overcommit and the "allocations must meet backing store" rule (policy #3) the above can never use all physical memory
So you can't do it: if this user can't get more memory neither root.
Quoted 2 lines
- if your point is that a rogue user can use all of the systems memory, then you need per-user resource accounting.
I explicitely mentioned above, "make sure you don't hit any resource ... limit".
Quoted 2 lines
- the point of this patch is to not use MORE memory than the system has.
I had my [not finished] own non-overcommit patch based on Eduardo Horvath's from 2000, no need to explain what it means :) Actually the basics of your patch looks very similar to Eduardo's one.
Quoted 4 lines
I say nothing else except that I am trying to avoid OOM and push the allocation failures into the allocations themselves. Assuming the accounting is correct (and it seems to be) then Alan and I have succeeded.
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 5 lines · Szakacsits Szabolcs
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
Ahh, I figured out your target, embedded devices. Yes it's good for that but not enough for general purpose.
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 7 lines · Szakacsits Szabolcs
This is what I would do first [make sure you don't hit any resource, malloc, kernel memory mapping, etc limits -- this is a simulation that must eat all available memory continually]:
main(){void *x;while(1)if(x=malloc(4096))memset(x,666,4096);}When the above used up all the memory try to ssh/login to the box as root and clean up the mess. Can you do it?
Three points:
- with strict overcommit and the "allocations must meet backing store" rule (policy #3) the above can never use all physical memory
- if your point is that a rogue user can use all of the systems memory, then you need per-user resource accounting.
- the point of this patch is to not use MORE memory than the system has. I say nothing else except that I am trying to avoid OOM and push the allocation failures into the allocations themselves. Assuming the accounting is correct (and it seems to be) then Alan and I have succeeded.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 2 lines · Robert Love
An orthogonal issue is per-user resource limits and this may need to be coupled with that. It is not a problem I am trying to solve, however.
About 99% of the people don't know about, don't understand or don't care about resource limits. But they do care about cleaning up when mess comes. Adding reserved root memory would be a couple of lines, you can get ideas from the patch from here,
http://mlf.linux.rulez.org/mlf/ezaz/reserved_root_memory.html
Surprisingly visited through google and people are asking for 2.4 patches, hint ;)
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Alan CoxQuoted 3 lines · Alan Cox
Adjusting the percentages to have a root only zone is doable. It helps in some conceivable cases but not all. Do people think its important, if so I'll add it
"Why isn't in the kernel?" was the other FAQ I got besides "when it will be ported to 2.4?" [about the reserved root vm patch I mentioned in my other email].
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 5 lines · Szakacsits Szabolcs
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
I understand your point, and you are entirely right.
But it is a _completely_ unrelated issue. The goal here is to not overcommit memory and I think we succeeded.
An orthogonal issue is per-user resource limits and this may need to be coupled with that. It is not a problem I am trying to solve, however.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 2 lines · Szakacsits Szabolcs
Ahh, I figured out your target, embedded devices. Yes it's good for that but not enough for general purpose.
I think this applies to more than just embedded devices. Further, it applies to even the case you are talking about because the issues are _orthogonal_.
If you also have an issue with root vs non-root users then you need resource limits. You still need this too.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 10 lines · Szakacsits Szabolcs
Quoted 5 lines · Szakacsits Szabolcs
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
Ahh, I figured out your target, embedded devices. Yes it's good for that but not enough for general purpose.
Adjusting the percentages to have a root only zone is doable. It helps in some conceivable cases but not all. Do people think its important, if so I'll add it
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 3 lines · Alan Cox
Adjusting the percentages to have a root only zone is doable. It helps in some conceivable cases but not all. Do people think its important, if so I'll add it
Changing the rules would be easy, but you would need to make the accounting check for root vs non-root and keep track accordingly. Admittedly not hard but not entirely pretty either.
I still contend the issues are not related. It would make more sense to me to do resource limits to solve this problem - rlimits are something Rik has on his TODO and supposedly easy to add to rmap.
That way people can use strict overcommit, rlimits, neither, or both to meet their needs.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 8 lines · Robert Love
Quoted 5 lines · Szakacsits Szabolcs
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
Quoted 5 lines
I understand your point, and you are entirely right.
But it is a _completely_ unrelated issue. The goal here is to not overcommit memory and I think we succeeded.
Let's see, I have 30 network daemons that are all sleeping, each requested and got 200 MB of memory to work with. I've got 10 NFS daemons that allocated their worse-case 228 MB data-buffers. They are all sleeping. I have 6 gettys, sleeping on terminals, they all requested and got 32 MB. I am now trying to log-in, but /bin/login fails to exec because there is no memory.
What should have happened is each of the tasks need only about 4k until they actually access something. Since they can't possibly access everything at once, we need to fault in pages as needed, not all at once. This is what 'overcomit' is, and it is necessary.
If the machine was set up with the correct amount of swap, and if resource limits are correctly in-place, even a 16 megabyte RAM machine will not fail due to OOM.
If you have 'fixed' something so that no RAM ever has to be paged you have a badly broken system.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 4 lines · Richard B. Johnson
What should have happened is each of the tasks need only about 4k until they actually access something. Since they can't possibly access everything at once, we need to fault in pages as needed, not all at once. This is what 'overcomit' is, and it is necessary.
Then do not enable strict overcommit, Dick.
Quoted 2 lines
If you have 'fixed' something so that no RAM ever has to be paged you have a badly broken system.
That is not the intention of Alan or I's work at all.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Richard B. JohnsonQuoted 4 lines · Richard B. Johnson
What should have happened is each of the tasks need only about 4k until they actually access something. Since they can't possibly access everything at once, we need to fault in pages as needed, not all at once. This is what 'overcomit' is, and it is necessary.
I should also mention this is demand paging, not overcommit.
Overcommit is the property of succeeded more allocations than their is memory in the address space. The idea being that allocations are lazy, things often do not use their full allocations, etc. etc. as you mentioned.
It is typical a good thing since it lowers VM pressure.
It is not always a good thing, for numerous reasons, and it becomes important in those scenarios to ensure that all allocations can be met by the backing store and consequently we never find ourselves with more memory committed than available and thus never OOM.
This has nothing to do with paging and resource limits as you say. Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 7 lines · Robert Love
Quoted 4 lines · Richard B. Johnson
What should have happened is each of the tasks need only about 4k until they actually access something. Since they can't possibly access everything at once, we need to fault in pages as needed, not all at once. This is what 'overcomit' is, and it is necessary.
Quoted 8 lines
Then do not enable strict overcommit, Dick.
Quoted 2 lines
If you have 'fixed' something so that no RAM ever has to be paged you have a badly broken system.
That is not the intention of Alan or I's work at all.
Robert Love
Okay then. When would it be useful? I read that it would be useful in embedded systems, but everything that will ever run on embedded systems is known at compile time, or is uploaded by something written by an intelligent developer, so I don't think it's useful there. I 'do' embedded systems and have never encountered OOM.
I also read about some 'home users' not knowing how to set up there systems. I don't think one CPU cycle should be wasted to protect them, well maybe 10, but that's it.
I keep seeing the same thing about protecting root against fork and malloc bombs and I get rather "malloc()" about it. All distributions I have seen, so far, come with gcc and make. The kiddies can crap all over their kernels at their heart's content. I don't think Linux should be reduced to the lowest common denominator.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 5 lines · Richard B. Johnson
Okay then. When would it be useful? I read that it would be useful in embedded systems, but everything that will ever run on embedded systems is known at compile time, or is uploaded by something written by an intelligent developer, so I don't think it's useful there. I 'do' embedded systems and have never encountered OOM.
I work for an embedded systems company and our customers do have OOM problems. The problem is not so much that they _do_ OOM but that they _can_ - killing a random process is the last thing they want.
Same issue with HA etc... its not preventing OOM so much as being prepared for it, by pushing the failures into the allocation routines and out from the page access.
Certainly Alan and RedHat found a need for it, too. It should be pretty clear why this is an issue...
Quoted 5 lines
I keep seeing the same thing about protecting root against fork and malloc bombs and I get rather "
malloc()" about it. All distributions I have seen, so far, come withgccandmake. The kiddies can crap all over their kernels at their heart's content. I don't think Linux should be reduced to the lowest common denominator.
This is the argument I was making before -- I do not think strict overcommit should solve this problem (nor can it fully). This is a problem to be solved by per-user resource limits.
It is not an issue I care much for either, but this is more than just a "kiddies" issue. Unbounded memory growth can happen without evil intentions and in places e.g. like a university shell server it is important to protect against.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsSzakacsits> About 99% of the people don't know about, don't understand Szakacsits> or don't care about resource limits. But they do care Szakacsits> about cleaning up when mess comes. Adding reserved root Szakacsits> memory would be a couple of lines
So what does this buy you when root itself runs the box into the ground? Or if a dumb user decides to run his process as root, and it takes down the system?
You're arguing for the wrong thing here. What Robert is doing is making sure that when a process asks for memory, it can only succeed when there is physical memory available.
Linux currently runs in over-commit mode, since it actually makes alot of sense. Most processes ask for potentially huge amounts of memory, but never use it. So if I have 10mb of RAM, and process A asks for 5mb, and process b asks for 5mb I'm ok. If process B asks for 6mb then one of two things happens:
Over commit mode:
process B succeeds.
Strict overcommit mode:
process B gets a malloc failure and can't proceed.
Even if A and B only want to use 2mb of RAM each, and the system would have 6mb free, they could *ask* for the extra RAM and overcommit the system and hit the OOM situation.
DEC OSF/1 had a toggle way back when in the early 90s to turn this feature on and off. Generally, being a school, we turned if off (i.e. allowed lazy allocation) but for some core servers, we turned it on to make sure the system was more stable.
In any case, what you're asking for is a *stupid user safety buffer* and that's not sane. As I said before, keeping around a few Mb for root doesn't do shit when a root process runs and pushes the system into OOM.
John
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 21 lines · Robert Love
Quoted 4 lines · Richard B. Johnson
What should have happened is each of the tasks need only about 4k until they actually access something. Since they can't possibly access everything at once, we need to fault in pages as needed, not all at once. This is what 'overcomit' is, and it is necessary.
I should also mention this is demand paging, not overcommit.
Overcommit is the property of succeeded more allocations than their is memory in the address space. The idea being that allocations are lazy, things often do not use their full allocations, etc. etc. as you mentioned.
It is typical a good thing since it lowers VM pressure.
It is not always a good thing, for numerous reasons, and it becomes important in those scenarios to ensure that all allocations can be met by the backing store and consequently we never find ourselves with more memory committed than available and thus never OOM.
Quoted 4 lines
This has nothing to do with paging and resource limits as you say. Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
It has everything to do with demand-paging. Since on single CPU machines, there is only one task executing at any one time, that single task can own and use every bit of RAM on the whole machine is virtual memory works correctly. For performance reasons, it may not actually use all the RAM but, in principle, it is possible.
If you don't allow that, the single task can use only the RAM that was not allocated to other tasks. At the time an allocation is made, the kernel cannot know what resources may be available when the task requesting the allocation actually starts to use those allocated resources. Instead, the kernel allocates resources based upon what it 'knows' at the present time. Since it can't see the future anymore than you or I, the fact that N processes just called exit() before the requesting task touched a single page can't be known.
FYI multiple CPU machines have compounded the problems because there can be several things happening at the same time. Although the MM is locked so it's single-threaded, you have a before/after resource history condition that can't be anticipated.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 6 lines
Same issue with HA etc... its not preventing OOM so much as being prepared for it, by pushing the failures into the allocation routines and out from the page access.
Certainly Alan and RedHat found a need for it, too. It should be pretty clear why this is an issue...
The code was written initially because we had large customers with a direct requirement for the facility. It is also very relevant to embedded systems where you want controlled failure.
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 6 lines · Robert Love
Quoted 3 lines · Alan Cox
Adjusting the percentages to have a root only zone is doable. It helps in some conceivable cases but not all. Do people think its important, if so I'll add it
Quoted 7 lines
Changing the rules would be easy, but you would need to make the accounting check for root vs non-root and keep track accordingly. Admittedly not hard but not entirely pretty either.
I still contend the issues are not related. It would make more sense to me to do resource limits to solve this problem - rlimits are something Rik has on his TODO and supposedly easy to add to rmap.
rmap supports rlimit AS which gives you paging control. Neither of them support workload management or partitioned accounting of any kind. That would need the beancounter patches resurrecting.
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Richard B. JohnsonQuoted 36 lines · Richard B. Johnson
Quoted 14 lines · Robert Love
I should also mention this is demand paging, not overcommit.
Overcommit is the property of succeeded more allocations than their is memory in the address space. The idea being that allocations are lazy, things often do not use their full allocations, etc. etc. as you mentioned.
It is typical a good thing since it lowers VM pressure.
It is not always a good thing, for numerous reasons, and it becomes important in those scenarios to ensure that all allocations can be met by the backing store and consequently we never find ourselves with more memory committed than available and thus never OOM.
Quoted 4 lines
This has nothing to do with paging and resource limits as you say. Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
It has everything to do with demand-paging. Since on single CPU machines, there is only one task executing at any one time, that single task can own and use every bit of RAM on the whole machine is virtual memory works correctly. For performance reasons, it may not actually use all the RAM but, in principle, it is possible.
If you don't allow that, the single task can use only the RAM that was not allocated to other tasks. At the time an allocation is made, the kernel cannot know what resources may be available when the task requesting the allocation actually starts to use those allocated resources. Instead, the kernel allocates resources based upon what it 'knows' at the present time. Since it can't see the future anymore than you or I, the fact that N processes just called
exit()before the requesting task touched a single page can't be known.
Quoted 8 lines
FYI multiple CPU machines have compounded the problems because there can be several things happening at the same time. Although the MM is locked so it's single-threaded, you have a before/after resource history condition that can't be anticipated.
Cheers,
Dick Johnson
Is it possible that you're confusing "backing store" with "physical RAM"? I was under the impression that strict overcommit used both RAM and SWAP when deciding whether an allocation should succeed. If you've exceeded all of RAM and all of swap, you are OOM. Period.
Daniel
Signature · 3 lines
Recursion n.:
See Recursion.
-- Random Shack Data Processing DictionaryRe: [PATCH] strict VM overcommit for stock 2.4
Quoted 46 lines · Daniel Gryniewicz
Quoted 36 lines · Richard B. Johnson
Quoted 14 lines · Robert Love
I should also mention this is demand paging, not overcommit.
Overcommit is the property of succeeded more allocations than their is memory in the address space. The idea being that allocations are lazy, things often do not use their full allocations, etc. etc. as you mentioned.
It is typical a good thing since it lowers VM pressure.
It is not always a good thing, for numerous reasons, and it becomes important in those scenarios to ensure that all allocations can be met by the backing store and consequently we never find ourselves with more memory committed than available and thus never OOM.
Quoted 4 lines
This has nothing to do with paging and resource limits as you say. Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
It has everything to do with demand-paging. Since on single CPU machines, there is only one task executing at any one time, that single task can own and use every bit of RAM on the whole machine is virtual memory works correctly. For performance reasons, it may not actually use all the RAM but, in principle, it is possible.
If you don't allow that, the single task can use only the RAM that was not allocated to other tasks. At the time an allocation is made, the kernel cannot know what resources may be available when the task requesting the allocation actually starts to use those allocated resources. Instead, the kernel allocates resources based upon what it 'knows' at the present time. Since it can't see the future anymore than you or I, the fact that N processes just called
exit()before the requesting task touched a single page can't be known.Quoted 8 lines
FYI multiple CPU machines have compounded the problems because there can be several things happening at the same time. Although the MM is locked so it's single-threaded, you have a before/after resource history condition that can't be anticipated.
Cheers,
Dick Johnson
Quoted 6 lines
Is it possible that you're confusing "backing store" with "physical RAM"? I was under the impression that strict overcommit used both RAM and SWAP when deciding whether an allocation should succeed. If you've exceeded all of RAM and all of swap, you are OOM. Period.
Daniel
No. And I'm not confused. Consider Virtual RAM as all the real RAM and all the backing store. If I consider this an absolute limit, then I am not able to fully use all the system resources.
Lets say the system has 20 'units' of a resource (virtual RAM).
Example:
Task (1) allocates 10 units, actually uses 1 so far. Task (2) allocates 10 units, actually uses 2 so far. Task (3) wants to allocate 7 units. It can't so it exits in error. Task (1) uses all its units then exits normally.
Task (2) uses 1 more unit then exits normally.
So you forced a task to terminate in error because you established hard limits on your resource.
What could (should?) have happened, is that all the memory allocations could have succeeded, even though they exceeded the 20 units of resource.
Quoted 1 line
From the history, we see that Task (1) actually used 10. Task (2)
actually used 3 units. This means that there were really 20 - 13 = 7 units available when task 3 requested 7 units. But, the system 'knew' what its commitment was so it refused.
Now, since the system is dynamic, it is possible that Task (1) and Task (2) might not even exist by the time Task (3) actually wants to use its memory. In that case, there would have been 20 units available, but we will never know because Task 3 exited in error.
Now, what this should point out is that a complete VM system, although it can't anticipate the future, can put things off until the future where things may be better. This is the true 'fix' of OOM (if it needs fixing.
Let's say I make a fork bomb, as root, no protection. The MM knows that it can't give me any more RAM right now so I am put to sleep. Other tasks run fine, at full speed. As they exit, the fork-bomb may get their memory. Since the MM knows how much resource could ever become available, as a single task exceeds this limit, the MM knows that it cannot get any more in the future so the MM knows it's a bomb. If the system doesn't kill the bomb, eventually, I may fail the system because there may be no resource available to log-in and kill the bomb, but as long as there is one task running, connected to a terminal, that task can be used to kill the fork-bomb.
The problem with putting memory allocation off to the future, as I see it, is the existing paging code wasn't designed for it. If a task that page-faulted could also sleep, the problem could be solved.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Windows-2000/Professional isn't.
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 100 lines · Richard B. Johnson
Quoted 46 lines · Daniel Gryniewicz
Quoted 36 lines · Richard B. Johnson
Quoted 14 lines · Robert Love
I should also mention this is demand paging, not overcommit.
Overcommit is the property of succeeded more allocations than their is memory in the address space. The idea being that allocations are lazy, things often do not use their full allocations, etc. etc. as you mentioned.
It is typical a good thing since it lowers VM pressure.
It is not always a good thing, for numerous reasons, and it becomes important in those scenarios to ensure that all allocations can be met by the backing store and consequently we never find ourselves with more memory committed than available and thus never OOM.
Quoted 4 lines
This has nothing to do with paging and resource limits as you say. Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
It has everything to do with demand-paging. Since on single CPU machines, there is only one task executing at any one time, that single task can own and use every bit of RAM on the whole machine is virtual memory works correctly. For performance reasons, it may not actually use all the RAM but, in principle, it is possible.
If you don't allow that, the single task can use only the RAM that was not allocated to other tasks. At the time an allocation is made, the kernel cannot know what resources may be available when the task requesting the allocation actually starts to use those allocated resources. Instead, the kernel allocates resources based upon what it 'knows' at the present time. Since it can't see the future anymore than you or I, the fact that N processes just called
exit()before the requesting task touched a single page can't be known.Quoted 8 lines
FYI multiple CPU machines have compounded the problems because there can be several things happening at the same time. Although the MM is locked so it's single-threaded, you have a before/after resource history condition that can't be anticipated.
Cheers,
Dick JohnsonQuoted 6 lines
Is it possible that you're confusing "backing store" with "physical RAM"? I was under the impression that strict overcommit used both RAM and SWAP when deciding whether an allocation should succeed. If you've exceeded all of RAM and all of swap, you are OOM. Period.
Daniel
No. And I'm not confused. Consider Virtual RAM as all the real RAM and all the backing store. If I consider this an absolute limit, then I am not able to fully use all the system resources.
Lets say the system has 20 'units' of a resource (virtual RAM).
Example:
Task (1) allocates 10 units, actually uses 1 so far. Task (2) allocates 10 units, actually uses 2 so far. Task (3) wants to allocate 7 units. It can't so it exits in error. Task (1) uses all its units then exits normally.
Task (2) uses 1 more unit then exits normally.So you forced a task to terminate in error because you established hard limits on your resource.
What could (should?) have happened, is that all the memory allocations could have succeeded, even though they exceeded the 20 units of resource.
Quoted 1 line
From the history, we see that Task (1) actually used 10. Task (2)
actually used 3 units. This means that there were really 20 - 13 = 7 units available when task 3 requested 7 units. But, the system 'knew' what its commitment was so it refused.
Now, since the system is dynamic, it is possible that Task (1) and Task (2) might not even exist by the time Task (3) actually wants to use its memory. In that case, there would have been 20 units available, but we will never know because Task 3 exited in error.
Now, what this should point out is that a complete VM system, although it can't anticipate the future, can put things off until the future where things may be better. This is the true 'fix' of OOM (if it needs fixing.
Let's say I make a fork bomb, as root, no protection. The MM knows that it can't give me any more RAM right now so I am put to sleep. Other tasks run fine, at full speed. As they exit, the fork-bomb may get their memory. Since the MM knows how much resource could ever become available, as a single task exceeds this limit, the MM knows that it cannot get any more in the future so the MM knows it's a bomb. If the system doesn't kill the bomb, eventually, I may fail the system because there may be no resource available to log-in and kill the bomb, but as long as there is one task running, connected to a terminal, that task can be used to kill the fork-bomb.
Quoted 5 lines
The problem with putting memory allocation off to the future, as I see it, is the existing paging code wasn't designed for it. If a task that page-faulted could also sleep, the problem could be solved.
So don't turn on strict overcommit. What you describe is what we have now, and OOM is the result of allowing requests for more than we actually have based on the assumption processes won't use it all. If they do, you have problems. If you don't want those problems, you turn on strict overcommit, and live with the allocation failures.
Daniel
Signature · 3 lines
Recursion n.:
See Recursion.
-- Random Shack Data Processing DictionaryQuoted 5 lines · Robert Love
...
In the strictest of modes, it should be impossible to allocate more memory than available and impossible to OOM. All memory failures should be pushed down to the allocation routines -- malloc, mmap, etc.
...
Out of interest:
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"
Quoted 3 lines
Enjoy,
Robert Love
cu
Adrian
Signature · 3 lines
You only think this is a free country. Like the US the UK spends a lot of time explaining its a free country because its a police state. Alan Cox
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 9 lines · Szakacsits Szabolcs
Quoted 5 lines · Szakacsits Szabolcs
And my point (you asked for comments) was that, this is only (the harder) part of the solution making Linux a more reliable (no OOM killing *and* root always has the control) and cost effective platform (no need for occasionally very complex and continuous resource limit setup/adjusting, especially for inexpert home/etc users).
Ahh, I figured out your target, embedded devices. Yes it's good for that but not enough for general purpose.
However, you NEED this patch in order to implement something that is good enough for general purpose (ie. per-user resource accounting).
regards,
Rik
Signature · 3 lines
Bravely reimplemented by the knights who say "NIH". http://www.surriel.com/ http://distro.conectiva.com/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 2 lines · Szakacsits Szabolcs
And my point was that, this is only part of the solution making Linux a more reliable
I see no reason to not merge this (useful) part. Not only is it useful on its own, it's also a necessary ingredient of whatever "complete solution" to control per-user resource limits.
regards,
Rik
Signature · 3 lines
Bravely reimplemented by the knights who say "NIH". http://www.surriel.com/ http://distro.conectiva.com/
Quoted 8 lines · Adrian Bunk
Out of interest:
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"
Well, seriously: don't do that.
But `swapoff' will not succeed if there is not enough swap or physical memory to move the pages to... if it does succeed, then there is enough storage elsewhere. At that point, you are not OOM but you may now have more address space allocated than the strict accounting would typically allow - thus no allocations will succeed so you should not be able to OOM.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Rik van RielQuoted 4 lines · Rik van Riel
I see no reason to not merge this (useful) part. Not only is it useful on its own, it's also a necessary ingredient of whatever "complete solution" to control per-user resource limits.
I am glad we agree here - resource limits and strict overcommit are two separate solutions to various problems. Some they solve individually, others they solve together.
I may use one, the other, both, or neither. A clean abstract solution allows this.
Robert Love
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to [email protected]Quoted 8 lines · On Thu, 18 Jul 2002 [email protected] wrote:
Szakacsits> About 99% of the people don't know about, don't understand Szakacsits> or don't care about resource limits. But they do care Szakacsits> about cleaning up when mess comes. Adding reserved root Szakacsits> memory would be a couple of lines
So what does this buy you when root itself runs the box into the ground? Or if a dumb user decides to run his process as root, and it takes down the system?
You would be able to point out them running stuffs as root is the worst scenario from security and reliability point of view. You can argue about security now but not reliability because it doesn't matter who owns the "runaway" processes, the end result is either uncontrolled process killing (default kernel) or livelock (strict overcommit patch).
You can't solve everybody's problems of course but you can educate them however at present the kernel misses the features to do so [and for a moment *please* ignore the resource control/accounting with all its benefits and deficients on Linux, there are lot's of way to do resource control and Linux is quite infant at present].
Quoted 1 line
You're arguing for the wrong thing here.
How about consulting with some Sun or ex-Dec engineers why they have this feature for (internet) decades? Because at default they use strict overcommit and that's shooting yourself in the foot without reserved root vm on a general purposes system.
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Alan CoxQuoted 2 lines · Alan Cox
Adjusting the percentages to have a root only zone is doable. It helps in some conceivable cases but not all.
For 2.2 kernels I've found 5 MB reserved from swap until it was needed was enough to ssh to the box and fix whatever was going on (whatever:
real world cases like slashdot effects, exploits from packetstorm and other own made testcases that heavily overcommited memory). Nevertheless the amount reserved was controllable via /proc.
And I do know it doesn't solve all cases but covering 99% of the real world issues isn't a bad start at all, imho.
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveQuoted 3 lines · Robert Love
Btw, without this it is possible to OOM any machine. OOM is a by-product of allowing overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
Very well said, now I try to explain again what's missing from the
patch: livelock is a by-product of allowing strict VM overcommit and poor accounting (and perhaps poor software/users), not an incorrectly configured machine.
So where is the solution for "poor accounting (and perhaps poor software/users), not an incorrectly configured machine" users? These are part of life and please don't claim all your work was perfect at first shoot and automatically adapted in all changing environments whitout ever touching it again on a general purpose system. Even if it would be true, not everybody supergenius.
So which one is better? OOM killer that considers root owned processes to make his decision or strict VM overcommit that doesn't distinguish root and non-root users and potentially will livelock [if you don't have some custom solution, like "trigger OOM handler through sysrq" patch posted here a year ago].
For embedded systems the later, for general purpose systems the first is better in average however this is not linux-embedded and later on people using Linux for general purpose could get the impression strict VM overcommit is useful for them and potentially would end up in a worse situation than without it (see my example sent, default kernel OOM killed the bad process, with your patch reset the box).
*However* distinguishing root and non-root users also in strict VM overcommit would make a significant difference for general purpose systems, this was always my point.
Can you see the non-orthogonality now?
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Rik van RielQuoted 2 lines · Rik van Riel
However, you NEED this patch in order to implement something that is good enough for general purpose
Yes Rik, apparently you missed when I wrote: "Strict overcommit is requisite but not satisfactory".
Szaka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 9 lines · Robert Love
Quoted 8 lines
Out of interest:
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"
Quoted 8 lines
Well, seriously: don't do that.
But `swapoff' will not succeed if there is not enough swap or physical memory to move the pages to... if it does succeed, then there is enough storage elsewhere. At that point, you are not OOM but you may now have more address space allocated than the strict accounting would typically allow - thus no allocations will succeed so you should not be able to OOM.
"thus no allocations will succeed" seems to be a synonymous for "the machine is more or less dead"?
And this might be a real problem:
If you have a xsession with many open programs and leave it with an xlock over night it's quite usual that all your applications are swapped out the next morning. A convenient way to get all your applications swapped in again is a "swapoff -a; swapon -a". You might argue that this is "wrong" but it's as far as I know the best solution to get all your applications swapped in again (and I know several people doing it this way).
If "no allocations will succeed" the first command that will fail is the "swapon -a"...
Quoted 1 line
Robert Love
cu
Adrian
Signature · 3 lines
You only think this is a free country. Like the US the UK spends a lot of time explaining its a free country because its a police state. Alan Cox
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveOne question: do you have a strict vm overcommit patch for 2.4.18?
On 18 Jul 2002 12:03:16 -0700
Robert Love <[email protected]> wrote:
RL> On Thu, 2002-07-18 at 11:56, Richard B. Johnson wrote:
RL>
RL> > What should have happened is each of the tasks need only about RL> > 4k until they actually access something. Since they can't possibly RL> > access everything at once, we need to fault in pages as needed, RL> > not all at once. This is what 'overcomit' is, and it is necessary. RL>
RL> Then do not enable strict overcommit, Dick.
RL>
RL> > If you have 'fixed' something so that no RAM ever has to be paged RL> > you have a badly broken system.
RL>
RL> That is not the intention of Alan or I's work at all. RL>
RL> Robert Love
---
- Amit
Want to know more about me? Follow this link-> http://amitshah.nav.to/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
Quoted 1 line · Amit Shah
One question: do you have a strict vm overcommit patch for 2.4.18?
Yes, I have made patches for 2.4 and 2.5 with and without rmap. See,
http://www.kernel.org/pub/linux/kernel/people/rml/vm/strict-overcommit/
Robert Love
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Szakacsits SzabolcsQuoted 5 lines · Szakacsits Szabolcs
*However* distinguishing root and non-root users also in strict VM overcommit would make a significant difference for general purpose systems, this was always my point.
Can you see the non-orthogonality now?
Nope, I still disagree and there is no point going back and forth.
We both agree that there are situations where both resource accounting (or some sort of root-protection like you want) and strict overcommit is required.
I contend there are situations where only one or the other is needed.
More importantly, I argue the two things should be kept separate. Putting some root safety net into strict accounting is a hack (how much of a net? etc.). You want to keep users from ruining things - get per-user resource limits. You want to keep the machine from overcommiting memory and thus not OOMing? Get strict accounting. You want both? Use both.
I provided the first piece.
Robert Love
Quoted 7 lines
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"
Make swapoff -a return -ENOMEM
I've not done this on the basis that this is root specific stupidity and generally shouldnt be protected against
Re: [PATCH] strict VM overcommit for stock 2.4
In reply to Robert LoveThanks Robert, got the patch. The reason I asked was because I didn't find it there a couple of days ago..
On 19 Jul 2002 10:16:58 -0700
Robert Love <[email protected]> wrote:
RL> On Fri, 2002-07-19 at 09:49, Amit Shah wrote:
RL> > One question: do you have a strict vm overcommit patch for 2.4.18? RL>
RL> Yes, I have made patches for 2.4 and 2.5 with and without rmap. See, RL>
RL> http://www.kernel.org/pub/linux/kernel/people/rml/vm/strict-overcommit/
RL>
RL> Robert Love
RL>
---
- Amit
Want to know more about me? Follow this link-> http://amitshah.nav.to/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/
Quoted 10 lines · Alan Cox
Quoted 5 lines
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"Make swapoff -a return
-ENOMEMI've not done this on the basis that this is root specific stupidity and generally shouldnt be protected against
Recommended reading: MIT's Magazin of Innovation Technology Review, August 2002 issue, cover story: Why Software Is So Bad?
Next you might read: "... prominent, leading Linux kernel developer publically labels users stupid instead of handling a special case [that is ironically used as a workaround for one of the many system software deficiencies] in what case the system software would hang using a new feature the developer is about to add and admitted to be paid for ..."
Adrian would deserve a thanks for spotting and reporting the issue [and there *are* other use cases for the above mentioned swapoff -a, some also to overcome kernel bugs].
With all respect, Alan, the critic isn't personal but reaction to a trendy phenomenon that should be address if developers care about user issues.
Szaka
Quoted 10 lines · Szakacsits Szabolcs
Quoted 8 lines · Alan Cox
Quoted 5 lines
How is assured that it's impossible to OOM when the amount of memory shrinks?
IOW:
- allocate very much memory
- "swapoff -a"Make swapoff -a return
-ENOMEM
Quoted 8 lines
Quoted 2 lines
I've not done this on the basis that this is root specific stupidity and generally shouldnt be protected against
Recommended reading: MIT's Magazin of Innovation Technology Review, August 2002 issue, cover story: Why Software Is So Bad?
Next you might read: "... prominent, leading Linux kernel developer publically labels users stupid instead of handling a special case
I would suggest you do something quite different. Go and read what K&R had to say about the design of Unix. One of the design goals of Unix is that the system does not think it knows better than the administrator. That is one of the reasons unix works well and is so flexible.
Alan
Quoted 10 lines · Alan Cox
Quoted 9 lines · Szakacsits Szabolcs
Quoted 4 lines · Alan Cox
Make swapoff -a return
-ENOMEMI've not done this on the basis that this is root specific stupidity and generally shouldnt be protected against
Recommended reading: MIT's Magazin of Innovation Technology Review, August 2002 issue, cover story: Why Software Is So Bad?
Quoted 7 lines
Quoted 2 lines
Next you might read: "... prominent, leading Linux kernel developer publically labels users stupid instead of handling a special case
I would suggest you do something quite different. Go and read what K&R had to say about the design of Unix. One of the design goals of Unix is that the system does not think it knows better than the administrator. That is one of the reasons unix works well and is so flexible.
The problem is that at the time K&R said this only real men (tm) were administrators of UNIX systems. Nowadays clueless people like me are administrators of their Linux system at home. ;-)
With enough stupidity root can always trash his system but if as Robert says the state of the system will be that "no allocations will succeed" which seems to be a synonymous for "the system is practically dead" it is IMHO a good idea to let "swapoff -a return -ENOMEM".
Quoted 1 line
Alan
cu
Adrian
Signature · 3 lines
You only think this is a free country. Like the US the UK spends a lot of time explaining its a free country because its a police state. Alan Cox
Quoted 7 lines · Adrian Bunk
Quoted 4 lines · Alan Cox
I would suggest you do something quite different. Go and read what K&R had to say about the design of Unix. One of the design goals of Unix is that the system does not think it knows better than the administrator. That is one of the reasons unix works well and is so flexible.
Quoted 9 lines
The problem is that at the time K&R said this only real men (tm) were administrators of UNIX systems. Nowadays clueless people like me are administrators of their Linux system at home. ;-)
With enough stupidity root can always trash his system but if as Robert says the state of the system will be that "no allocations will succeed" which seems to be a synonymous for "the system is practically dead" it is IMHO a good idea to let "swapoff -a return
-ENOMEM".
Maybe it is an option to add the --I_know_Im_stupid option to the swapoff command line ? (Also known as the --force flag). This way we can both return an error when the OS lacks memory and force a swapoff.
Agreed, the system is practically dead when no allocations will succeed, but maybe killing user tasks when root needs memory or something is an option... (Better a few angry users than a crashed server, besides, it is not something that should happen every day)
Jos
Quoted 4 lines · Adrian Bunk
With enough stupidity root can always trash his system but if as Robert says the state of the system will be that "no allocations will succeed" which seems to be a synonymous for "the system is practically dead" it is IMHO a good idea to let "swapoff -a return
-ENOMEM".
In the overcommit mode I already suggested that. An administrator can turn off overcommit protection if he really really needs to swapoff regardless of the consequences (eg failing swap disk)
Quoted 2 lines · Alan Cox
One of the design goals of Unix is that the system does not think it knows better than the administrator.
What about the many hundred counter-examples (e.g. umount gives EBUSY, kill can't kill processes in uninterruptible sleep, etc, etc)? Why the system knows better then admin in these cases? Why just don't destroy the data, crash the system as you suggest in your case? Why this inconsistency?
Szaka
Quoted 1 line · Szakacsits Szabolcs
What about the many hundred counter-examples (e.g. umount gives EBUSY,
umount -f.
Quoted 1 line
kill can't kill processes in uninterruptible sleep, etc, etc)? Why the
In these cases the kernel infrastructure doesn't support the ability to recover from such a state, very different from stopping a user doing something it can handle perfectly well.
You'll find plenty of people who believe the umount behaviour is incorrect (and it should just GC them) as wel as the fact that uninterruptible sleep is a bad idea
Hi,
Quoted 3 lines · Jos Hulzink
Maybe it is an option to add the --I_know_Im_stupid option to the swapoff command line ? (Also known as the --force flag). This way we can both return an error when the OS lacks memory and force a swapoff.
What's wrong with the current behavior? If the system can't live without swap, why forcing it dead?
Regards, Thunder
Signature · 7 lines
(Use http://www.ebb.org/ungeek if you can't decode) ------BEGIN GEEK CODE BLOCK------ Version: 3.12 GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$ N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G e++++ h* r--- y- ------END GEEK CODE BLOCK------
Hi,
Quoted 1 line · Szakacsits Szabolcs
What about the many hundred counter-examples
These cases are different.
Quoted 1 line
(e.g. umount gives EBUSY,
Simply because you _will_ lose data if you umount a device that's being scribbled on.
Quoted 1 line
kill can't kill processes in uninterruptible sleep
Because the uninterruptible sleep means the process is waiting for data. If you destroy the process and kill an interrupt handler, you _will_ crash.
Quoted 3 lines
, etc, etc)? Why the system knows better then admin in these cases? Why just don't destroy the data, crash the system as you suggest in your case?
This case is different. If you swapoff /dev/scsi/path/to/dead/disk, your system will likely live on. Possibly you'll have some tasks killed, but we're well up.
Alan was referring to cases where it's unlikely that we die of it, you're referring to cases where it's clear that the system won't get through.
Regards, Thunder
Signature · 7 lines
(Use http://www.ebb.org/ungeek if you can't decode) ------BEGIN GEEK CODE BLOCK------ Version: 3.12 GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$ N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G e++++ h* r--- y- ------END GEEK CODE BLOCK------
Quoted 3 lines · Thunder from the hill
Quoted 1 line
(e.g. umount gives EBUSY,
Simply because you _will_ lose data if you umount a device that's being scribbled on.
Potentially you _will_ lose data in swapoff case. Kernel could know when it's save to do but no way for admin to calculate.
Szaka
Quoted 4 lines · Alan Cox
Quoted 1 line · Szakacsits Szabolcs
What about the many hundred counter-examples (e.g. umount gives EBUSY,
umount -f.
The wasn't the question. *Why* umount (without -f) knows better then admin? You answered *how* unconditionally umount.
Quoted 3 lines
Quoted 1 line
kill can't kill processes in uninterruptible sleep, etc, etc)? Why the
In these cases the kernel infrastructure doesn't support the ability to recover from such a state,
You again anwered else but ironically you just rebute yourself that there are cases when the system knows better then the admin.
Quoted 2 lines
very different from stopping a user doing something it can handle perfectly well.
What the patch claims is no OOM. In the swapoff case potentially there are OOM's. This is called bug (the feature not follows the behavior what it specified when admin turned it on). Why do you call this bug perfectly handled case? What differentiate this case from all other when the system knows better not to destroy your data without at least a "force" operation for example?
Szaka
Hi,
Quoted 2 lines · Szakacsits Szabolcs
Potentially you _will_ lose data in swapoff case. Kernel could know when it's save to do but no way for admin to calculate.
The difference is between you will definitely loose data and you will potentially loose data.
Regards, Thunder
Signature · 7 lines
(Use http://www.ebb.org/ungeek if you can't decode) ------BEGIN GEEK CODE BLOCK------ Version: 3.12 GCS/E/G/S/AT d- s++:-- a? C++$ ULAVHI++++$ P++$ L++++(+++++)$ E W-$ N--- o? K? w-- O- M V$ PS+ PE- Y- PGP+ t+ 5+ X+ R- !tv b++ DI? !D G e++++ h* r--- y- ------END GEEK CODE BLOCK------
Quoted 6 lines · Szakacsits Szabolcs
Quoted 3 lines
Quoted 1 line
kill can't kill processes in uninterruptible sleep, etc, etc)? Why the
In these cases the kernel infrastructure doesn't support the ability to recover from such a state,
You again anwered else but ironically you just rebute yourself that there are cases when the system knows better then the admin.
And purists consider those flaws
Quoted 6 lines
What the patch claims is no OOM. In the swapoff case potentially there are OOM's. This is called bug (the feature not follows the behavior what it specified when admin turned it on). Why do you call this bug perfectly handled case? What differentiate this case from all other when the system knows better not to destroy your data without at least a "force" operation for example?
Lets put this bluntly. Your swapdisk is losing sectors left right and centre. You propose a system where the kernel says "sorry might cause an OOM" and I lose everything as the disk goes down. Letting the admin set policy means I can swapoff, maybe lose a program or two to OOM but not lose the entire system in the process.
Its quite clear that being able to override the kernels assumptions about what is right are sensible. It always has been
Quoted 9 lines · Alan Cox
Lets put this bluntly. Your swapdisk is losing sectors left right and centre. You propose a system where the kernel says "sorry might cause an OOM" and I lose everything as the disk goes down. Letting the admin set policy means I can swapoff, maybe lose a program or two to OOM but not lose the entire system in the process.
Its quite clear that being able to override the kernels assumptions about what is right are sensible. It always has been
Suggested compromise: swapoff (in loose overcommit-permitted mode) should always swap off as much as it can, a small margin short of causing OOM, but should then give up with ENOMEM (leaving the whole swap area available again, for consistency). Seeing its failure, the admin can then choose processes to kill (overriding the kernel's assumptions about what is right to kill), and try swapoff again.
At present it never gives up: I do intend to fix that.
In strict no-overcommit mode, it should probably decide in advance whether to embark on swapping off: I think you suggested that earlier in the thread, that it's acceptable to switch overcommit mode temporarily to achieve whichever behaviour is desirable?
Hugh
Quoted 4 lines · Hugh Dickins
In strict no-overcommit mode, it should probably decide in advance whether to embark on swapping off: I think you suggested that earlier in the thread, that it's acceptable to switch overcommit mode temporarily to achieve whichever behaviour is desirable?
Yes. I have no problem with
#swapoff -a
swapoff: out of memory
#vmctl overcommit 1
#swapoff -a