summaryrefslogtreecommitdiffstats
path: root/mm/khugepaged.c
diff options
context:
space:
mode:
authorYang Shi <shy828301@gmail.com>2022-06-16 10:48:36 -0700
committerakpm <akpm@linux-foundation.org>2022-07-17 17:14:32 -0700
commitf707fa493784b515ced01d4e261afe16fc784b5d (patch)
treec036943c7d9f40adefdd2bb24b766a08d1190884 /mm/khugepaged.c
parent4fa6893faeaaea4fe4440512d2a708527ef47051 (diff)
downloadlinux-f707fa493784b515ced01d4e261afe16fc784b5d.tar.bz2
mm: khugepaged: better comments for anon vma check in hugepage_vma_revalidate
The hugepage_vma_revalidate() needs to check if the vma is still anonymous vma or not since the address may be unmapped then remapped to file before khugepaged reaquired the mmap_lock. The old comment is not quite helpful, elaborate this with better comment. Link: https://lkml.kernel.org/r/20220616174840.1202070-4-shy828301@gmail.com Signed-off-by: Yang Shi <shy828301@gmail.com> Reviewed-by: Zach O'Keefe <zokeefe@google.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Miaohe Lin <linmiaohe@huawei.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/khugepaged.c')
-rw-r--r--mm/khugepaged.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index c7e22135f1b5..67e144e64b7f 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -958,7 +958,13 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address,
return SCAN_ADDRESS_RANGE;
if (!hugepage_vma_check(vma, vma->vm_flags))
return SCAN_VMA_CHECK;
- /* Anon VMA expected */
+ /*
+ * Anon VMA expected, the address may be unmapped then
+ * remapped to file after khugepaged reaquired the mmap_lock.
+ *
+ * hugepage_vma_check may return true for qualified file
+ * vmas.
+ */
if (!vma->anon_vma || !vma_is_anonymous(vma))
return SCAN_VMA_CHECK;
return 0;