Re: [PATCH -mm] mm: hugetlbfs: Correctly populate shared pmd

From: Rik van Riel
Date: Thu Aug 02 2012 - 10:42:39 EST


On 08/02/2012 10:16 AM, Michal Hocko wrote:
Hi Andrew,
the following patch fixes yet-another race in the hugetlb pte sharing
code reported by Larry. It is based on top of the current -mm tree but
it cleanly applies to linus tree as well. It should go to stable as
well. The bug is there for ages but this fix is possible only since 3.0
because i_mmap_lock used to be a spinlock until 3d48ae45 which turned it
into mutex and so we can call pmd_alloc.

This patch addresses the issue by moving pmd_alloc into huge_pmd_share
which guarantees that the shared pud is populated in the same
critical section as pmd. This also means that huge_pte_offset test in
huge_pmd_share is serialized correctly now which in turn means that
the success of the sharing will be higher as the racing tasks see the
pud and pmd populated together.

Race identified and changelog written mostly by Mel Gorman
Reported-and-tested-by: Larry Woodman <lwoodman@xxxxxxxxxx>
Reviewed-by: Mel Gorman <mgorman@xxxxxxx>
Signed-off-by: Michal Hocko <mhocko@xxxxxxx>

Reviewed-by: Rik van Riel <riel@xxxxxxxxxx>


--
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/