Re: [PATCH] mm: use managed_zone() for more exact check in zone iteration

From: Michal Hocko
Date: Fri Nov 16 2018 - 12:08:00 EST


On Fri 16-11-18 15:58:28, Wei Yang wrote:
> On Fri, Nov 16, 2018 at 12:26:03PM +0100, Michal Hocko wrote:
> >On Fri 16-11-18 12:05:04, osalvador wrote:
> >> On Fri, 2018-11-16 at 10:57 +0100, Michal Hocko wrote:
> >[...]
> >> > E.g. memory hotplug decreases both managed and present counters. I
> >> > am actually not sure that is 100% correct (put on my TODO list to
> >> > check). There is no consistency in that regards.
> >>
> >> We can only offline non-reserved pages (so, managed pages).
> >
> >Yes
> >
> >> Since present pages holds reserved_pages + managed_pages, decreasing
> >> both should be fine unless I am mistaken.
> >
> >Well, present_pages is defined as "physical pages existing within the zone"
> >and those pages are still existing but they are offline. But as I've
> >said I have to think about it some more
>
> I may not catch up with your discussions, while I'd like to share what I
> learnt.
>
> online_pages()
> online_pages_range()
> zone->present_pages += onlined_pages;
>
> __offline_pages()
> adjust_managed_page_count()
> zone->present_pages -= offlined_pages;
>
> The two counters: present_pages & managed_pages would be adjusted during
> online/offline.
>
> While I am not sure when *reserved_pages* would be adjusted. Will we add
> this hot-added memory into memblock.reserved? and allocate memory by
> memblock_alloc() after system bootup?

This is not really related to this patch. I have only mentioned the
memory hotplug as an example. I would rather focus on the change itself
so let's not get too off topic here.

--
Michal Hocko
SUSE Labs