diff mbox series

[4/4] mm/rmap: try_to_migrate() skip zone_device !device_private

Message ID 1241d356-8ec9-f47b-a5ec-9b2bf66d242@google.com (mailing list archive)
State New
Headers show
Series [1/4] mm/rmap: fix comments left over from recent changes | expand

Commit Message

Hugh Dickins July 7, 2021, 8:13 p.m. UTC
I know nothing about zone_device pages and !device_private pages; but
if try_to_migrate_one() will do nothing for them, then it's better that
try_to_migrate() filter them first, than trawl through all their vmas.

Signed-off-by: Hugh Dickins <hughd@google.com>
---
 mm/rmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Shakeel Butt July 7, 2021, 8:54 p.m. UTC | #1
On Wed, Jul 7, 2021 at 1:13 PM Hugh Dickins <hughd@google.com> wrote:
>
> I know nothing about zone_device pages and !device_private pages; but
> if try_to_migrate_one() will do nothing for them, then it's better that
> try_to_migrate() filter them first, than trawl through all their vmas.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>
Alistair Popple July 7, 2021, 11:25 p.m. UTC | #2
I know a bit about device private pages but not so much other variants.
try_to_migrate_one() will work with private pages so in general that check
still looks good.

Reviewed-by: Alistair Popple <apopple@nvidia.com>

On Thursday, 8 July 2021 6:13:33 AM AEST Hugh Dickins wrote:
> I know nothing about zone_device pages and !device_private pages; but
> if try_to_migrate_one() will do nothing for them, then it's better that
> try_to_migrate() filter them first, than trawl through all their vmas.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>  mm/rmap.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 1235368f0628..795f9d5f8386 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1703,9 +1703,6 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma,
>  	struct mmu_notifier_range range;
>  	enum ttu_flags flags = (enum ttu_flags)(long)arg;
>  
> -	if (is_zone_device_page(page) && !is_device_private_page(page))
> -		return true;
> -
>  	/*
>  	 * When racing against e.g. zap_pte_range() on another cpu,
>  	 * in between its ptep_get_and_clear_full() and page_remove_rmap(),
> @@ -1944,6 +1941,9 @@ void try_to_migrate(struct page *page, enum ttu_flags flags)
>  					TTU_SYNC)))
>  		return;
>  
> +	if (is_zone_device_page(page) && !is_device_private_page(page))
> +		return;
> +
>  	/*
>  	 * During exec, a temporary VMA is setup and later moved.
>  	 * The VMA is moved under the anon_vma lock but not the
>
diff mbox series

Patch

diff --git a/mm/rmap.c b/mm/rmap.c
index 1235368f0628..795f9d5f8386 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1703,9 +1703,6 @@  static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma,
 	struct mmu_notifier_range range;
 	enum ttu_flags flags = (enum ttu_flags)(long)arg;
 
-	if (is_zone_device_page(page) && !is_device_private_page(page))
-		return true;
-
 	/*
 	 * When racing against e.g. zap_pte_range() on another cpu,
 	 * in between its ptep_get_and_clear_full() and page_remove_rmap(),
@@ -1944,6 +1941,9 @@  void try_to_migrate(struct page *page, enum ttu_flags flags)
 					TTU_SYNC)))
 		return;
 
+	if (is_zone_device_page(page) && !is_device_private_page(page))
+		return;
+
 	/*
 	 * During exec, a temporary VMA is setup and later moved.
 	 * The VMA is moved under the anon_vma lock but not the