Re: MM deadlock [was: Re: arca-vm-8...]

Zlatko Calusic
1999-01-12T18:45:35Z

Linus Torvalds <torvalds@transmeta.com> writes:

> On Tue, 12 Jan 1999, Stephen C. Tweedie wrote:
> >
> > On 11 Jan 1999 00:04:11 -0600, ebiederm+eric@ccr.net (Eric W. Biederman)
> > said:
> >
> > > Oh, and just as a side note we are currently unfairly penalizing
> > > threaded programs by doing for_each_task instead of for_each_mm in the
> > > swapout code...
> >
> > I know, on my TODO list...
>
> Actually, this one is _really_ easy to fix.
>
> The truly trivial fix is to just move "swap_cnt" into the mm structure,
> and you're all done. You'd still walk the list with for_each_task(), but
> it no longer matters.
>
> Linus
>

Not related to this, but I (hopefully correctly) observed that SHM
swap I/O is done synchronously.

Could somebody spare a minute to explain why is that so, and what
needs to be done to make SHM swapping asynchronous?

Also, while we're at MM fixes, I'm appending below a small patch that
will improve interactive feel.

After number of async pages gets bigger than pager_daemon.swap_cluster
(= SWAP_CLUSTER_MAX), swapin readahead becomes synchronous, and that
hurts performance. It is better to skip readahead in such situations,
and that is also more fair to swapout. Andrea came to exactly the same
conclusion, independent of me (on the same day :)).

diff -urN linux-pre-7/mm/page_alloc.c linux/mm/page_alloc.c
--- linux-pre-7/mm/page_alloc.c Tue Jan 11 07:28:06 1999
+++ linux/mm/page_alloc.c Tue Jan 11 07:29:44 1999
@@ -358,6 +358,8 @@
for (i = 1 << page_cluster; i > 0; i--) {
if (offset >= swapdev->max)
return;
+ if (atomic_read(&nr_async_pages) > pager_daemon.swap_cluster)
+ return;
if (!swapdev->swap_map[offset] ||
swapdev->swap_map[offset] == SWAP_MAP_BAD ||
test_bit(offset, swapdev->swap_lockmap))

Regards,
--
Zlatko