Re: Simple fix for swap_out (the 1st August patch)

Bill Hawes (whawes@star.net)
Sat, 02 Aug 1997 14:56:48 -0400


Dr. Werner Fink wrote:
> Hmmm ... in my current patch I'm use the follwing statement:
>
> if (nr_free_pages > 5) {
> /* and repeat until we find something good */
> if (grow_buffers(GFP_ATOMIC, size)) {
> needed -= PAGE_SIZE;
> goto repeat;
> };
> }
>
> wakeup_bdflush(1);
>
> that means if really low on mem or grow_buffers() fails wakeup_bdflush()
> is called before refill_freelist() returns to the caller.

A wakeup_bdflush(1) will block for a while, so even if this task managed
to free any buffers, the buffers will probably be used up by other tasks
during the call to bdflush. So returning after wakeup probably won't
help -- the task will just fall back into refill_freelist, and have to
try for a full quota again. So it's probably better to keep the goto
repeat after the wakeup.

The best place to test the free_list for early return is just before the
call to wakeup_bdflush -- this is where you're most likely to have some
buffers on the free list. And at this point you've only made one pass
through the allocations, in order to minimize the amount of free page
reserve converted into buffers.

I want to argue consistently that refill_freelist needs to return early,
even with just one buffer, when the system is having memory problems. I
went back and reviewed a patch Bernd Schmidt posted a while ago, and
even though his approach to the problem was very different, he also
returned early when memory problems were present.

Regards,
Bill