From: Wei Yang <richard.weiyang@gmail.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, osalvador@suse.de, david@redhat.com,
Minchan Kim <minchan@kernel.org>,
Mel Gorman <mgorman@techsingularity.net>
Subject: Re: [PATCH] mm, page_isolation: remove drain_all_pages() in set_migratetype_isolate()
Date: Tue, 18 Dec 2018 20:48:44 +0000 [thread overview]
Message-ID: <20181218204844.tmlv5jpie6smhnhn@master> (raw)
In-Reply-To: <20181217122132.GH30879@dhcp22.suse.cz>
On Mon, Dec 17, 2018 at 01:21:32PM +0100, Michal Hocko wrote:
>On Fri 14-12-18 15:17:56, Wei Yang wrote:
>> On Thu, Dec 13, 2018 at 07:57:12PM -0800, Andrew Morton wrote:
>> >On Fri, 14 Dec 2018 10:39:12 +0800 Wei Yang <richard.weiyang@gmail.com> 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.
>>
>> With some rethinking we even could take drain_all_pages() out of the
>> repeat loop. Because after isolation, the page in this range will not be
>> put to pcp pageset. So we just need to drain pages once.
>>
>> The change may look like this.
>
>No, this is incorrect. Draining pcp lists before scan_movable_pages is
>most likely sub-optimal, because scan_movable_pages will simply ignore
>pages being on the pcp lists. But we definitely want to drain before we
>terminate the offlining phase because we do not want to have isolated
>pages on those lists before we allow the final hotremove.
>
>The way how we retry the migration loop until there is no page in use
>just guarantees that drain_all_pages is called. If you put it out of the
>loop then you just break that assumption. Moving drain_all_pages down
>after the migration is done should work well AFAICS but I didn't really
>think through all potential side effects nor have time to do so now.
>
After discussion, do you agree with this proposal?
>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>> index 6910e0eea074..120e9fdfd055 100644
>> --- a/mm/memory_hotplug.c
>> +++ b/mm/memory_hotplug.c
>> @@ -1590,6 +1590,7 @@ static int __ref __offline_pages(unsigned long start_pfn,
>> if (ret)
>> goto failed_removal;
>>
>> + drain_all_pages(zone);
>> pfn = start_pfn;
>> repeat:
>> /* start memory hot removal */
>> @@ -1599,7 +1600,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
>>
>> cond_resched();
>> lru_add_drain_all();
>> - drain_all_pages(zone);
>>
>> pfn = scan_movable_pages(start_pfn, end_pfn);
>> if (pfn) { /* We have movable pages */
>>
>> --
>> Wei Yang
>> Help you, Help me
>
>--
>Michal Hocko
>SUSE Labs
--
Wei Yang
Help you, Help me
next prev parent reply other threads:[~2018-12-18 20:48 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 2:39 Wei Yang
2018-12-14 3:57 ` Andrew Morton
2018-12-14 7:01 ` Wei Yang
2018-12-14 15:17 ` Wei Yang
2018-12-17 12:21 ` Michal Hocko
2018-12-18 20:48 ` Wei Yang [this message]
2018-12-17 12:25 ` Michal Hocko
2018-12-17 15:08 ` Wei Yang
2018-12-17 15:48 ` Michal Hocko
2018-12-18 14:44 ` Wei Yang
2018-12-18 20:46 ` [PATCH v2] " Wei Yang
2018-12-18 21:14 ` David Hildenbrand
2018-12-18 21:49 ` Wei Yang
2018-12-18 22:18 ` David Hildenbrand
2018-12-18 23:29 ` Oscar Salvador
2018-12-19 9:51 ` Michal Hocko
2018-12-19 9:57 ` Oscar Salvador
2018-12-19 13:53 ` Wei Yang
2018-12-19 14:13 ` Michal Hocko
2018-12-19 14:33 ` Wei Yang
2018-12-19 14:39 ` Michal Hocko
2018-12-20 15:58 ` Wei Yang
2018-12-20 16:23 ` Michal Hocko
2018-12-21 3:37 ` Wei Yang
2018-12-19 13:29 ` Wei Yang
2018-12-19 13:40 ` Michal Hocko
2018-12-19 13:56 ` Wei Yang
2018-12-19 14:12 ` Michal Hocko
2018-12-19 14:41 ` Wei Yang
2018-12-19 10:05 ` Michal Hocko
2018-12-21 17:02 ` [PATCH v3] mm: remove extra drain pages on pcp list Wei Yang
2018-12-21 17:02 ` Wei Yang
2019-01-03 13:56 ` Michal Hocko
2019-01-05 23:27 ` Wei Yang
2019-01-05 23:31 ` [PATCH v4] " Wei Yang
2019-01-05 23:31 ` Wei Yang
2019-01-07 11:34 ` David Hildenbrand
2019-01-08 9:10 ` Oscar Salvador
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=20181218204844.tmlv5jpie6smhnhn@master \
--to=richard.weiyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.org \
--cc=osalvador@suse.de \
/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