Files
kernel_arpi/mm
Minchan Kim 98f3cc7ecd ANDROID: mm: freeing MIGRATE_ISOLATE page instantly
Since Android has pcp list for MIGRATE_CMA[1], it could cause
CMA allocation latency due to not freeing the MIGRATE_ISOLATE
page immediately.

Originally, MIGRATE_ISOLATED page is supposed to go buddy list
with skipping pcp list. Otherwise, the page could be reallocated
from pcp list or staying on the pcp list until the pcp is drained
so that CMA keeps retrying since it couldn't find the freed page
from buddy list. That worked before since the CMA pfnblocks changed
only from MIGRATE_CMA to MIGRATE_ISOLATE and free function logic
in page allocator has checked MIGRATE_ISOLATEness on every CMA
pages using below.

  free_unref_page_commit
    if (migratetype >= MIGRATE_PCPTYPES)
      if(is_migrate_isolate(migratetype))
        free_one_page(page);

It worked since enum MIGRATE_CMA was bigger than enum
MIGRATE_PCPTYPES but since [1], the enum MIGRATE_CMA is less than
MIGRATE_PCPTYPES so the logic above doesn't work any more.

It could cause following race

         CPU 0	                          CPU 1
  free_unref_page
  migratetype = get_pfnblock_migratetype()
  set_pcppage_migratetype(MIGRATE_CMA)

                                cma_alloc
				alloc_contig_range
                              	set_migrate_isolate(MIGRATE_ISOLATE)
  add the page into pcp list
  the page could be reallocated

This patch couldn't fix the race completely due to missing zone->lock
in order-0 page free(for performance reason). However, it's not a new
problem so we need to deal with the issue separately.

[1] ANDROID: mm: add cma pcp list

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ibea20085ce5bfb4b74b83b041f9bda9a380120f9
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit d9e4b67784866047e8cfb5598cdf1ebc0c71f3d9)
2022-12-29 09:09:24 +00:00
..
2022-07-13 11:40:42 +02:00
2022-12-08 16:43:35 +00:00
2022-03-23 11:32:12 -07:00
2022-11-28 16:08:50 +00:00
2022-12-14 13:04:18 +01:00
2022-09-24 14:12:45 +02:00
2021-09-13 10:18:28 -07:00
2022-10-05 11:59:55 +02:00
2022-03-16 12:53:52 +01:00
2022-12-14 13:04:18 +01:00
2022-09-21 17:30:12 +02:00
2022-10-05 11:59:55 +02:00
2022-06-09 15:39:10 +02:00
2022-06-06 11:12:02 +02:00
2021-11-23 11:59:24 +05:30
2022-04-27 16:02:52 +00:00
2022-11-28 16:08:50 +00:00
2022-06-06 11:12:02 +02:00
2022-06-06 11:12:02 +02:00
2022-09-28 13:32:32 +02:00
2021-11-23 11:59:24 +05:30
2022-07-13 19:41:43 +02:00
2022-12-08 16:43:35 +00:00
2022-07-09 11:22:04 +02:00