Why __alloc_contig_migrate_range calls migrate_prep() at first?
Subsystems (2)
Minchan,
That sounds good to me.
Thanks,
Wang Sheng-Hui
------------------ Original ------------------
From: "Minchan Kim";<[email protected]>; Date: Wed, Jun 1, 2016 03:40 PM To: "Wang Sheng-Hui"<[email protected]>;
Cc: "akpm"<[email protected]>; "mgorman"<[email protected]>; "iamjoonsoo.kim"<[email protected]>; "linux-mm"<[email protected]>; "Vlastimil Babka"<[email protected]>;
Subject: Re: Why __alloc_contig_migrate_range calls migrate_prep() at first?
Quoted 8 lines · Wang Sheng-Hui
Dear,
Sorry to trouble you.
I noticed
cma_allocwould turn to__alloc_contig_migrate_rangefor allocating pages. But__alloc_contig_migrate_rangecallsmigrate_prep()at first, even if the requested page is single and free,lru_add_drain_allstill run (called bymigrate_prep())?
Quoted 5 lines
Image a large chunk of free contig pages for CMA, various drivers may request a single page from the CMA area, we'll get
lru_add_drain_allrun for each page.Should we detect if the required pages are free before
migrate_prep(), or detect at least for single page allocation?
That makes sense to me.
How about calling migrate_prep once migrate_pages fails in the first trial?
mm/page_alloc.c +0 -0
@@ -6623,8 +6623,6 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
unsigned int tries = 0;
int ret = 0;
- migrate_prep();
-
while (pfn < end || !list_empty(&cc->migratepages)) {
if (fatal_signal_pending(current)) {
ret = -EINTR;
@@ -6650,6 +6648,8 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
ret = migrate_pages(&cc->migratepages, alloc_migrate_target,
NULL, 0, cc->mode, MR_CMA);
+if (ret)
+ migrate_prep();
}
if (ret < 0) { putback_movable_pages(&cc->migratepages);
Quoted 4 lines
------------------
Regards,
Wang Sheng-HuiN‹§²æìr¸›zǧu©ž²Æ {†éì¹»®&Þ–)îÆi¢žØ^n‡r¶‰šŽŠÝ¢j$½§$¢¸¢¹¨è§~Š'.)îÄ