linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Xu, Yanfei" <yanfei.xu@windriver.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: mm: Question about the race condition of pages in buddy during isolating pages
Date: Tue, 12 Jan 2021 23:21:29 +0800	[thread overview]
Message-ID: <c40a0fc0-56b9-a448-b7f2-f44c48f6bd11@windriver.com> (raw)
In-Reply-To: <47aaf4b5-2587-72b0-42a1-4c0b4f13f12d@suse.cz>



On 1/12/21 10:31 PM, Vlastimil Babka wrote:
> On 1/12/21 3:24 PM, Xu, Yanfei wrote:
>> Hi Vlastimil,
> 
> Hi,
> 
>> When I inspect the the codes about isolating pages, there are some lines
>> from you make me confused. As blow:
>>
>> Locate in isolate_migratepages_block()
>> mm/compaction.c
>>
>>   908                 /*
>>   909                  * Skip if free. We read page order here without zone lock
>>   910                  * which is generally unsafe, but the race window is small and
>>   911                  * the worst thing that can happen is that we skip some
>>   912                  * potential isolation targets.
>>   913                  */
>>   914                 if (PageBuddy(page)) {
>>   915                         unsigned long freepage_order =
>> buddy_order_unsafe(page);
>>   916
>>   917                         /*
>>   918                          * Without lock, we cannot be sure that what we got is
>>   919                          * a valid page order. Consider only values in the
>>   920                          * valid order range to prevent low_pfn overflow.
>>   921                          */
>>   922                         if (freepage_order > 0 && freepage_order < MAX_ORDER))
>>   923                                 low_pfn += (1UL << freepage_order) - 1;
>>   924                         continue;
>>   925                 }
>>
>> These lines was isntroduced by the commit 99c0fd5e51c("mm, compaction:
>> skip buddy pages by their order in the migrate scanner")
>>
>> What I don't understand is that "the samll race window" mentioned in
>> comments is which situation. I think before the
>> isolate_migratepages_block() function is involved, those pageblocks have
>> been marked MIGRATE_ISOLATE by set_migratetype_isolate() in
>> start_isolate_page_range(). So the pages of those pageblocks in buddy
> 
> AFAIK that's only true when we start in alloc_contig_range(). In compact_zone()
> -> isolate_migratepages() we don't use MIGRATE_ISOLATE as that would increase
> the compaction cost a lot.
> 
Ah, got it. Compaction doesn't need these buddy pages during isolating, 
so it doesn't need to mark them MIGRATE_ISOLATE. THANK YOU.

>> will not be allocated, then the buddy_order_unsafe() here will get a
>> certainly correct order value.
>>
>> Could you please tell me what situation it will race with? :)
>>
>>
>>
>> Thanks,
>> Yanfei
>>
> 


      reply	other threads:[~2021-01-12 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 14:24 Xu, Yanfei
2021-01-12 14:31 ` Vlastimil Babka
2021-01-12 15:21   ` Xu, Yanfei [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c40a0fc0-56b9-a448-b7f2-f44c48f6bd11@windriver.com \
    --to=yanfei.xu@windriver.com \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox