mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy.patch removed from -mm tree
The patch titled
Subject: mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY
has been removed from the -mm tree. Its filename was
mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Mina Almasry <[email protected]>
Subject: mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY
On UFFDIO_COPY, if we fail to copy the page contents while holding the hugetlb_fault_mutex, we will drop the mutex and return to the caller after allocating a page that consumed a reservation. In this case there may be a fault that double consumes the reservation. To handle this, we free the allocated page, fix the reservations, and allocate a temporary hugetlb page and return that to the caller. When the caller does the copy outside of the lock, we again check the cache, and allocate a page consuming the reservation, and copy over the contents.
Test:
Hacked the code locally such that resv_huge_pages underflows produce a warning and the copy_huge_page_from_user() always fails, then:
./tools/testing/selftests/vm/userfaultfd hugetlb_shared 10
2 /tmp/kokonut_test/huge/userfaultfd_test && echo test success ./tools/testing/selftests/vm/userfaultfd hugetlb 10 2 /tmp/kokonut_test/huge/userfaultfd_test && echo test success
Both tests succeed and produce no warnings. After the test runs number of free/resv hugepages is correct.
---
include/linux/migrate.h | 4 +++ mm/hugetlb.c | 48 +++++++++++++++++++++++++++++------- mm/migrate.c | 2 - mm/userfaultfd.c | 50 -------------------------------------- 4 files changed, 45 insertions(+), 59 deletions(-)
include/linux/migrate.h renamed from include/linux/migrate.h~mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy +4 -0
@@ -51,6 +51,7 @@ extern int migrate_huge_page_move_mappin struct page *newpage, struct page *page);extern int migrate_page_move_mapping (struct address_space *mapping,struct page *newpage,struct page *page,int extra_count); +extern void copy_huge_page (struct page *dst,struct page *src);#else static inline void putback_movable_pages (struct list_head *l) {}
@@ -77,6 +78,9 @@ static inline int migrate_huge_page_move return -ENOSYS; } +static inline void copy_huge_page (struct page *dst,struct page *src) +{ +}#endif /* CONFIG_MIGRATION */ #ifdef CONFIG_COMPACTION
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy +39 -9
77 lines not on this page · raw message
mm/migrate.c renamed from mm/migrate.c~mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy +1 -1
@@ -553,7 +553,7 @@ static void __copy_gigantic_page(struct } } -static void copy_huge_page (struct page *dst,struct page *src) +void copy_huge_page (struct page *dst,struct page *src) {int i;int nr_pages;
mm/userfaultfd.c renamed from mm/userfaultfd.c~mm-hugetlb-fix-racy-resv_huge_pages-underflow-on-uffdio_copy +1 -49
69 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are