Re:Is RAM wiped before use in another LXC container?
by lxgr on Wednesday April 05, 2023 @10:34AM
(#35454953)
I think you've got it backwards: With overcommit, there is no memory reservation. The forked processes gets an exact copy of the other's page table, but with all writable memory marked as copy-on-write instead. The kernel might well be tallying these up to some number, but nothing important happens with it.
Only without overcommit does the kernel does need to start accounting for hypothetically-writable memory before it actually is written to.
Re:Is RAM wiped before use in another LXC container?
by reisse on Wednesday April 05, 2023 @01:02PM
(#35457219)
Yes, you're right here, that was what I wanted to say but probably was not able to formulate.
Re:Is RAM wiped before use in another LXC container?
by blitzkrieg3 on Wednesday April 05, 2023 @11:59AM
(#35456294)
This is a misconception you and parent are perpetuating. fork() existed in this problematic 2x memory implementation _way_ before overcommit, and overcommit was non-existent or disabled on Unix (which has fork()) before Linux made it the default. Today with CoW we don't even have this "reserve memory for forked process" problem, so overcommit does nothing for us with regard to fork()/exec() (to say nothing of the vfork()/clone() point others have brought up). But if you want you can still disable overcommit on linux and observe that your apps can still create new processes.
What overcommit enables is more efficient use of memory for applications that request more memory than they use (which is most of them) and more efficient use of page cache. It also pretty much guarantees an app gets memory when it asks for it, at the cost of getting oom-killed later if the system as a whole runs out.
If kernel could not reserve memory for forked process, overcommit would not be necessary.