Messages in this thread | | | Date | Thu, 4 Aug 2022 16:06:56 -0700 | Subject | Re: [PATCH] mm/gup.c: Refactor check_and_migrate_movable_pages() | From | John Hubbard <> |
| |
On 8/3/22 20:22, Alistair Popple wrote: > @@ -1970,29 +1968,25 @@ static long check_and_migrate_movable_pages(unsigned long nr_pages, > drain_allow = false; > } > > - if (folio_isolate_lru(folio)) { > - isolation_error_count++; > + if (folio_isolate_lru(folio)) > continue; > - } > + > list_add_tail(&folio->lru, &movable_page_list); > node_stat_mod_folio(folio, > NR_ISOLATED_ANON + folio_is_file_lru(folio), > folio_nr_pages(folio)); > } > > - if (!list_empty(&movable_page_list) || isolation_error_count || > - coherent_pages) > - goto unpin_pages; > - > /* > - * If list is empty, and no isolation errors, means that all pages are > - * in the correct zone. > + * All pages are still pinned and in the correct zone. > */ > - return nr_pages; > + if (list_empty(&movable_page_list) && !coherent_pages) > + return 0; >
At this point, a second part of the (rather long) routine begins. If I were refactoring this, I'd split it into a top level routine that calls the two parts:
check_and_migrate_movable_pages() collect_migration_candidates() unpin_and_migrate_pages()
...which I think would further help in working with this thing.
(I realize that this is additional work. And that it's best done as a separate patch. And it's just a suggestion.)
> -unpin_pages: > /* > - * pages[i] might be NULL if any device coherent pages were found. > + * Unpin all pages. If device coherent pages were found > + * migrate_deivce_coherent_page() will have already dropped the pin and
"migrate_device_coherent_page()"
thanks, -- John Hubbard NVIDIA
| |