Re: pre12 VM doubts and patch
Linus Torvalds (torvalds@transmeta.com)
Wed, 19 Sep 2001 16:16:13 -0700 (PDT)
On Wed, 19 Sep 2001, Andrea Arcangeli wrote:
>
> On Wed, Sep 19, 2001 at 08:42:39PM +0100, Hugh Dickins wrote:
> > --- 2.4.10-pre12/mm/swap_state.c Wed Sep 19 14:05:54 2001
> > +++ linux/mm/swap_state.c Mon Sep 17 06:30:26 2001
> > @@ -23,6 +23,17 @@
> > */
> > static int swap_writepage(struct page *page)
> > {
> > + /* One for the page cache, one for this user, one for page->buffers */
> > + if (page_count(page) > 2 + !!page->buffers)
>
> this is racy, you have to spin_lock(&pagecache_lock) before you can
> expect the page_count() stays constant. then after you checked the page
> has count == 1, you must atomically drop it from the pagecache so it's
> not visible anymore to the swapin lookups.
No.
Note how it is a _heuristic_ only. The "safe" answer is always to say "the
page is in use", and note that once the page_count has dropped to 2 or
less, it won't increase unless somebody else has a swap count..
And we check for the "somebody else has a swap count" two lines lower.
(And the swap count is stable at 1 while the page is locked, because
nobody can increase the swap count without locking the page and dropping
it from their VM).
Do you see anything wrong with that logic?
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/