2020-11-05 20:57:30

by Yang Shi

[permalink] [raw]
Subject: [PATCH 0/5] mm: misc migrate cleanup and improvement


Some misc migrate code cleanup and improvement.

Yang Shi (5):
mm: truncate_complete_page is not existed anymore
mm: migrate: simplify the logic for handling permanent failure
mm: migrate: skip shared exec THP for NUMA balancing
mm: migrate: clean up migrate_prep{_local}
mm: migrate: return -ENOSYS if THP migration is unsupported

include/linux/migrate.h | 4 +--
mm/mempolicy.c | 8 ++----
mm/migrate.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
mm/vmscan.c | 2 +-
4 files changed, 99 insertions(+), 63 deletions(-)


2020-11-05 20:57:37

by Yang Shi

[permalink] [raw]
Subject: [PATCH 4/5] mm: migrate: clean up migrate_prep{_local}

The migrate_prep{_local} never fails, so it is pointless to have return
value and check the return value.

Signed-off-by: Yang Shi <[email protected]>
---
include/linux/migrate.h | 4 ++--
mm/mempolicy.c | 8 ++------
mm/migrate.c | 8 ++------
3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 0f8d1583fa8e..4594838a0f7c 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -45,8 +45,8 @@ extern struct page *alloc_migration_target(struct page *page, unsigned long priv
extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
extern void putback_movable_page(struct page *page);

-extern int migrate_prep(void);
-extern int migrate_prep_local(void);
+extern void migrate_prep(void);
+extern void migrate_prep_local(void);
extern void migrate_page_states(struct page *newpage, struct page *page);
extern void migrate_page_copy(struct page *newpage, struct page *page);
extern int migrate_huge_page_move_mapping(struct address_space *mapping,
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 3fde772ef5ef..780861312008 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1114,9 +1114,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
int err;
nodemask_t tmp;

- err = migrate_prep();
- if (err)
- return err;
+ migrate_prep();

mmap_read_lock(mm);

@@ -1315,9 +1313,7 @@ static long do_mbind(unsigned long start, unsigned long len,

if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {

- err = migrate_prep();
- if (err)
- goto mpol_out;
+ migrate_prep();
}
{
NODEMASK_SCRATCH(scratch);
diff --git a/mm/migrate.c b/mm/migrate.c
index 9a32bb128f31..8f6a61c9274b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -62,7 +62,7 @@
* to be migrated using isolate_lru_page(). If scheduling work on other CPUs is
* undesirable, use migrate_prep_local()
*/
-int migrate_prep(void)
+void migrate_prep(void)
{
/*
* Clear the LRU lists so pages can be isolated.
@@ -71,16 +71,12 @@ int migrate_prep(void)
* pages that may be busy.
*/
lru_add_drain_all();
-
- return 0;
}

/* Do the necessary work of migrate_prep but not if it involves other CPUs */
-int migrate_prep_local(void)
+void migrate_prep_local(void)
{
lru_add_drain();
-
- return 0;
}

int isolate_movable_page(struct page *page, isolate_mode_t mode)
--
2.26.2

2020-11-05 20:58:06

by Yang Shi

[permalink] [raw]
Subject: [PATCH 1/5] mm: truncate_complete_page is not existed anymore

The commit 9f4e41f4717832e34cca153ced62b4a1d7e26c0e ("mm: refactor
truncate_complete_page()") refactored truncate_complete_page(), and it
is not existed anymore, correct the comment in vmscan and migrate to avoid
confusion.

Signed-off-by: Yang Shi <[email protected]>
---
mm/migrate.c | 2 +-
mm/vmscan.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 5ca5842df5db..8a2e7e19e27b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1106,7 +1106,7 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
* and treated as swapcache but it has no rmap yet.
* Calling try_to_unmap() against a page->mapping==NULL page will
* trigger a BUG. So handle it here.
- * 2. An orphaned page (see truncate_complete_page) might have
+ * 2. An orphaned page (see truncate_cleanup_page) might have
* fs-private metadata. The page can be picked up due to memory
* offlining. Everywhere else except page reclaim, the page is
* invisible to the vm, so the page can not be migrated. So try to
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 1b8f0e059767..165cca87edc8 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1393,7 +1393,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
*
* Rarely, pages can have buffers and no ->mapping. These are
* the pages which were not successfully invalidated in
- * truncate_complete_page(). We try to drop those buffers here
+ * truncate_cleanup_page(). We try to drop those buffers here
* and if that worked, and the page is no longer mapped into
* process address space (page_count == 1) it can be freed.
* Otherwise, leave the page on the LRU so it is swappable.
--
2.26.2

2020-11-06 09:17:55

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/5] mm: truncate_complete_page is not existed anymore

On Tue 03-11-20 05:03:30, Yang Shi wrote:
> The commit 9f4e41f4717832e34cca153ced62b4a1d7e26c0e ("mm: refactor
> truncate_complete_page()") refactored truncate_complete_page(), and it
> is not existed anymore, correct the comment in vmscan and migrate to avoid
> confusion.
>
> Signed-off-by: Yang Shi <[email protected]>

Thanks! Looks good to me. You can add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> mm/migrate.c | 2 +-
> mm/vmscan.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 5ca5842df5db..8a2e7e19e27b 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1106,7 +1106,7 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
> * and treated as swapcache but it has no rmap yet.
> * Calling try_to_unmap() against a page->mapping==NULL page will
> * trigger a BUG. So handle it here.
> - * 2. An orphaned page (see truncate_complete_page) might have
> + * 2. An orphaned page (see truncate_cleanup_page) might have
> * fs-private metadata. The page can be picked up due to memory
> * offlining. Everywhere else except page reclaim, the page is
> * invisible to the vm, so the page can not be migrated. So try to
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 1b8f0e059767..165cca87edc8 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1393,7 +1393,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
> *
> * Rarely, pages can have buffers and no ->mapping. These are
> * the pages which were not successfully invalidated in
> - * truncate_complete_page(). We try to drop those buffers here
> + * truncate_cleanup_page(). We try to drop those buffers here
> * and if that worked, and the page is no longer mapped into
> * process address space (page_count == 1) it can be freed.
> * Otherwise, leave the page on the LRU so it is swappable.
> --
> 2.26.2
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2020-11-06 20:10:49

by Zi Yan

[permalink] [raw]
Subject: Re: [PATCH 4/5] mm: migrate: clean up migrate_prep{_local}

On 3 Nov 2020, at 8:03, Yang Shi wrote:

> The migrate_prep{_local} never fails, so it is pointless to have return
> value and check the return value.
>
> Signed-off-by: Yang Shi <[email protected]>
> ---
> include/linux/migrate.h | 4 ++--
> mm/mempolicy.c | 8 ++------
> mm/migrate.c | 8 ++------
> 3 files changed, 6 insertions(+), 14 deletions(-)
>

LGTM. Thanks. Reviewed-by: Zi Yan <[email protected]>



Best Regards,
Yan Zi


Attachments:
signature.asc (871.00 B)
OpenPGP digital signature