Date: Tue, 8 Jan 2008 00:57:21 +0000 From: "Igor Mozolevsky" <igor@hybrid-lab.co.uk> To: "Poul-Henning Kamp" <phk@phk.freebsd.dk> Cc: Kostik Belousov <kostikbel@gmail.com>, Andrew Reilly <andrew-freebsd@areilly.bpc-users.org>, freebsd-current@freebsd.org, Peter Jeremy <peterjeremy@optushome.com.au> Subject: Re: sbrk(2) broken Message-ID: <a2b6592c0801071657s43fcc739jac09baedef7b7532@mail.gmail.com> In-Reply-To: <15094.1199751424@critter.freebsd.dk> References: <a2b6592c0801071606g4c0dcb9ap117e345fda5e7e5f@mail.gmail.com> <15094.1199751424@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 08/01/2008, Poul-Henning Kamp <phk@phk.freebsd.dk> wrote: > In message <a2b6592c0801071606g4c0dcb9ap117e345fda5e7e5f@mail.gmail.com>, "Igor > Mozolevsky" writes: > >On 07/01/2008, Andrew Reilly <andrew-freebsd@areilly.bpc-users.org> wrote: > >> On Mon, 07 Jan 2008 13:18:47 +0000 > >> "Poul-Henning Kamp" <phk@phk.freebsd.dk> wrote: > >> > >> > Yes, but you will not see this complication, it will be hidden > >> > in the implementation of malloc(3). > >> > >> How could you hide it inside malloc? Would malloc start > >> returning 0 after receiving the "less mem than desirable" > >> signal? Would it ever go back to returning non-zero? > > > >I'm with Andrew on this one. The only (sensible) way I could see it > >being hidden behind malloc() is if malloc() blocks until sufficient > >memory becomes available. > > You should read some recent literature on malloc(3), my own and > Jasons papers are good places to start. Can you provide some refs/links, unfortunately googling for PKH+malloc() is pretty futile! > For performance reasons, malloc(3) will hold on to a number of pages > that theoretically could be given back to the kernel, simply because > it expects to need them shortly. > > Such parameters and many others of the malloc implementation can > be tweaked to "waste" more or less memory, in response to a sensibly > granular indication from the kernel about how bad things are. > > Also, many subsystems in the kernel could adjust their memory use > in response to a "memory pressure" indication, if memory is tight, > we could cache vnodes and inodes less agressively, if things are > going truly bad, we can even ditch all non-active entries from > these caches. I don't think it's the kernel that is being ill-mannered (unless, of course, it's running ZFS ;-)) by eating up the memory, it's the user processes that consume most resources. > Nothing prevents an intelligent process from listening in and > doing sensible things, firefox could ditch the memory cache of > pages for instance. How do you propose they 'eavesdrop' on the kernel? Baring in mind that most apps nowadays are written for Linux and are hacked to be portable afterwards (just look at the number of patches in the ports tree), it's much simpler to write a signal handler than FreeBSD-kernel specific listening code... > But we can't get anywhere until some VM wizard produces the > three "lamps" for us to look at in the first place, that's where > we have been stuck for the last 10 years. I think the problem is not in providing the lamps to indicate the state, but figuring out an algorithm for judging green->yellow and yellow->green transitions... Igor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a2b6592c0801071657s43fcc739jac09baedef7b7532>