diff -r -c generic-2.4.16/mm/mmap.c vm-lapdog/mm/mmap.c *** generic-2.4.16/mm/mmap.c Sun Nov 4 10:17:20 2001 --- vm-lapdog/mm/mmap.c Sun Dec 2 22:10:46 2001 *************** *** 62,93 **** */ unsigned long free; /* Sometimes we want to use more memory than we have. */ if (sysctl_overcommit_memory) return 1; - /* The page cache contains buffer pages these days.. */ - free = atomic_read(&page_cache_size); - free += nr_free_pages(); - free += nr_swap_pages; - - /* - * This double-counts: the nrpages are both in the page-cache - * and in the swapper space. At the same time, this compensates - * for the swap-space over-allocation (ie "nr_swap_pages" being - * too small. - */ - free += swapper_space.nrpages; - /* ! * The code below doesn't account for free space in the inode ! * and dentry slab cache, slab cache fragmentation, inodes and ! * dentries which will become freeable under VM load, etc. ! * Lets just hope all these (complex) factors balance out... */ ! free += (dentry_stat.nr_unused * sizeof(struct dentry)) >> PAGE_SHIFT; ! free += (inodes_stat.nr_unused * sizeof(struct inode)) >> PAGE_SHIFT; return free > pages; } --- 62,98 ---- */ unsigned long free; + unsigned long free_pages; /* Sometimes we want to use more memory than we have. */ if (sysctl_overcommit_memory) return 1; /* ! * Um... how about a better algorithm yet. ! * Start with the theoretical maximum--size of RAM + size of swap. ! * Reduce the RAM by 1/8, up to a maximum of MAX_OS_RESERVED_MEM ! * (16MB) to allow for the OS to have *some* work to get stuff ! * done with. */ ! #define MAX_OS_RESERVED_MEM 4096 /* in pages */ ! free_pages = nr_free_pages(); ! if (free_pages < (max_mapnr >> 3)) { /* free_pages < 1/8 physical */ ! free = nr_swap_pages + swapper_space.nrpages; /* take swap free */ ! /* ! * Now compensate for the RAM short-fall... ! */ ! if (free > ((max_mapnr >> 3) - free_pages)) { /* swap > RAM shortfall */ ! free -= (max_mapnr >> 3) - free_pages; ! } else { ! free = 0; ! } ! } else { ! free = free_pages - (max_mapnr >> 3); ! if (free > MAX_OS_RESERVED_MEM) ! free = MAX_OS_RESERVED_MEM; ! free += nr_swap_pages + swapper_space.nrpages; ! } return free > pages; } diff -r -c generic-2.4.16/mm/page_alloc.c vm-lapdog/mm/page_alloc.c *** generic-2.4.16/mm/page_alloc.c Mon Nov 19 16:35:40 2001 --- vm-lapdog/mm/page_alloc.c Sun Dec 2 18:50:29 2001 *************** *** 389,397 **** } } ! /* Don't let big-order allocations loop */ ! if (order > 3) ! return NULL; /* Yield for kswapd, and try again */ current->policy |= SCHED_YIELD; --- 389,405 ---- } } ! /* ! * So this is a sleep-able request for memory--we're presuming ! * that vm_enough_memory() hasn't indicated more available VM ! * than we actually have, or this process could end up looping ! * here. On the other hand, that's far less detrimental than ! * killing processes! ! * ! * More ideal would be if vm_enough_memory() decreased the ! * available memory counts, but allowed *that* request to ! * claim those pages as if they were free. ! */ /* Yield for kswapd, and try again */ current->policy |= SCHED_YIELD;