[lkml]   [2017]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[PATCH 0/1] mm/cma: fix alloc_contig_range ret code/potential leak
In an attempt to make contiguous allocation routines more available to
drivers, I have been experimenting with code similar to that used by
alloc_gigantic_page(). While stressing this code with many other
allocations and frees in progress, I would sometimes notice large 'leaks'
of page ranges.

I traced this down to the routine alloc_contig_range() itself. In commit
8ef5849fa8a2 the code was changed so that an -EBUSY returned by
__alloc_contig_migrate_range() would not immediately return to the caller.
Rather, processing continues so that test_pages_isolated() is eventually
called. This is done because test_pages_isolated() has a tracepoint to
identify the busy pages.

However, it is possible (observed in my testing) that pages which were
busy when __alloc_contig_migrate_range was called may become available
by the time test_pages_isolated is called. Further, it is possible that
the entire range can actually be allocated. Unfortunately, in this case
the return code originally set by __alloc_contig_migrate_range (-EBUSY)
is returned to the calller. Therefore, the caller assumes the range was
not allocated and the pages are essentially leaked.

The following patch simply updates the return code based on the value
returned from test_pages_isolated.

It is unlikely that we will hit this issue today based on the limited
number of callers to alloc_contig_range. However, I have Cc'ed stable
because if we do hit this issue it has the potential to leak a large
number of pages.

Mike Kravetz (1):
mm/cma: fix alloc_contig_range ret code/potential leak

mm/page_alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)


 \ /
  Last update: 2017-11-20 20:40    [W:0.063 / U:1.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site