> HOWEVER, _then_ I started wondering about whether the thing needs to be> removed from the swap cache at all, and came to the conclusion that for> the only case we really care about (and the only case where we _can_> re-use the swap cache page), we don't actually need to remove it from the> cache in the first place.

There is a second case, though you may be handling it differently now.Typically the case is swap < RAM. But basically when we don't haveenough have enough swap pages it pays to drop pages from the swapcache. So in as many places as we can figuring out how to dropswap pages when the swap space is practically full is important.

The other alternative implementation is to create a logical backingstore for anonymous pages (so the don't need a presence in the pagetable) and then we could just walk that backing store and free up swapspace on demand. Though if you can put anonymous pages in the pagecache now, a variation on that idea may be possible. We don'twant to remove the swap from pages that aren't in ram.

> Does anybody see why we have to remove it from the swap cache at all?