linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Zi Yan <ziy@nvidia.com>, Jonathan Corbet <corbet@lwn.net>,
	linux-mm@kvack.org
Subject: Re: [PATCH 4/6] mm: migrate_device: use more folio in migrate_device_finalize()
Date: Tue, 27 Aug 2024 15:48:12 +1000	[thread overview]
Message-ID: <8734mqjyww.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <20240826065814.1336616-5-wangkefeng.wang@huawei.com>


Kefeng Wang <wangkefeng.wang@huawei.com> writes:

> Saves a couple of calls to compound_head() and remove last two callers
> of putback_lru_page().
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/migrate_device.c | 41 ++++++++++++++++++++++-------------------
>  1 file changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index b49f4956617a..6ea3d055f520 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -815,42 +815,45 @@ void migrate_device_finalize(unsigned long *src_pfns,
>  	unsigned long i;
>  
>  	for (i = 0; i < npages; i++) {
> -		struct folio *dst, *src;
> +		struct folio *dst = NULL, *src = NULL;
>  		struct page *newpage = migrate_pfn_to_page(dst_pfns[i]);
>  		struct page *page = migrate_pfn_to_page(src_pfns[i]);

We could probably simplify this even further with a
migrate_pfn_to_folio() function. I'm still working on extending
ZONE_DEVICE to support higher order folios though (held up fixing
refcounts) so this can wait until then.

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

>  
> +		if (newpage)
> +			dst = page_folio(newpage);
> +
>  		if (!page) {
> -			if (newpage) {
> -				unlock_page(newpage);
> -				put_page(newpage);
> +			if (dst) {
> +				folio_unlock(dst);
> +				folio_put(dst);
>  			}
>  			continue;
>  		}
>  
> -		if (!(src_pfns[i] & MIGRATE_PFN_MIGRATE) || !newpage) {
> -			if (newpage) {
> -				unlock_page(newpage);
> -				put_page(newpage);
> +		src = page_folio(page);
> +
> +		if (!(src_pfns[i] & MIGRATE_PFN_MIGRATE) || !dst) {
> +			if (dst) {
> +				folio_unlock(dst);
> +				folio_put(dst);
>  			}
> -			newpage = page;
> +			dst = src;
>  		}
>  
> -		src = page_folio(page);
> -		dst = page_folio(newpage);
>  		remove_migration_ptes(src, dst, false);
>  		folio_unlock(src);
>  
> -		if (is_zone_device_page(page))
> -			put_page(page);
> +		if (folio_is_zone_device(src))
> +			folio_put(src);
>  		else
> -			putback_lru_page(page);
> +			folio_putback_lru(src);
>  
> -		if (newpage != page) {
> -			unlock_page(newpage);
> -			if (is_zone_device_page(newpage))
> -				put_page(newpage);
> +		if (dst != src) {
> +			folio_unlock(dst);
> +			if (folio_is_zone_device(dst))
> +				folio_put(dst);
>  			else
> -				putback_lru_page(newpage);
> +				folio_putback_lru(dst);
>  		}
>  	}
>  }



  parent reply	other threads:[~2024-08-27  5:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26  6:58 [PATCH 0/6] mm: finish isolate/putback_lru_page() Kefeng Wang
2024-08-26  6:58 ` [PATCH 1/6] mm: migrate_device: convert to migrate_device_coherent_folio() Kefeng Wang
2024-08-26 15:04   ` David Hildenbrand
2024-08-26 17:52   ` Vishal Moola
2024-08-27  5:42   ` Alistair Popple
2024-08-26  6:58 ` [PATCH 2/6] mm: migrate_device: use a folio in migrate_device_range() Kefeng Wang
2024-08-26 15:05   ` David Hildenbrand
2024-08-26 17:53   ` Vishal Moola
2024-08-27  5:46   ` Alistair Popple
2024-08-26  6:58 ` [PATCH 3/6] mm: migrate_device: use more folio in migrate_device_unmap() Kefeng Wang
2024-08-26 15:06   ` David Hildenbrand
2024-08-26 17:53   ` Vishal Moola
2024-08-27  5:47   ` Alistair Popple
2024-08-26  6:58 ` [PATCH 4/6] mm: migrate_device: use more folio in migrate_device_finalize() Kefeng Wang
2024-08-26 17:53   ` Vishal Moola
2024-08-27  5:48   ` Alistair Popple [this message]
2024-08-26  6:58 ` [PATCH 5/6] mm: remove isolate_lru_page() Kefeng Wang
2024-08-26 13:05   ` Matthew Wilcox
2024-08-26 13:52     ` Kefeng Wang
2024-08-26 14:41   ` [PATCH 5-fix/6] mm: remove isolate_lru_page() fix Kefeng Wang
2024-08-26 17:54     ` Vishal Moola
2024-08-26  6:58 ` [PATCH 6/6] mm: remove putback_lru_page() Kefeng Wang
2024-08-26 15:08   ` David Hildenbrand
2024-08-26 17:54   ` Vishal Moola

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=8734mqjyww.fsf@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox