diff mbox series

[RFC,RESEND,08/28] mm/khugepaged: mark VMA as locked while collapsing a hugepage

Message ID 20220901173516.702122-9-surenb@google.com (mailing list archive)
State New
Headers show
Series per-VMA locks proposal | expand

Commit Message

Suren Baghdasaryan Sept. 1, 2022, 5:34 p.m. UTC
Protect VMA from concurrent page fault handler while modifying it in
collapse_huge_page.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
 mm/khugepaged.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Dufour Sept. 6, 2022, 2:43 p.m. UTC | #1
Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit :
> Protect VMA from concurrent page fault handler while modifying it in
> collapse_huge_page.

Is the goal to protect changes in the anon_vma structure?

AFAICS, the vma it self is not impacted here, only the anon_vma and the
PMD/PTE are touched, and they have their own protection mechanism, isn't it?

> 
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
>  mm/khugepaged.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 01f71786d530..030680633989 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1072,6 +1072,7 @@ static void collapse_huge_page(struct mm_struct *mm,
>  	if (mm_find_pmd(mm, address) != pmd)
>  		goto out_up_write;
>  
> +	vma_mark_locked(vma);
>  	anon_vma_lock_write(vma->anon_vma);
>  
>  	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm,
Suren Baghdasaryan Sept. 9, 2022, 12:15 a.m. UTC | #2
On Tue, Sep 6, 2022 at 7:43 AM Laurent Dufour <ldufour@linux.ibm.com> wrote:
>
> Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit :
> > Protect VMA from concurrent page fault handler while modifying it in
> > collapse_huge_page.
>
> Is the goal to protect changes in the anon_vma structure?
>
> AFAICS, the vma it self is not impacted here, only the anon_vma and the
> PMD/PTE are touched, and they have their own protection mechanism, isn't it?

Yes, I think you are right about not needing to lock VMA here as all
modified components are already protected. Thanks!

>
> >
> > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > ---
> >  mm/khugepaged.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index 01f71786d530..030680633989 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -1072,6 +1072,7 @@ static void collapse_huge_page(struct mm_struct *mm,
> >       if (mm_find_pmd(mm, address) != pmd)
> >               goto out_up_write;
> >
> > +     vma_mark_locked(vma);
> >       anon_vma_lock_write(vma->anon_vma);
> >
> >       mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm,
>
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 01f71786d530..030680633989 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1072,6 +1072,7 @@  static void collapse_huge_page(struct mm_struct *mm,
 	if (mm_find_pmd(mm, address) != pmd)
 		goto out_up_write;
 
+	vma_mark_locked(vma);
 	anon_vma_lock_write(vma->anon_vma);
 
 	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm,