2021-04-07 17:07:52

by Xu, Yanfei

[permalink] [raw]
Subject: [PATCH v2 0/2] mm: khugepaged: cleanup and a minor tuning in THP

From: Yanfei Xu <[email protected]>

v1-->v2:
1.correct the wrong location where the goto jump to.
2.keep the cond_resched() dropped in v1 still there.

Thanks for Yang's review.

Yanfei Xu (2):
mm: khugepaged: use macro to align addresses
mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas

mm/khugepaged.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)

--
2.27.0


2021-04-07 17:42:07

by Xu, Yanfei

[permalink] [raw]
Subject: [PATCH v2 2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas

From: Yanfei Xu <[email protected]>

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 <[email protected]>
---
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

2021-04-07 22:08:44

by Yang Shi

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas

On Tue, Apr 6, 2021 at 8:06 PM <[email protected]> wrote:
>
> From: Yanfei Xu <[email protected]>
>
> 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 <[email protected]>

>
> Signed-off-by: Yanfei Xu <[email protected]>
> ---
> 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
>

2021-04-14 11:53:42

by Xu, Yanfei

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] mm: khugepaged: cleanup and a minor tuning in THP

Gentle ping.

On 4/7/21 11:05 AM, [email protected] wrote:
> From: Yanfei Xu <[email protected]>
>
> v1-->v2:
> 1.correct the wrong location where the goto jump to.
> 2.keep the cond_resched() dropped in v1 still there.
>
> Thanks for Yang's review.
>
> Yanfei Xu (2):
> mm: khugepaged: use macro to align addresses
> mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas
>
> mm/khugepaged.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>