Re: Linux 2.2.15pre12

From: Gregory Maxwell (greg@linuxpower.cx)
Date: Mon Mar 06 2000 - 14:14:05 EST


On Mon, 6 Mar 2000, Paul Jakma wrote:

> On Mon, 6 Mar 2000, Gregory Maxwell wrote:
>
> > On Mon, 6 Mar 2000, Paul Jakma wrote:
> >
> > > another question, forgive me if it's stupid: Why do we even allow
> > > overcommited memory? What reason is there is to support app's that
> > > malloc() a huge amount of memory without using that memory?
> > [snip]
> >
> > This isn't the only case. Linux uses COW paging on fork. I.e. if an app
>
> i understand this. and i'm wondering would it possible to turn off
> overcommit, yet still keep the COW behaviour? eg it should be possible
> to mark pages in swap as used in a kernel table, without actually
> writing to them yet. ie if we have x pages of swap available, on fork
> decrement the available pages of swap. Then later on when at the point
> the process actually dirties the page the kernel could whatever more
> extensive housekeeping is needed.

Yes, you can currently do this. Turning off overcommit doesn't stop COW,
but it takes away it's memory/swap advantage.

[snip]
> as i understand you can't turn off overcommit in linux at the
> moment. Yet it would be a useful option to have. I can easily imagine
> certain situations where i would choose to turn off overcommit at the
> expense of more swap if it would guarantee that OOM would never
> happen. (hard disk space is cheap compared to downtime)
[snip]

/proc/sys/vm/overcommit_memory
overcommit_memory:

This value contains a flag that enables memory overcommitment.
When this flag is 0, the kernel checks before each malloc()
to see if there's enough memory left. If the flag is nonzero,
the system pretends there's always enough memory.

This feature can be very useful because there are a lot of
programs that malloc() huge amounts of memory "just-in-case"
and don't much of it.

Look at: mm/mmap.c::vm_enough_memory() for more information.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:20 EST