Re: Allow swapping over nbd and more similar magic

Pavel Machek (pavel@suse.cz)
Mon, 20 Dec 1999 20:58:29 +0100


Hi!

> > /*
> > + * The background page discarder, started from the init process.
> > + *
> > + * This basically executes once a second, trickling out pages
> > + * so that we have _some_ free memory available even if there
> > + * is no other activity that frees anything up.
> > + * We want this to be separate from kswapd, because we do not
> > + * want to block, no matter what happens. As long as there are
> > + * some clean pages backed it file (which is true under normal
> > + * conditions, SCT tells me), we can swap over anything.
>
> I guess this means that you want to do two things:
> - swap out dirty pages when we have memory left
> - swap out / free _clean_ pages when we are short on
> memory

> That is something completely different from the naive
> tactic you're trying to use in the next code fragment.

What I tried to do is to just free _clean_ pages when short on
memory. I did not want to touch anything else in order not to break
some balance. That do_try_to_free_pages(0) should kill one clean
page. (Do you have idea how to write it in short piece of code?)

> > +int kreclaimd(void *unused)
>
> [snip]
>
> > + while (1) {
> > + do {
> > + int count = SWAP_CLUSTER_MAX;
> > +
> > + /* Normally, lets let kswapd do its work. If memory gets really low,
> > + we'll want to clean up something to break the deadlock. */
> > + if (nr_free_pages() >= freepages.low)
> > + break;
> > + while (do_try_to_free_pages(0) && count--) /* We don't want it to do any I/O */
> > + ;
> > +// printk( "kreclaimd: Freed %d pages\n", SWAP_CLUSTER_MAX - count );
> > + } while (!tsk->need_resched);
> }
>
> Now what if:
> - there already are a number of async swapouts
> in progress (likely since kreclaimd only runs if
> memory is tight)
> - kreclaimd tries to swap out a few dirty pages
> and runs into trouble

Kreclaimd should not try to swap out anything...

> I guess you want to change the system a bit so that
> one daemon only reclaims clean pages and the other
> daemon has a condition where it cleans up dirty
> pages without freeing memory on a periodic basis.
>
> (ie. kswapd calling swap_out() but never shrink_mmap()
> when free memory is high enough)

Does that mean that I should call shrink_mmap(6, 0) instead?
Pavel

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents me at discuss@linmodems.org

- 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/