Skip to contentSkip to conversation

+ mm-hugetlb-fix-race-in-region-tracking.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Jan 31, 2014

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + mm-hugetlb-fix-race-in-region-tracking.patch added to -mm tree
To: [email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 31 Jan 2014 13:08:41 -0800

The patch titled
Subject: mm, hugetlb: fix race in region tracking
has been added to the -mm tree. Its filename is
mm-hugetlb-fix-race-in-region-tracking.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-hugetlb-fix-race-in-region-tracking.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-hugetlb-fix-race-in-region-tracking.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Davidlohr Bueso <[email protected]>
Subject: mm, hugetlb: fix race in region tracking

There is a race condition if we map the same file on different processes. Region tracking is protected by mmap_sem and hugetlb_instantiation_mutex. When we do mmap, we don't grab hugetlb_instantiation_mutex, but only the mmap_sem (exclusively). This doesn't prevent other tasks from modifying the region structure, so it can be modified by two processes concurrently.

To solve this, introduce a spinlock to resv_map and make region manipulation function grab it before they do actual work.

---

 include/linux/hugetlb.h |    1 
 mm/hugetlb.c            |   58 ++++++++++++++++++++++++--------------
 2 files changed, 39 insertions(+), 20 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-hugetlb-fix-race-in-region-tracking +1 -0
diff -puN include/linux/hugetlb.h~mm-hugetlb-fix-race-in-region-tracking include/linux/hugetlb.h
@@ -27,6 +27,7 @@ struct hugepage_subpool {
 
 struct resv_map {
 	struct kref refs;
+	spinlock_t lock;
 	struct list_head regions;
 };
 extern struct resv_map *resv_map_alloc(void);
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-fix-race-in-region-tracking +38 -20

138 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

origin.patch mm-hugetlb-unify-region-structure-handling.patch mm-hugetlb-improve-cleanup-resv_map-parameters.patch mm-hugetlb-fix-race-in-region-tracking.patch mm-hugetlb-remove-resv_map_put.patch mm-hugetlb-use-vma_resv_map-map-types.patch mm-hugetlb-improve-page-fault-scalability.patch mm-hugetlb-improve-page-fault-scalability-fix.patch linux-next.patch