Snap for 6779986 from 95551f816ae87fac700f97c7e6d1bf3302f2b85b to rvc-d1-b-release

Change-Id: Ia7ae972c6fe5ecaab06b1b8cf7d3f30ed1b6cf3e
diff --git a/lmkd.cpp b/lmkd.cpp
index a2820b8..b7eb18f 100644
--- a/lmkd.cpp
+++ b/lmkd.cpp
@@ -2239,9 +2239,11 @@
  * Returns lowest breached watermark or WMARK_NONE.
  */
 static enum zone_watermark get_lowest_watermark(union meminfo *mi,
-                                                struct zone_watermarks *watermarks)
+                                                struct zone_watermarks *watermarks,
+                                                long margin)
 {
     int64_t nr_free_pages = mi->field.nr_free_pages - mi->field.cma_free;
+    int64_t high_wmark = (watermarks->high_wmark * margin) / 100;
 
     if (nr_free_pages < watermarks->min_wmark) {
         return WMARK_MIN;
@@ -2249,7 +2251,7 @@
     if (nr_free_pages < watermarks->low_wmark) {
         return WMARK_LOW;
     }
-    if (nr_free_pages < watermarks->high_wmark) {
+    if (nr_free_pages < high_wmark) {
         return WMARK_HIGH;
     }
     return WMARK_NONE;
@@ -2406,7 +2408,7 @@
      }
 
     /* Find out which watermark is breached if any */
-    wmark = get_lowest_watermark(&mi, &watermarks);
+    wmark = get_lowest_watermark(&mi, &watermarks, swap_is_low ? 115 : 100);
 
     /*
      * TODO: move this logic into a separate function