diff mbox series

[v2,2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas

Message ID 20210407030548.189104-3-yanfei.xu@windriver.com (mailing list archive)
State New, archived
Headers show
Series mm: khugepaged: cleanup and a minor tuning in THP | expand

Commit Message

Xu, Yanfei April 7, 2021, 3:05 a.m. UTC
From: Yanfei Xu <yanfei.xu@windriver.com>

We could check MMF_DISABLE_THP ahead of iterating over all of vma.
Otherwise if some mm_struct contain a large number of vma, there will
be amounts meaningless cpu cycles cost.

Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
---
 mm/khugepaged.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Yang Shi April 7, 2021, 9:40 p.m. UTC | #1
On Tue, Apr 6, 2021 at 8:06 PM <yanfei.xu@windriver.com> wrote:
>
> From: Yanfei Xu <yanfei.xu@windriver.com>
>
> We could check MMF_DISABLE_THP ahead of iterating over all of vma.
> Otherwise if some mm_struct contain a large number of vma, there will
> be amounts meaningless cpu cycles cost.

Reviewed-by: Yang Shi <shy828301@gmail.com>

>
> Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
> ---
>  mm/khugepaged.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index a6012b9259a2..f4ad25a7db55 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2094,6 +2094,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
>          */
>         if (unlikely(!mmap_read_trylock(mm)))
>                 goto breakouterloop_mmap_lock;
> +       if (test_bit(MMF_DISABLE_THP, &mm->flags))
> +               goto breakouterloop;
>         if (likely(!khugepaged_test_exit(mm)))
>                 vma = find_vma(mm, khugepaged_scan.address);
>
> --
> 2.27.0
>
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index a6012b9259a2..f4ad25a7db55 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2094,6 +2094,8 @@  static unsigned int khugepaged_scan_mm_slot(unsigned int pages,
 	 */
 	if (unlikely(!mmap_read_trylock(mm)))
 		goto breakouterloop_mmap_lock;
+	if (test_bit(MMF_DISABLE_THP, &mm->flags))
+		goto breakouterloop;
 	if (likely(!khugepaged_test_exit(mm)))
 		vma = find_vma(mm, khugepaged_scan.address);