Re: [PATCH 01/10] mm/page-flags: introduce PageHighMemZone()
From: Joonsoo Kim
Date: Tue Apr 21 2020 - 02:43:52 EST
Hello, Matthew and Vlastimil.
2020ë 4ì 20ì (ì) ìí 8:37, Vlastimil Babka <vbabka@xxxxxxx>ëì ìì:
>
> On 4/20/20 1:20 PM, Matthew Wilcox wrote:
> > On Mon, Apr 20, 2020 at 04:59:33PM +0900, js1304@xxxxxxxxx wrote:
> >> ZONE_MOVABLE is special. It is considered as normal type zone on
> >> !CONFIG_HIGHMEM, but, it is considered as highmem type zone
> >> on CONFIG_HIGHMEM. Let's focus on later case. In later case, all pages
> >> on the ZONE_MOVABLE has no direct mapping until now.
> >>
> >> However, following patchset
> >> "mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE"
> >> , which is once merged and reverted, will be tried again and will break
> >> this assumption that all pages on the ZONE_MOVABLE has no direct mapping.
> >> Hence, the ZONE_MOVABLE which is considered as highmem type zone could
> >> have the both types of pages, direct mapped and not. Since
> >> the ZONE_MOVABLE could have both type of pages, __GFP_HIGHMEM is still
> >> required to allocate the memory from it. And, we conservatively need to
> >> consider the ZONE_MOVABLE as highmem type zone.
> >
> > I don't understand why CMA allocating pages from ZONE_MOVABLE somehow
> > gives these pages a direct mapping. Maybe you have a freaky layout in
> > the architecture that makes no sense and that's what needs to be fixed?
> >
> > My understanding of the zones is based on x86, and it looks like this
> > on a 32-bit system with 8GB of memory:
> >
> > ZONE_DMA 0-16MB
> > ZONE_NORMAL 16-896MB
> > ZONE_HIGHMEM 896-xMB
> > ZONE_MOVABLE x-8192MB
> >
> > where x is a boot option used to partition the highmem between movable
> > and unmovable.
> >
> > Now, why would allocating the CMA from ZONE_NORMAL suddenly make these
> > pages part of the direct mapping?
>
> I assume the scenario is that ZONE_MOVABLE could extend into today's ZONE_NORMAL
> range, which is the range covered by direct mapping.
> At that point, testing page's zone stops being a reliable test of "does this
> page have direct mapping"?
Correct explanation. Thanks, Vlastimil.
This patchset is a preparation for my future patchset "mm/cma: manage the memory
of the CMA area by using the ZONE_MOVABLE" [1] to solve the many CMA problems.
CMA areas can be on the all the memory range, from ZONE_DMA to ZONE_HIGHMEM.
And, in my future patchset [1], all the CMA areas are managed through
the ZONE_MOVABLE
and the range of the ZONE_MOVABLE is extended to cover all the CMA
areas. In this
case, following scenario would be possible.
CMA area 1: 32MB size on the memory range 16MB~48MB (originally on the
ZONE_NORMAL)
CMA area 2: 32MB size on the memory range 896MB~928MB (originally on
the ZONE_HIGHMEM)
With my future patchset [1], ZONE_MOVABLE manages all the pages from
CMA area 1 and 2.
So, ZONE_MOVABLE has both direct mapped page and un-mapped page. Since one zone
has two types of pages, current PageHighMem() implemented by using
zone index could not
work correctly. So, I make this patchset to change the PagHighMem()
implementation.
> I don't know the exact motivation why that will happen but I can imagine two.
> 1) some CMA user needs the CMA allocations to be in direct mapping range
> 2) the amount of CMA memory reservation required is so high it won't fit in
> highmem range only.
The range of CMA area is highly depends on system architecture and
device. Each device
using CMA area would have different limitation for address range and
someone's limitation
could be low memory range.
Thanks.