Re: memory handling in pre5/pre6

From: Andrea Arcangeli (andrea@suse.de)
Date: Tue Apr 18 2000 - 13:20:40 EST


On Mon, 17 Apr 2000, Rik van Riel wrote:

>--- linux-2.3.99-pre6-3/mm/filemap.c.orig Mon Apr 17 12:21:46 2000
>+++ linux-2.3.99-pre6-3/mm/filemap.c Mon Apr 17 19:20:54 2000
>@@ -149,11 +149,13 @@
>
> /* page wholly truncated - free it */
> if (offset >= start) {
>+ if (TryLockPage(page)) {
>+ spin_unlock(&pagecache_lock);
>+ goto repeat;
>+ }
> get_page(page);
> spin_unlock(&pagecache_lock);
>
>- lock_page(page);
>-
> if (!page->buffers || block_flushpage(page, 0))
> lru_cache_del(page);
>
>@@ -191,11 +193,13 @@
> continue;
>
> /* partial truncate, clear end of page */
>+ if (TryLockPage(page)) {
>+ spin_unlock(&pagecache_lock);
>+ goto repeat;
>+ }
> get_page(page);
> spin_unlock(&pagecache_lock);
>
>- lock_page(page);
>-
> memclear_highpage_flush(page, partial, PAGE_CACHE_SIZE-partial);
> if (page->buffers)
> block_flushpage(page, partial);

You'll lockup. Also you aren't fixing anything. There is no race to fix in
truncate_inode_pages.

>@@ -234,6 +238,16 @@
> list_del(page_lru);
>
> dispose = &zone->lru_cache;
>+ /* don't account passes over not DMA pages */
>+ if (zone && (!memclass(page->zone, zone)))
>+ goto dispose_continue;
>+
>+ count--;
>+ dispose = &old;
>+ /* the page is in use, we can't free it now */
>+ if (!page->buffers && page_count(page) > 1)
>+ goto dispose_continue;
>+
> if (test_and_clear_bit(PG_referenced, &page->flags))
> /* Roll the page at the top of the lru list,
> * we could also be more aggressive putting
>@@ -242,18 +256,7 @@
> */
> goto dispose_continue;
>
>- dispose = &old;
>- /* don't account passes over not DMA pages */
>- if (zone && (!memclass(page->zone, zone)))
>- goto dispose_continue;
>-
>- count--;
>-
> dispose = &young;
>-
>- /* avoid unscalable SMP locking */
>- if (!page->buffers && page_count(page) > 1)
>- goto dispose_continue;
>
> if (TryLockPage(page))
> goto dispose_continue;

This will make your machine sloowww and you also won't be able to shrink
the cache at a certain point and you'll swapout even more at that point.
Just try this:

        find / -type f -exec cp {} /dev/null \; >/dev/null

then you'll understand what I'm talking about :).

I know what's going wrong in the memory balancing since the 99 pre patches
(and IIRC I just mentioned that at once on the list). try_to_free_pages is
supposed to work on a classzone while now it's recalled per each zone
without breaking the loop. zone_balance_memory is seriously broken. Also
the code that checks if we are now on memory is racy, we have to avoid
somebody to free pages from under us before we start trying to free memory
or we could swapout by mistake or kill tasks by mistake. Work in
progress... People using HIGHMEM will have much more problems, btw. OTOH
16mbyte memory machines will run happy.

Andrea

-
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 : Sun Apr 23 2000 - 21:00:13 EST