mm: exclude free cma pages when calculate watermark [1/1]
authortao zeng <tao.zeng@amlogic.com>
Thu, 1 Nov 2018 02:18:16 +0000 (10:18 +0800)
committertao zeng <tao.zeng@amlogic.com>
Thu, 1 Nov 2018 02:18:16 +0000 (10:18 +0800)
PD#SWPL-1210

Problem:
Some drivers(eth/wifi) occasionally can't allocate memory under
atomic context. From mem status print, there are enough free
pages but most of them are CMA.

Solution:
Exclude free cma pages when calculate water mark. This can push
kswapd/compaction work more aggressive.

Verify:
P212

Change-Id: Ia723f21c0316eff1a38e759ff9f044bb59aa8efa
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
mm/page_alloc.c

index 0862dcf..a361ce2 100644 (file)
@@ -2996,13 +2996,10 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
 
 #ifdef CONFIG_CMA
        /* If allocation can't use CMA areas don't use free CMA pages */
+#ifndef CONFIG_AMLOGIC_CMA /* always sub cma pages to avoid wm all CMA */
        if (!(alloc_flags & ALLOC_CMA))
-               free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);
-#ifdef CONFIG_AMLOGIC_CMA
-       /* avoid free pages in water mark are all CMA */
-       else
-               free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES) / 2;
 #endif
+               free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);
 #endif
 
        /*