diff mbox series

[12/27] mm: refactor the ZONE_DEVICE handling in migrate_vma_pages

Message ID 20220210072828.2930359-13-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/27] mm: remove a pointless CONFIG_ZONE_DEVICE check in memremap_pages | expand

Commit Message

Christoph Hellwig Feb. 10, 2022, 7:28 a.m. UTC
Make the flow a little more clear and prepare for adding a new
ZONE_DEVICE memory type.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 mm/migrate.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

Comments

Alistair Popple Feb. 10, 2022, 10:46 a.m. UTC | #1
Reviewed-by: Alistair Popple <apopple@nvidia.com>

On Thursday, 10 February 2022 6:28:13 PM AEDT Christoph Hellwig wrote:
> Make the flow a little more clear and prepare for adding a new
> ZONE_DEVICE memory type.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  mm/migrate.c | 27 ++++++++++++---------------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 30ecd7223656c1..746e1230886ddb 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2788,24 +2788,21 @@ void migrate_vma_pages(struct migrate_vma *migrate)
>  
>  		mapping = page_mapping(page);
>  
> -		if (is_zone_device_page(newpage)) {
> -			if (is_device_private_page(newpage)) {
> -				/*
> -				 * For now only support private anonymous when
> -				 * migrating to un-addressable device memory.
> -				 */
> -				if (mapping) {
> -					migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
> -					continue;
> -				}
> -			} else {
> -				/*
> -				 * Other types of ZONE_DEVICE page are not
> -				 * supported.
> -				 */
> +		if (is_device_private_page(newpage)) {
> +			/*
> +			 * For now only support private anonymous when migrating
> +			 * to un-addressable device memory.
> +			 */
> +			if (mapping) {
>  				migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
>  				continue;
>  			}
> +		} else if (is_zone_device_page(newpage)) {
> +			/*
> +			 * Other types of ZONE_DEVICE page are not supported.
> +			 */
> +			migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
> +			continue;
>  		}
>  
>  		r = migrate_page(mapping, newpage, page, MIGRATE_SYNC_NO_COPY);
>
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index 30ecd7223656c1..746e1230886ddb 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2788,24 +2788,21 @@  void migrate_vma_pages(struct migrate_vma *migrate)
 
 		mapping = page_mapping(page);
 
-		if (is_zone_device_page(newpage)) {
-			if (is_device_private_page(newpage)) {
-				/*
-				 * For now only support private anonymous when
-				 * migrating to un-addressable device memory.
-				 */
-				if (mapping) {
-					migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
-					continue;
-				}
-			} else {
-				/*
-				 * Other types of ZONE_DEVICE page are not
-				 * supported.
-				 */
+		if (is_device_private_page(newpage)) {
+			/*
+			 * For now only support private anonymous when migrating
+			 * to un-addressable device memory.
+			 */
+			if (mapping) {
 				migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
 				continue;
 			}
+		} else if (is_zone_device_page(newpage)) {
+			/*
+			 * Other types of ZONE_DEVICE page are not supported.
+			 */
+			migrate->src[i] &= ~MIGRATE_PFN_MIGRATE;
+			continue;
 		}
 
 		r = migrate_page(mapping, newpage, page, MIGRATE_SYNC_NO_COPY);