All of lore.kernel.org
 help / color / mirror / Atom feed
* Why __alloc_contig_migrate_range calls  migrate_prep() at first?
@ 2016-06-01  3:42 Wang Sheng-Hui
  2016-06-01  7:40 ` Minchan Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Wang Sheng-Hui @ 2016-06-01  3:42 UTC (permalink / raw)
  To: akpm, mgorman, iamjoonsoo.kim; +Cc: linux-mm

Dear,

Sorry to trouble you.

I noticed cma_alloc would turn to  __alloc_contig_migrate_range for allocating pages.
But  __alloc_contig_migrate_range calls  migrate_prep() at first, even if the requested page
is single and free, lru_add_drain_all still run (called by  migrate_prep())?

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_all run for each page.

Should we detect if the required pages are free before migrate_prep(), or detect at least for single 
page allocation?

------------------
Regards,
Wang Sheng-HuiN‹§²æìr¸›zǧu©ž²Æ {\b­†éì¹»\x1c®&Þ–)îÆi¢žØ^n‡r¶‰šŽŠÝ¢j$½§$¢¸\x05¢¹¨­è§~Š'.)îÄÃ,yèm¶ŸÿÃ\f%Š{±šj+ƒðèž×¦j)Z†·Ÿ

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re:  Why __alloc_contig_migrate_range calls  migrate_prep() at first?
@ 2016-06-01 12:11 Wang Sheng-Hui
  0 siblings, 0 replies; 8+ messages in thread
From: Wang Sheng-Hui @ 2016-06-01 12:11 UTC (permalink / raw)
  To: Minchan Kim; +Cc: akpm, mgorman, iamjoonsoo.kim, linux-mm, Vlastimil Babka

[-- Attachment #1: Type: text/plain, Size: 2148 bytes --]

Minchan,

That sounds good to me. 

Thanks,
Wang Sheng-Hui


------------------ Original ------------------
From:  "Minchan Kim";<minchan@kernel.org>;
Date:  Wed, Jun 1, 2016 03:40 PM
To:  "Wang Sheng-Hui"<shhuiw@foxmail.com>; 
Cc:  "akpm"<akpm@linux-foundation.org>; "mgorman"<mgorman@techsingularity.net>; "iamjoonsoo.kim"<iamjoonsoo.kim@lge.com>; "linux-mm"<linux-mm@kvack.org>; "Vlastimil Babka"<vbabka@suse.cz>; 
Subject:  Re: Why __alloc_contig_migrate_range calls  migrate_prep() at first?



On Wed, Jun 01, 2016 at 11:42:29AM +0800, Wang Sheng-Hui wrote:
> Dear,
> 
> Sorry to trouble you.
> 
> I noticed cma_alloc would turn to  __alloc_contig_migrate_range for allocating pages.
> But  __alloc_contig_migrate_range calls  migrate_prep() at first, even if the requested page
> is single and free, lru_add_drain_all still run (called by  migrate_prep())?
> 
> 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_all run 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?

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9d666df5ef95..c504c1a623d2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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);


> 
> ------------------
> Regards,
> Wang Sheng-HuiN‹§²æìr¸›zǧu©ž²Æ {­†éì¹»®&Þ–)îÆi¢žØ^n‡r¶‰šŽŠÝ¢j$½§$¢¸¢¹¨­è§~Š'.)îÄ

[-- Attachment #2: Type: text/html, Size: 2456 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-02  6:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01  3:42 Why __alloc_contig_migrate_range calls migrate_prep() at first? Wang Sheng-Hui
2016-06-01  7:40 ` Minchan Kim
2016-06-02  1:19   ` Wang Sheng-Hui
2016-06-02  2:22     ` Joonsoo Kim
2016-06-02  4:29       ` Minchan Kim
2016-06-02  6:29         ` Joonsoo Kim
2016-06-02  6:46           ` Minchan Kim
2016-06-01 12:11 Wang Sheng-Hui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.