From cb7c1a4c787f882b16f6f8ebb5819203d6900460 Mon Sep 17 00:00:00 2001 From: Peifeng Li Date: Sat, 26 Mar 2022 20:43:40 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Add hooks to for free_unref_page_commit Provide a vendor hook to skip cma-pages to add in pcplist when free_unref_page_commit. The patch is revelant to skip drain_all_pages in alloc_contig_range, the revelant hooks is android_vh_cma_drain_all_pages_bypass which is to avoid to delay in drain pcppages when drain_all_pages. In most case, pcp->high is small so that free-pages with other mt_types can also fill with pcplist full. Bug: 224732340 Signed-off-by: Peifeng Li Change-Id: Ifdeeed9f8934d87671ec3fa6787a02675b993082 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/page_alloc.c | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 44507a74e573..2e2285789229 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -294,6 +294,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_slab_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_referenced_check_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_drain_all_pages_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_drain_all_pages_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pcplist_add_cma_pages_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index b5db91c72bf5..bde2f3556c2a 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -125,6 +125,9 @@ DECLARE_HOOK(android_vh_drain_all_pages_bypass, DECLARE_HOOK(android_vh_cma_drain_all_pages_bypass, TP_PROTO(unsigned int migratetype, bool *bypass), TP_ARGS(migratetype, bypass)); +DECLARE_HOOK(android_vh_pcplist_add_cma_pages_bypass, + TP_PROTO(int migratetype, bool *bypass), + TP_ARGS(migratetype, bypass)); struct device; DECLARE_HOOK(android_vh_subpage_dma_contig_alloc, TP_PROTO(bool *allow_subpage_alloc, struct device *dev, size_t *size), diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4bd60d681200..30f52cc94948 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3301,6 +3301,7 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn) struct zone *zone = page_zone(page); struct per_cpu_pages *pcp; int migratetype; + bool pcp_skip_cma_pages = false; migratetype = get_pcppage_migratetype(page); __count_vm_event(PGFREE); @@ -3313,7 +3314,10 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn) * excessively into the page allocator */ if (migratetype >= MIGRATE_PCPTYPES) { - if (unlikely(is_migrate_isolate(migratetype))) { + trace_android_vh_pcplist_add_cma_pages_bypass(migratetype, + &pcp_skip_cma_pages); + if (unlikely(is_migrate_isolate(migratetype)) || + pcp_skip_cma_pages) { free_one_page(zone, page, pfn, 0, migratetype, FPI_NONE); return;