On Fri, 14 Dec 2018 10:39:12 +0800 Wei Yang <richard.weiyang@xxxxxxxxx> wrote: > Below is a brief call flow for __offline_pages() Offtopic... set_migratetype_isolate() has the comment /* * immobile means "not-on-lru" pages. If immobile is larger than * removable-by-driver pages reported by notifier, we'll fail. */ what the heck does that mean? It used to talk about unmovable pages, but this was mysteriously changed to use the unique term "immobile" by Minchan's ee6f509c32 ("mm: factor out memory isolate functions"). Could someone please take a look? > and > alloc_contig_range(): > > __offline_pages()/alloc_contig_range() > start_isolate_page_range() > set_migratetype_isolate() > drain_all_pages() > drain_all_pages() > > Since set_migratetype_isolate() is only used in > start_isolate_page_range(), which is just used in __offline_pages() and > alloc_contig_range(). And both of them call drain_all_pages() if every > check looks good. This means it is not necessary call drain_all_pages() > in each iteration of set_migratetype_isolate(). > > By doing so, the logic seems a little bit clearer. > set_migratetype_isolate() handles pages in Buddy, while > drain_all_pages() takes care of pages in pcp. Well. drain_all_pages() moves pages from pcp to buddy so I'm not sure that argument holds water. Can we step back a bit and ask ourselves what all these draining operations are actually for? What is the intent behind each callsite? Figuring that out (and perhaps even documenting it!) would help us decide the most appropriate places from which to perform the drain.