From: Marcelo Tosatti <marcelo@conectiva.com.br>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Jonathan Morton <chromi@cyberspace.org>,
Rik van Riel <riel@conectiva.com.br>, Ingo Molnar <mingo@elte.hu>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linux Kernel List <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org, Szabolcs Szakacsits <szaka@f-secure.com>
Subject: Re: [patch] swap-speedup-2.4.3-A1, massive swapping speedup
Date: Mon, 23 Apr 2001 19:13:15 -0300 (BRT) [thread overview]
Message-ID: <Pine.LNX.4.21.0104231910090.1179-100000@freak.distro.conectiva> (raw)
In-Reply-To: <Pine.LNX.4.21.0104231003480.13206-100000@penguin.transmeta.com>
On Mon, 23 Apr 2001, Linus Torvalds wrote:
>
> On Mon, 23 Apr 2001, Jonathan Morton wrote:
> > >There seems to be one more reason, take a look at the function
> > >read_swap_cache_async() in swap_state.c, around line 240:
> > >
> > > /*
> > > * Add it to the swap cache and read its contents.
> > > */
> > > lock_page(new_page);
> > > add_to_swap_cache(new_page, entry);
> > > rw_swap_page(READ, new_page, wait);
> > > return new_page;
> > >
> > >Here we add an "empty" page to the swap cache and use the
> > >page lock to protect people from reading this non-up-to-date
> > >page.
> >
> > How about reversing the order of the calls - ie. add the page to the cache
> > only when it's been filled? That would fix the race.
>
> No. The page cache is used as the IO synchronization point, both for
> swapping and for regular IO. You have to add the page in _first_, because
> otherwise you may end up doing multiple IO's from different pages.
>
> The proper fix is to do the equivalent of this on all the lookup paths
> that want a valid page:
>
> if (!PageUptodate(page)) {
> lock_page(page);
> if (PageUptodate(page)) {
> unlock_page(page);
> return 0;
> }
> rw_swap_page(page, 0);
> wait_on_page(page);
> if (!PageUptodate(page))
> return -EIO;
> }
> return 0;
>
> This is the whole point of the "uptodate" flag, and for all I know we may
> already do all of this (it's certainly the normal setup).
>
> Note how we do NOT block on write-backs in the above: the page will be
> up-to-date from the bery beginning (it had _better_ be, it's hard to write
> back a swap page that isn't up-to-date ;).
>
> The above is how all the file paths work.
Please don't forget about swapin readahead.
If the page is not uptodated and we are doing swapin readahead on it, we
want to fail if the page is already locked (which means its already under
IO).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
prev parent reply other threads:[~2001-04-23 22:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-23 9:20 Ingo Molnar
2001-04-23 15:33 ` Rik van Riel
2001-04-23 16:05 ` [patch] swap-speedup-2.4.3-A2 Ingo Molnar
2001-04-23 17:17 ` Linus Torvalds
2001-04-23 16:54 ` Ingo Molnar
2001-04-24 5:44 ` [patch] swap-speedup-2.4.3-B3 Ingo Molnar
2001-04-24 16:38 ` Linus Torvalds
2001-04-25 2:28 ` Marcelo Tosatti
2001-04-23 16:53 ` [patch] swap-speedup-2.4.3-A1, massive swapping speedup Jonathan Morton
2001-04-23 17:10 ` Linus Torvalds
2001-04-23 22:13 ` Marcelo Tosatti [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.21.0104231910090.1179-100000@freak.distro.conectiva \
--to=marcelo@conectiva.com.br \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=chromi@cyberspace.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=riel@conectiva.com.br \
--cc=szaka@f-secure.com \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox