On Wed, May 05, 2010 at 10:34:03AM -0700, Linus Torvalds wrote:
Maybe I should have read mail before sending off a work-in-progress patch :/ .
In the direction I was taking, only rmap_walk took the deepest lock (I called
it oldest but hey) and would take other anon_vma locks as well. The objective
was to make sure the order the locks were taken in was correct.
I think you are suggesting that any anon_vma lock that is taken should always
take the deepest lock. Am I right and is that necessary? The downsides is that
there is a single lock that is hotter. The upside is that rmap_walk no longer
has different semantics as vma_adjust and friends because it's the same lock.
I think I got that right at least.
That was my understanding but I'm still not sure of my footing on the
anon_vma changes so doubted myself.
Not sure if this is necessary. In the case of rmap_walk(), it's already
held. In the other cases, a semaphore is held which should prevent the first
anon_vma disappearing.
Can it be empty? I didn't think it was possible as the anon_vma must
have at least it's own chain.
Other than terminology and minor implementation details, this is more or
less what I came up with as well.
This is the only significant point we differ on. Do we;
1. Always take the deepest anon_vma lock using the lock anon_vma lock
just to protect the list long enough to find it?
or
2. Only have rmap_walk use the deepest anon_vma lock just so it takes
multiple locks in the correct order?
I am not seeing a killer advantage of one over the order. While (2)
would mean the same lock is always taken - it's a double lock to get it
"lock local, find deepest, lock deepest, release local" which adds a
small overhead to the common path. With 1, the searching around is
confined to migration.
Andrea, is there an advantage of one over the other for you or is Rik's
approach just better overall?
Rik, any opinions?
Well, for what it works, the basic principal appears to work. At least,
the machine I'm testing my own patch on hasn't managed to deadlock yet.
Considering that we came up with more or less the same idea, the basic
idea of "lock the deepest anon_vma" must be sound :/
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
--