On Tue, 28 Aug 2007, Javier Cabezas Rodríguez wrote: > Now I am implementing the memory freeing. The biggest problem here is > that the regular swapping out algorithm of the kernel only frees memory > when it is needed, so I don't know which is the behaviour of the > standard routines in this situation. I have looked at the standard > swapping functions (shrink_zones, shrink_zone, ...) and I think they > handle all the process page types I enumerated previously. So, for each > VMA of the process, I build a page list with all the pages and pass it > as a parameter to shrink_page_list (before that I remove them from the > LRU active/inactive lists with del_page_from_lru). You may want to look at the page migration logic and in particular the implementation of memory unplug in Andrew's tree. Memory unplug moves memory to another node. You could use the same logic but instead of moving pages reclaim them. Movable pages are reclaimable and much of the page migration logic is based on reclaim.