From: Vernon Yang <yanglincheng@kylinos.cn>
When an mm with the MMF_DISABLE_THP_COMPLETELY flag is detected during
scanning, directly set khugepaged_scan.mm_slot to the next mm_slot,
reduce redundant operation.
Without this patch, entering khugepaged_scan_mm_slot() next time, we
will set khugepaged_scan.mm_slot to the next mm_slot.
With this patch, we will directly set khugepaged_scan.mm_slot to the
next mm_slot.
Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
---
mm/khugepaged.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index be1c09842ea2..1dc19c1b1f97 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2558,7 +2558,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_result
* Release the current mm_slot if this mm is about to die, or
* if we scanned all vmas of this mm.
*/
- if (hpage_collapse_test_exit(mm) || !vma) {
+ if (hpage_collapse_test_exit_or_disable(mm) || !vma) {
/*
* Make sure that if mm_users is reaching zero while
* khugepaged runs here, khugepaged_exit will find
--
2.51.0
On 23/01/26 1:52 pm, Vernon Yang wrote:
> From: Vernon Yang <yanglincheng@kylinos.cn>
>
> When an mm with the MMF_DISABLE_THP_COMPLETELY flag is detected during
> scanning, directly set khugepaged_scan.mm_slot to the next mm_slot,
> reduce redundant operation.
>
> Without this patch, entering khugepaged_scan_mm_slot() next time, we
> will set khugepaged_scan.mm_slot to the next mm_slot.
>
> With this patch, we will directly set khugepaged_scan.mm_slot to the
> next mm_slot.
>
> Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
> Reviewed-by: Lance Yang <lance.yang@linux.dev>
> ---
> mm/khugepaged.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index be1c09842ea2..1dc19c1b1f97 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2558,7 +2558,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_result
> * Release the current mm_slot if this mm is about to die, or
> * if we scanned all vmas of this mm.
> */
Need to update comment: "...or THP got disabled".
Reviewed-by: Dev Jain <dev.jain@arm.com>
> - if (hpage_collapse_test_exit(mm) || !vma) {
> + if (hpage_collapse_test_exit_or_disable(mm) || !vma) {
> /*
> * Make sure that if mm_users is reaching zero while
> * khugepaged runs here, khugepaged_exit will find
On Fri, Jan 23, 2026 at 8:40 PM Dev Jain <dev.jain@arm.com> wrote: > > > On 23/01/26 1:52 pm, Vernon Yang wrote: > > From: Vernon Yang <yanglincheng@kylinos.cn> > > > > When an mm with the MMF_DISABLE_THP_COMPLETELY flag is detected during > > scanning, directly set khugepaged_scan.mm_slot to the next mm_slot, > > reduce redundant operation. > > > > Without this patch, entering khugepaged_scan_mm_slot() next time, we > > will set khugepaged_scan.mm_slot to the next mm_slot. > > > > With this patch, we will directly set khugepaged_scan.mm_slot to the > > next mm_slot. > > > > Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn> > > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> > > Reviewed-by: Lance Yang <lance.yang@linux.dev> > > --- > > mm/khugepaged.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index be1c09842ea2..1dc19c1b1f97 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -2558,7 +2558,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_result > > * Release the current mm_slot if this mm is about to die, or > > * if we scanned all vmas of this mm. > > */ > > Need to update comment: "...or THP got disabled". > +1 With that, Reviewed-by: Barry Song <baohua@kernel.org>
On Fri, Jan 23, 2026 at 8:40 PM Dev Jain <dev.jain@arm.com> wrote:
>
> On 23/01/26 1:52 pm, Vernon Yang wrote:
> > From: Vernon Yang <yanglincheng@kylinos.cn>
> >
> > When an mm with the MMF_DISABLE_THP_COMPLETELY flag is detected during
> > scanning, directly set khugepaged_scan.mm_slot to the next mm_slot,
> > reduce redundant operation.
> >
> > Without this patch, entering khugepaged_scan_mm_slot() next time, we
> > will set khugepaged_scan.mm_slot to the next mm_slot.
> >
> > With this patch, we will directly set khugepaged_scan.mm_slot to the
> > next mm_slot.
> >
> > Signed-off-by: Vernon Yang <yanglincheng@kylinos.cn>
> > Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
> > Reviewed-by: Lance Yang <lance.yang@linux.dev>
> > ---
> > mm/khugepaged.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> > index be1c09842ea2..1dc19c1b1f97 100644
> > --- a/mm/khugepaged.c
> > +++ b/mm/khugepaged.c
> > @@ -2558,7 +2558,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, enum scan_result
> > * Release the current mm_slot if this mm is about to die, or
> > * if we scanned all vmas of this mm.
> > */
>
> Need to update comment: "...or THP got disabled".
LGTM, I will update comment in the next version. Thanks!
> Reviewed-by: Dev Jain <dev.jain@arm.com>
>
> > - if (hpage_collapse_test_exit(mm) || !vma) {
> > + if (hpage_collapse_test_exit_or_disable(mm) || !vma) {
> > /*
> > * Make sure that if mm_users is reaching zero while
> > * khugepaged runs here, khugepaged_exit will find
© 2016 - 2026 Red Hat, Inc.