Re: [PATCH 1/2] mm,migration: Prevent rmap_walk_[anon|ksm] seeingthe wrong VMA information

From: Linus Torvalds
Date: Thu May 06 2010 - 10:08:51 EST




On Thu, 6 May 2010, Minchan Kim wrote:
> > + Â Â Â Â*/
> > + Â Â Â avc = list_first_entry(&anon_vma->head, struct anon_vma_chain, same_anon_vma);
>
> Dumb question.
>
> I can't understand why we should use list_first_entry.

It's not that we "should" use list_entry_first. It's that we want to find
_any_ entry on the list, and the most natural one is the first one.

So we could take absolutely any 'avc' entry that is reachable from the
anon_vma, and use that to look up _any_ 'vma' that is associated with that
anon_vma. And then, from _any_ of those vma's, we know how to get to the
"root anon_vma" - the one that they are all associated with.

So no, there's absolutely nothing special about the first entry. It's
just a random easily found one.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/