linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mm/hugetlb: Restore the reservation
@ 2024-02-05 19:18 Breno Leitao
  2024-02-05 19:18 ` [PATCH v2 1/2] mm/hugetlb: Restore the reservation if needed Breno Leitao
  2024-02-05 19:18 ` [PATCH v2 2/2] selftests/mm: run_vmtests.sh: add hugetlb_madv_vs_map Breno Leitao
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-02-05 19:18 UTC (permalink / raw)
  To: mike.kravetz, linux-mm, akpm, muchun.song
  Cc: lstoakes, willy, hannes, mhocko, roman.gushchin, linux-kernel

This is a fix for a case where a backing huge page could stolen after
madvise(MADV_DONTNEED).

A full reproducer is in selftest. See
https://lore.kernel.org/all/20240105155419.1939484-1-leitao@debian.org/

v1:
  * https://lore.kernel.org/all/20240117171058.2192286-1-leitao@debian.org/
v2:
  * In version 1, there was a lockdep dependency detected by syzbot.
	* https://lore.kernel.org/all/00000000000050a2fb060fdc478c@google.com/
	* The lockdep dependency was caused because `vma_add_reservation()` was
	  called with the pte lock. This is fixed now by deferring the
	  vma_add_reservation() to after the spinlock.
  * Version 2 fixes the problem above by setting the restore_reserve bit
    inside the ptl, but, calling vma_add_reservation() later, after the
    lock is released.
	* Reported by a test done by Ryan Roberts.

In order to test this patch, I instrumented the kernel with LOCKDEP and
KASAN, and run the following tests, without any regression:
  * The self test that reproduces the problem
  * All mm hugetlb selftests
	SUMMARY: PASS=9 SKIP=0 FAIL=0
  * All libhugetlbfs tests
	PASS:     0     86
	FAIL:     0      0

Breno Leitao (2):
  mm/hugetlb: Restore the reservation if needed
  selftests/mm: run_vmtests.sh: add hugetlb_madv_vs_map

 mm/hugetlb.c                              | 25 +++++++++++++++++++++++
 tools/testing/selftests/mm/run_vmtests.sh |  1 +
 2 files changed, 26 insertions(+)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-05 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 19:18 [PATCH v2 0/2] mm/hugetlb: Restore the reservation Breno Leitao
2024-02-05 19:18 ` [PATCH v2 1/2] mm/hugetlb: Restore the reservation if needed Breno Leitao
2024-02-05 19:18 ` [PATCH v2 2/2] selftests/mm: run_vmtests.sh: add hugetlb_madv_vs_map Breno Leitao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox