Welcome! Share code as fast as possible.
- Use the language picker to change the language manually.
- The previous link will get modified. You can then share this new link with others.
- Visit
https://code-dump.vercel.app/<extension>
- For example, to create a link which for a JavaScript code you will visit
https://code-dump.vercel.app/js
Any link generated does not have an expiry.
GitHub
diff --git a/mm/migrate.c b/mm/migrate.c
index 477acf996951..261f86199f06 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1878,7 +1869,7 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio,
struct list_head *ret_folios, struct list_head *split_folios,
struct migrate_pages_stats *stats)
{
- int rc, nr_failed = 0;
+ int rc, nr_failed = 0, consec_failures = 0;
LIST_HEAD(folios);
struct migrate_pages_stats astats;
@@ -1913,11 +1904,25 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio,
list_move(from->next, &folios);
rc = migrate_pages_batch(&folios, get_new_folio, put_new_folio,
private, mode, reason, ret_folios,
- split_folios, stats, NR_MAX_MIGRATE_SYNC_RETRY);
+ split_folios, stats, 1);
list_splice_tail_init(&folios, ret_folios);
- if (rc < 0)
- return rc;
- nr_failed += rc;
+ if (rc) {
+ if (rc < 0)
+ return rc;
+ if (++consec_failures >= 7) {
+ /* We have got 7 consecutive failures;
+ * drop the current folio to ensure the
+ * the length of from list reduces
+ */
+ nr_failed += rc;
+ consec_failures = 0;
+ continue;
+ }
+ /* push it back to from list */
+ if (!list_empty(from))
+ list_add_tail(ret_folios->next, from);
+ }
+ consec_failures = 0;
}
return nr_failed;