diff mbox series

[3/6] mm: migrate: teach migrate_misplaced_page() about THP

Message ID 20210329183312.178266-4-shy828301@gmail.com (mailing list archive)
State New, archived
Headers show
Series mm: thp: use generic THP migration for NUMA hinting fault | expand

Commit Message

Yang Shi March 29, 2021, 6:33 p.m. UTC
In the following patch the migrate_misplaced_page() will be used to migrate THP
for NUMA faul too.  Prepare to deal with THP.

Signed-off-by: Yang Shi <shy828301@gmail.com>
---
 include/linux/migrate.h | 6 ++++--
 mm/memory.c             | 2 +-
 mm/migrate.c            | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

Comments

Huang, Ying March 30, 2021, 12:21 a.m. UTC | #1
Yang Shi <shy828301@gmail.com> writes:

> In the following patch the migrate_misplaced_page() will be used to migrate THP
> for NUMA faul too.  Prepare to deal with THP.
>
> Signed-off-by: Yang Shi <shy828301@gmail.com>
> ---
>  include/linux/migrate.h | 6 ++++--
>  mm/memory.c             | 2 +-
>  mm/migrate.c            | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> index 3a389633b68f..6abd34986cc5 100644
> --- a/include/linux/migrate.h
> +++ b/include/linux/migrate.h
> @@ -102,14 +102,16 @@ static inline void __ClearPageMovable(struct page *page)
>  #ifdef CONFIG_NUMA_BALANCING
>  extern bool pmd_trans_migrating(pmd_t pmd);
>  extern int migrate_misplaced_page(struct page *page,
> -				  struct vm_area_struct *vma, int node);
> +				  struct vm_area_struct *vma, int node,
> +				  bool compound);
>  #else
>  static inline bool pmd_trans_migrating(pmd_t pmd)
>  {
>  	return false;
>  }
>  static inline int migrate_misplaced_page(struct page *page,
> -					 struct vm_area_struct *vma, int node)
> +					 struct vm_area_struct *vma, int node,
> +					 bool compound)
>  {
>  	return -EAGAIN; /* can't migrate now */
>  }
> diff --git a/mm/memory.c b/mm/memory.c
> index 003bbf3187d4..7fed578bdc31 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4169,7 +4169,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
>  	}
>  
>  	/* Migrate to the requested node */
> -	migrated = migrate_misplaced_page(page, vma, target_nid);
> +	migrated = migrate_misplaced_page(page, vma, target_nid, false);
>  	if (migrated) {
>  		page_nid = target_nid;
>  		flags |= TNF_MIGRATED;
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 62b81d5257aa..9c4ae5132919 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2127,7 +2127,7 @@ static inline bool is_shared_exec_page(struct vm_area_struct *vma,
>   * the page that will be dropped by this function before returning.
>   */
>  int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
> -			   int node)
> +			   int node, bool compound)

Can we just use PageCompound(page) instead?

Best Regards,
Huang, Ying

