Messages in this thread | | | Date | Thu, 14 Mar 2002 08:24:43 +0000 (GMT) | From | Hugh Dickins <> | Subject | Re: 23 second kernel compile / pagemap_lru_lock improvement |
| |
On Wed, 13 Mar 2002, Martin J. Bligh wrote: > > > > I'm surprised it made any difference at all, I think the patch mainly > > adds more tests: activate_page is only called from mark_page_accessed > > (after testing !PageActive) and from fail_writepage (where usually > > !PageActive). I don't think many !PageLRU pages can get there. > > It does seem distinctly odd that we take the lock, *then* test whether > we actually need to do anything. Is the test just a sanity check that > should never fail?
It's quite normal to have to recheck flags after taking the relevant lock. Here I think the two flags have different needs. I've not checked rigorously, but I believe that the PageLRU flag cannot change beneath us (but does need to be checked either outside or inside the lock); whereas it's easy to find races where PageActive is set outside but found clear once inside the lock, or vice versa.
Now it doesn't matter if we make a wrong activity decision occasionally, but we do need to keep internal consistency. If PageActive were not rechecked inside pagemap_lru_lock, nr_active_pages and nr_inactive_pages would become approximate instead of exact counts; then there's a danger they would tend to drift in one direction, unbalancing shrink_caches.
Hugh
- 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/
| |