[lkml]   [2010]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 4/5] always lock the root (oldest) anon_vma

On Wed, 12 May 2010, Rik van Riel wrote:
> I suspect the atomic_dec_and_lock in the KVM code is being used
> to prevent the following race:
> 1) KSM code reduces the refcount to 0
> 2) munmap on other CPU frees the anon_vma
> 3) KSM code takes the anon_vma lock,
> which now lives in freed memory

Hmm. Well, if it were just about the lock, then that would be fine. That's
why we do the whole anon_vma RCU freeing dance, after all.

But I guess you're right - although not because of the lock. You're right
because it would be a double-free - both parties would decide that they
can free the damn thing, because it's not a pure atomic refcount, it's a
"refcount or list_empty()" thing.

If _everybody_ was using the refcount, we could just do the
atomic_dec_and_test(). But they aren't. So yeah, I guess we do want that
nasty dec-and-lock version.


 \ /
  Last update: 2010-05-13 00:31    [W:0.046 / U:11.904 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site