>  {
>  	pg_data_t *pgdat = NODE_DATA(node);
>  	int isolated;
Yang Shi March 30, 2021, 4:57 p.m. UTC | #2
On Mon, Mar 29, 2021 at 5:21 PM Huang, Ying <ying.huang@intel.com> wrote:
>
> Yang Shi <shy828301@gmail.com> writes:
>
> > In the following patch the migrate_misplaced_page() will be used to migrate THP
> > for NUMA faul too.  Prepare to deal with THP.
> >
> > Signed-off-by: Yang Shi <shy828301@gmail.com>
> > ---
> >  include/linux/migrate.h | 6 ++++--
> >  mm/memory.c             | 2 +-
> >  mm/migrate.c            | 2 +-
> >  3 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/migrate.h b/include/linux/migrate.h
> > index 3a389633b68f..6abd34986cc5 100644
> > --- a/include/linux/migrate.h
> > +++ b/include/linux/migrate.h
> > @@ -102,14 +102,16 @@ static inline void __ClearPageMovable(struct page *page)
> >  #ifdef CONFIG_NUMA_BALANCING
> >  extern bool pmd_trans_migrating(pmd_t pmd);
> >  extern int migrate_misplaced_page(struct page *page,
> > -                               struct vm_area_struct *vma, int node);
> > +                               struct vm_area_struct *vma, int node,
> > +                               bool compound);
> >  #else
> >  static inline bool pmd_trans_migrating(pmd_t pmd)
> >  {
> >       return false;
> >  }
> >  static inline int migrate_misplaced_page(struct page *page,
> > -                                      struct vm_area_struct *vma, int node)
> > +                                      struct vm_area_struct *vma, int node,
> > +                                      bool compound)
> >  {
> >       return -EAGAIN; /* can't migrate now */
> >  }
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 003bbf3187d4..7fed578bdc31 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4169,7 +4169,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf)
> >       }
> >
> >       /* Migrate to the requested node */
> > -     migrated = migrate_misplaced_page(page, vma, target_nid);
> > +     migrated = migrate_misplaced_page(page, vma, target_nid, false);
> >       if (migrated) {
> >               page_nid = target_nid;
> >               flags |= TNF_MIGRATED;
> > diff --git a/mm/migrate.c b/mm/migrate.c
> > index 62b81d5257aa..9c4ae5132919 100644
> > --- a/mm/migrate.c
> > +++ b/mm/migrate.c
> > @@ -2127,7 +2127,7 @@ static inline bool is_shared_exec_page(struct vm_area_struct *vma,
> >   * the page that will be dropped by this function before returning.
> >   */
> >  int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
> > -                        int node)
> > +                        int node, bool compound)
>
> Can we just use PageCompound(page) instead?

Yes, I think so. The current base page NUMA hinting does bail out
early if PTE mapped THP is met. So the THP just could be PMD mapped as
long as it reaches here.

>
> Best Regards,
> Huang, Ying
>
> >  {
> >       pg_data_t *pgdat = NODE_DATA(node);
> >       int isolated;
>
diff mbox series

Patch

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 3a389633b68f..6abd34986cc5 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -102,14 +102,16 @@  static inline void __ClearPageMovable(struct page *page)
 #ifdef CONFIG_NUMA_BALANCING
 extern bool pmd_trans_migrating(pmd_t pmd);
 extern int migrate_misplaced_page(struct page *page,
-				  struct vm_area_struct *vma, int node);
+				  struct vm_area_struct *vma, int node,
+				  bool compound);
 #else
 static inline bool pmd_trans_migrating(pmd_t pmd)
 {
 	return false;
 }
 static inline int migrate_misplaced_page(struct page *page,
-					 struct vm_area_struct *vma, int node)
+					 struct vm_area_struct *vma, int node,
+					 bool compound)
 {
 	return -EAGAIN; /* can't migrate now */
 }
diff --git a/mm/memory.c b/mm/memory.c
index 003bbf3187d4..7fed578bdc31 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4169,7 +4169,7 @@  static vm_fault_t do_numa_page(struct vm_fault *vmf)
 	}
 
 	/* Migrate to the requested node */
-	migrated = migrate_misplaced_page(page, vma, target_nid);
+	migrated = migrate_misplaced_page(page, vma, target_nid, false);
 	if (migrated) {
 		page_nid = target_nid;
 		flags |= TNF_MIGRATED;
diff --git a/mm/migrate.c b/mm/migrate.c
index 62b81d5257aa..9c4ae5132919 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2127,7 +2127,7 @@  static inline bool is_shared_exec_page(struct vm_area_struct *vma,
  * the page that will be dropped by this function before returning.
  */
 int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
-			   int node)
+			   int node, bool compound)
 {
 	pg_data_t *pgdat = NODE_DATA(node);
 	int isolated;