Re: Possible memory ordering bug in page reclaim?

From: Nick Piggin
Date: Sat Oct 15 2005 - 19:11:17 EST

Linus Torvalds wrote:

I agree, however, that it looks like PG_dirty is racy. Probably not in practice, but still.

So I'd suggest adding a smp_wmb() into set_page_dirty, and the rmb where Nick suggested.

So I'd suggest a patch something more like this.. Marking the dirty/count cases unlikely too in mm/page-writeback.c, since we should have tested for these conditions optimistically outside the lock.

As Dave suggested, I think there is too much other code that depends on
these atomics to be barriers for us to change it (at least not in this
patch! :)).

Comments? Nick, did you have some test-case that you think might actually have been impacted by this?

I guess your vmscan.c hunks are slightly nicer, though I might put
'cannot_free' right at the end, because it will be a very uncommon case.

And no, I don't have a test case. In fact, I wouldn't be surprised if
nobody anywhere has ever hit it :) I was just browsing code...


SUSE Labs, Novell Inc.

Send instant messages to your online friends -
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at