All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, willy@infradead.org
Subject: Re: [PATCH 1/2] mm/migrate_device: further convert migrate_device_unmap() to folios
Date: Thu, 15 Feb 2024 09:38:42 +1100	[thread overview]
Message-ID: <877cj67jn3.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <20240214202055.77776-1-sidhartha.kumar@oracle.com>


Sidhartha Kumar <sidhartha.kumar@oracle.com> writes:

> migrate_device_unmap() already has a folio, we can use the folio
> versions of is_zone_device_page() and putback_lru_page.
>
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
>  mm/migrate_device.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index b6c27c76e1a0b..9152a329b0a68 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -377,33 +377,33 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns,
>  			continue;
>  		}
>  
> +		folio = page_folio(page);

Instead of open coding the migrate pfn to folio conversion I think we
should define a migrate_pfn_to_folio() and get rid of the intermediate
local variable. This would also allow a minor clean up to the final for
loop in migrate_device_unmap().

>  		/* ZONE_DEVICE pages are not on LRU */
> -		if (!is_zone_device_page(page)) {
> -			if (!PageLRU(page) && allow_drain) {
> +		if (!folio_is_zone_device(folio)) {
> +			if (!folio_test_lru(folio) && allow_drain) {
>  				/* Drain CPU's lru cache */
>  				lru_add_drain_all();
>  				allow_drain = false;
>  			}
>  
> -			if (!isolate_lru_page(page)) {
> +			if (!folio_isolate_lru(folio)) {
>  				src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
>  				restore++;
>  				continue;
>  			}
>  
>  			/* Drop the reference we took in collect */
> -			put_page(page);
> +			folio_put(folio);
>  		}
>  
> -		folio = page_folio(page);
>  		if (folio_mapped(folio))
>  			try_to_migrate(folio, 0);
>  
> -		if (page_mapped(page) ||
> +		if (folio_mapped(folio) ||
>  		    !migrate_vma_check_page(page, fault_page)) {
> -			if (!is_zone_device_page(page)) {
> -				get_page(page);
> -				putback_lru_page(page);
> +			if (!folio_is_zone_device(folio)) {
> +				folio_get(folio);
> +				folio_putback_lru(folio);
>  			}
>  
>  			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;



  parent reply	other threads:[~2024-02-14 22:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 20:20 [PATCH 1/2] mm/migrate_device: further convert migrate_device_unmap() to folios Sidhartha Kumar
2024-02-14 20:20 ` [PATCH 2/2] mm/migrate_device: further convert migrate_device_finalize() " Sidhartha Kumar
2024-02-14 22:45   ` Alistair Popple
2024-02-14 23:10     ` Sidhartha Kumar
2024-02-15  0:58       ` Alistair Popple
2024-02-14 22:38 ` Alistair Popple [this message]
2024-02-15  4:08   ` [PATCH 1/2] mm/migrate_device: further convert migrate_device_unmap() " Matthew Wilcox
2024-02-16  2:21     ` Alistair Popple

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cj67jn3.fsf@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.