Re: [PATCH] page->flags corruption fix

From: Marcelo Tosatti
Date: Wed Oct 08 2003 - 12:47:12 EST




On Wed, 8 Oct 2003, Hugh Dickins wrote:

> On Wed, 8 Oct 2003, Rik van Riel wrote:
> >
> > 1) cpu A adds page P to the swap cache, loading page->flags
> > and modifying it locally
>
> Right, the add_to_swap_cache in try_to_swap_out.
>
> > 2) a second thread scans a page table entry and sees that
> > the page was accessed, so cpu B moves page P to the
> > active list
>
> Right, the mark_page_accessed in try_to_swap_out
> (I don't see any other mark_page_accessed as problematic).
> Or the del_page_from_active_list in refill_inactive.
>
> > 3) cpu A undoes the PG_inactive -> PG_active bit change,
> > corrupting the page->flags of P
>
> (Mainline is easier than -rmap since no separate PG_inactive bit.)
>
> Thanks a lot for explaining, I see it now. Personally I'd prefer a
> lighter weight patch, either pagemap_lru_lock within add_to_swap_cache,
> or better moving the PG_flags clearing from __add_to_page_cache into
> __free_pages_ok, where I still believe it can be done non-atomically.
>
> But you've proved your point, and I understand you preferring a more
> straightforward and future-proof way. I'm not writing an alternative
> patch, don't let me stand in the way of progress...
>
> A little of the above explanation in the change comment would be nice.

Maybe comments on top of the code?

Rik? :)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/