[PATCH mm-unstable] mm/khugepaged: don't check pmd value twice in collapse_pte_mapped_thp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the v3 -> v4 merge of series "mm: add file/shmem support to
MADV_COLLAPSE", a line deletion was accidentally dropped, which left
collapse_pte_mapped_thp() in state:

---8<---
	<mmap_lock held exclusively>

	result = find_pmd_or_thp_or_none(mm, haddr, &pmd);

	<other checks that don't change "result" unless fail>

(*)	if (find_pmd_or_thp_or_none(mm, haddr, &pmd) != SCAN_SUCCEED)
	result = find_pmd_or_thp_or_none(mm, haddr, &pmd);

	switch (result) {
		case SCAN_SUCCEED:
---8<---

Where (*) is the line that should have been deleted (note that this is
still legal C).  Since the selftests are still passing, this mistake
highlights the fact that the second (intended) find_pmd_or_thp_or_none()
isn't necessary: the first one is called with mmap_lock held
exclusively, we don't drop the lock in this function, and "result" isn't
changed between assignment and use in the switch-statement (except for
failure paths which either return early or skip to "drop_hpage" label).

Remove the second (intended) find_pmd_or_thp_or_none() check, and the
misplaced find_pmd_or_thp_or_none() if-statement line.

Fixes: c27451af51cc ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx>
---

Andrew, apologies about letting this sneak through (both the needless check,
and the trivial merge error).  Please consider taking into mm-unstable to
clean things up there.  Will try to catch these better in the future. Thank you.

 mm/khugepaged.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 6d2dfd96608a..c7699fabf302 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1463,8 +1463,6 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
 		goto drop_hpage;
 	}
 
-	if (find_pmd_or_thp_or_none(mm, haddr, &pmd) != SCAN_SUCCEED)
-	result = find_pmd_or_thp_or_none(mm, haddr, &pmd);
 	switch (result) {
 	case SCAN_SUCCEED:
 		break;
-- 
2.37.3.998.g577e59143f-goog





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux