* [PATCH mm-unstable] mm/khugepaged: don't check pmd value twice in collapse_pte_mapped_thp()
@ 2022-09-27 3:38 Zach O'Keefe
0 siblings, 0 replies; only message in thread
From: Zach O'Keefe @ 2022-09-27 3:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Yang Shi
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@google.com>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-27 3:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 3:38 [PATCH mm-unstable] mm/khugepaged: don't check pmd value twice in collapse_pte_mapped_thp() Zach O'Keefe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).