From: Hyesoo Yu <hyesoo.yu@samsung.com>
Cc: janghyuck.kim@samsung.com, zhaoyang.huang@unisoc.com,
jaewon31.kim@gmail.com, david@redhat.com,
Hyesoo Yu <hyesoo.yu@samsung.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] mm: gup: clean up stale logic in migrate_longterm_unpinnable_folio()
Date: Thu, 5 Jun 2025 12:32:06 +0900 [thread overview]
Message-ID: <20250605033210.3184521-2-hyesoo.yu@samsung.com> (raw)
In-Reply-To: <20250605033210.3184521-1-hyesoo.yu@samsung.com>
migrate_longterm_unpinnable_folio() always receives a non-empty
movable_folio_list. Thus, list_empty() check can be safely removed.
Also, pofs entries are fully unpinned before migration is attempted.
The err label contained unnecessary unpinning logic for pofs, which
is now removed.
No functional change intended.
Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com>
---
mm/gup.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index e065a49842a8..68d91b000199 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2353,7 +2353,12 @@ static int
migrate_longterm_unpinnable_folios(struct list_head *movable_folio_list,
struct pages_or_folios *pofs)
{
- int ret;
+ struct migration_target_control mtc = {
+ .gfp_mask = GFP_USER | __GFP_NOWARN,
+ .reason = MR_LONGTERM_PIN,
+ .nid = NUMA_NO_NODE,
+ };
+ int ret = -EAGAIN;
unsigned long i;
for (i = 0; i < pofs->nr_entries; i++) {
@@ -2370,6 +2375,7 @@ migrate_longterm_unpinnable_folios(struct list_head *movable_folio_list,
gup_put_folio(folio, 1, FOLL_PIN);
if (migrate_device_coherent_folio(folio)) {
+ pofs_unpin(pofs);
ret = -EBUSY;
goto err;
}
@@ -2388,27 +2394,11 @@ migrate_longterm_unpinnable_folios(struct list_head *movable_folio_list,
pofs_clear_entry(pofs, i);
}
- if (!list_empty(movable_folio_list)) {
- struct migration_target_control mtc = {
- .nid = NUMA_NO_NODE,
- .gfp_mask = GFP_USER | __GFP_NOWARN,
- .reason = MR_LONGTERM_PIN,
- };
-
- if (migrate_pages(movable_folio_list, alloc_migration_target,
- NULL, (unsigned long)&mtc, MIGRATE_SYNC,
- MR_LONGTERM_PIN, NULL)) {
- ret = -ENOMEM;
- goto err;
- }
- }
-
- putback_movable_pages(movable_folio_list);
-
- return -EAGAIN;
+ if (migrate_pages(movable_folio_list, alloc_migration_target, NULL,
+ (unsigned long)&mtc, MIGRATE_SYNC, MR_LONGTERM_PIN, NULL))
+ ret = -ENOMEM;
err:
- pofs_unpin(pofs);
putback_movable_pages(movable_folio_list);
return ret;
--
2.49.0
next prev parent reply other threads:[~2025-06-05 3:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250605033401epcas2p46651837ba85629a50ed69db9665a52a2@epcas2p4.samsung.com>
2025-06-05 3:32 ` [PATCH v2 0/2] mm: gup: avoid CMA pinning and clean up stale logic Hyesoo Yu
[not found] ` <CGME20250605033430epcas2p37db099e1ff4f2225c2059e08bbaa97c9@epcas2p3.samsung.com>
2025-06-05 3:32 ` Hyesoo Yu [this message]
[not found] ` <CGME20250605033432epcas2p4c024a9d05246b18c217f3562b3f53551@epcas2p4.samsung.com>
2025-06-05 3:32 ` [PATCH v2 2/2] mm: gup: avoid CMA page pinning by retrying migration if no migratable page Hyesoo Yu
2025-06-05 3:43 ` Andrew Morton
2025-06-05 5:11 ` Hyesoo Yu
2025-06-05 5:24 ` Andrew Morton
2025-06-05 6:59 ` Hyesoo Yu
2025-06-05 7:39 ` David Hildenbrand
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=20250605033210.3184521-2-hyesoo.yu@samsung.com \
--to=hyesoo.yu@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jaewon31.kim@gmail.com \
--cc=janghyuck.kim@samsung.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=zhaoyang.huang@unisoc.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