mbox series

[0/2] Increasing CMA Utilization with a GFP Flag

Message ID cover.1604282969.git.cgoldswo@codeaurora.org (mailing list archive)
Headers show
Series Increasing CMA Utilization with a GFP Flag | expand

Message

Chris Goldsworthy Nov. 2, 2020, 2:39 p.m. UTC
The current approach to increasing CMA utilization introduced in
commit 16867664936e ("mm,page_alloc,cma: conditionally prefer cma
pageblocks for movable allocations") increases CMA utilization by
redirecting MIGRATE_MOVABLE allocations to a CMA region, when
greater than half of the free pages in a given zone are CMA pages.
The issue in this approach is that allocations with type
MIGRATE_MOVABLE can still succumb to pinning. To get around
this, one approach is to re-direct allocations to the CMA areas, that
are known not to be victims of pinning.

To this end, this series brings in __GFP_CMA, which we mark with
allocations that we know are safe to be redirected to a CMA area.

Heesub Shin (1):
  cma: redirect page allocation to CMA

Vinayak Menon (1):
  zram: allow zram to allocate CMA pages

 drivers/block/zram/zram_drv.c |  5 +--
 include/linux/gfp.h           | 15 ++++++++
 include/linux/highmem.h       |  4 ++-
 include/linux/mmzone.h        |  4 +++
 mm/page_alloc.c               | 83 +++++++++++++++++++++++++++----------------
 mm/zsmalloc.c                 |  4 +--
 6 files changed, 79 insertions(+), 36 deletions(-)

Comments

Matthew Wilcox Nov. 2, 2020, 2:44 p.m. UTC | #1
On Mon, Nov 02, 2020 at 06:39:20AM -0800, Chris Goldsworthy wrote:
> The current approach to increasing CMA utilization introduced in
> commit 16867664936e ("mm,page_alloc,cma: conditionally prefer cma
> pageblocks for movable allocations") increases CMA utilization by
> redirecting MIGRATE_MOVABLE allocations to a CMA region, when
> greater than half of the free pages in a given zone are CMA pages.
> The issue in this approach is that allocations with type
> MIGRATE_MOVABLE can still succumb to pinning. To get around
> this, one approach is to re-direct allocations to the CMA areas, that
> are known not to be victims of pinning.
> 
> To this end, this series brings in __GFP_CMA, which we mark with
> allocations that we know are safe to be redirected to a CMA area.

This feels backwards to me.  What you're essentially saying is "Some
allocations marked with GFP_MOVABLE turn out not to be movable, so we're
going to add another GFP_REALLY_MOVABLE flag" instead of tracking down
which GFP_MOVABLE allocations aren't really movable.
David Hildenbrand Nov. 2, 2020, 5:35 p.m. UTC | #2
On 02.11.20 15:44, Matthew Wilcox wrote:
> On Mon, Nov 02, 2020 at 06:39:20AM -0800, Chris Goldsworthy wrote:
>> The current approach to increasing CMA utilization introduced in
>> commit 16867664936e ("mm,page_alloc,cma: conditionally prefer cma
>> pageblocks for movable allocations") increases CMA utilization by
>> redirecting MIGRATE_MOVABLE allocations to a CMA region, when
>> greater than half of the free pages in a given zone are CMA pages.
>> The issue in this approach is that allocations with type
>> MIGRATE_MOVABLE can still succumb to pinning. To get around
>> this, one approach is to re-direct allocations to the CMA areas, that
>> are known not to be victims of pinning.
>>
>> To this end, this series brings in __GFP_CMA, which we mark with
>> allocations that we know are safe to be redirected to a CMA area.
> 
> This feels backwards to me.  What you're essentially saying is "Some
> allocations marked with GFP_MOVABLE turn out not to be movable, so we're
> going to add another GFP_REALLY_MOVABLE flag" instead of tracking down
> which GFP_MOVABLE allocations aren't really movable.

Right, this just sounds wrong. We have the exact same issues with 
long-term pinnings on ZONE_MOVABLE. We have known issues with short-term 
pinnings and movable allocations (e.g., when a process dies) that should 
be tackled instead.

This is just trying to work around the original issue.

Nacked-by: David Hildenbrand <david@redhat.com>
Michal Hocko Nov. 3, 2020, 7:58 p.m. UTC | #3
On Mon 02-11-20 14:44:49, Matthew Wilcox wrote:
> On Mon, Nov 02, 2020 at 06:39:20AM -0800, Chris Goldsworthy wrote:
> > The current approach to increasing CMA utilization introduced in
> > commit 16867664936e ("mm,page_alloc,cma: conditionally prefer cma
> > pageblocks for movable allocations") increases CMA utilization by
> > redirecting MIGRATE_MOVABLE allocations to a CMA region, when
> > greater than half of the free pages in a given zone are CMA pages.
> > The issue in this approach is that allocations with type
> > MIGRATE_MOVABLE can still succumb to pinning. To get around
> > this, one approach is to re-direct allocations to the CMA areas, that
> > are known not to be victims of pinning.
> > 
> > To this end, this series brings in __GFP_CMA, which we mark with
> > allocations that we know are safe to be redirected to a CMA area.
> 
> This feels backwards to me.  What you're essentially saying is "Some
> allocations marked with GFP_MOVABLE turn out not to be movable, so we're
> going to add another GFP_REALLY_MOVABLE flag" instead of tracking down
> which GFP_MOVABLE allocations aren't really movable.

Absolutely agreed. What is even worse the proposed approach doesn't
really add any new guarantee. Just look at how the new flag is used for
any anonymous page and that is a subject to a long term pinning as well.
So in the end a new and confusing gfp flag is proposed that doesn't
really help with the underlying problem.

Nacked-by: Michal Hocko <mhocko@suse.com>