Earl Pottinger wrote: > > Ingo Weinhold wrote: > > To prevent that all caches implemented in kernelland (at > > least all caches of relevant size) should register as low resource handlers > > and free up resources, when requested. > > Sorry, I don't know how to do this properly . Could you give me a hint or two > as to where to find sample code please? It's also private kernel API. Have a look at <low_resource_manager.h> [1] for the interface. There are several kernel services registering low resource handlers [2]. The basic mechanism is rather simple: You register a callback for the kinds of resources you are using (in your case probably both pages, memory, and address space) which gets called whenever the state of one or more of the resources changes and perdiodically while it remains low. In the callback you should check the state and, if it is low, try to release the resource in question -- the more aggressively the more critical the state is. Travis Geiselbrecht wrote: > On Mon, Aug 22, 2011 at 1:06 PM, Earl Pottinger > <earl_colby_pottinger@xxxxxxxxx> wrote: > >> Ingo Weinhold wrote: > >> To prevent that all caches implemented in kernelland (at > >> least all caches of relevant size) should register as low resource handlers > >> and free up resources, when requested. > > > > Sorry, I don't know how to do this properly . Could you give me a hint or > > two as to where to find sample code please? > > Really, the general solution to ramdisks like this on most oses are > not to permanently map the array into kernel space, but to directly > allocate from the physical page allocator and track the pages > yourself, and map them on demand. In the case of the haiku vm, the > most optimal way would be to somehow (not sure there's an api for it) > map a vm_cache to an anonymous memory object and simply map pieces of > it into kernel space on demand. That way the VM still does the > physical page tracking, and can even page out unused bits. This is exactly how the IOCache implementation works [3]. And that's more or less also my vision for a block cache rewrite. CU, Ingo [1] http://dev.haiku-os.org/browser/haiku/trunk/headers/private/kernel/low_resource_manager.h [2] http://haiku.it.su.se:8180/source/search?q=&defs=&refs=register_low_resource_handler&path=&hist= [3] http://dev.haiku-os.org/browser/haiku/trunk/src/system/kernel/device_manager/IOCache.cpp