Re: [PATCH 3/4] hugetlb, rmap: fix confusing page locking inhugetlb_cow()

From: Linus Torvalds
Date: Fri Sep 10 2010 - 13:16:05 EST




On Fri, 10 Sep 2010, Naoya Horiguchi wrote:
>
> - if (!pagecache_page) {
> - page = pte_page(entry);
> + /*
> + * hugetlb_cow() requires page locks of pte_page(entry) and
> + * pagecache_page, so here we need take the former one
> + * when page != pagecache_page or !pagecache_page.
> + */
> + page = pte_page(entry);
> + if (page != pagecache_page)
> lock_page(page);

Why isn't this a potential deadlock? You have two pages, and lock them
both. Is there some ordering guarantee that says that 'pagecache_page' and
'page' will always be in a certain relationship so that you cannot get
A->B and B->A lock ordering?

Please document that ordering rule if so.

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/