[Devel] [PATCH RHEL7 COMMIT] mm: vmscan: don't drop global slab caches at once if root cgroup is empty

Konstantin Khorenko khorenko at virtuozzo.com
Fri Feb 19 02:15:40 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.4.5.vz7.11.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.4.5.vz7.11.4
------>
commit fbba829c6836acbecee44f1883685415d6337569
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Fri Feb 19 14:15:39 2016 +0400

    mm: vmscan: don't drop global slab caches at once if root cgroup is empty
    
    If most processes reside in memory cgroups protected with memory.low,
    there won't be a lot of pages in the root cgroup's lruvec so that the
    lru scanned/eligible ratio can get high even on the initial scan
    priority. In this case global slab caches will be evicted far too
    aggressively. Tcache/tswap are especially affected - if the node is
    undercommitted, they may occupy gigabytes of RAM which can be dropped in
    an instant even on very low memory pressure.
    
    To fix this, we forge scanned/eligible ratio passed to slab shrinkers if
    the number of pages on the root lruvec is small.
    
    Related to https://jira.sw.ru/browse/PSBM-41239
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 mm/vmscan.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0406c11..a7cc964 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2388,10 +2388,29 @@ static void shrink_zone(struct zone *zone, struct scan_control *sc,
 		 * Shrink the slab caches in the same proportion that
 		 * the eligible LRU pages were scanned.
 		 */
-		if (global_reclaim(sc) && is_classzone)
+		if (global_reclaim(sc) && is_classzone) {
+			unsigned long scanned, eligible;
+
+			scanned = sc->nr_scanned - nr_scanned;
+			eligible = zone_lru_pages;
+
+			/*
+			 * If most processes reside in memory cgroups protected
+			 * with memory.low there won't be a lot of user pages
+			 * in the root lruvec so that the lru scanned/eligible
+			 * ratio ratio can get high even on the default scan
+			 * priority. In order not to subject memcg unaware slab
+			 * caches to disproportionately high pressure, we forge
+			 * the ratio in this case.
+			 */
+			if (eligible >> sc->priority == 0) {
+				scanned = 1000;
+				eligible = 1000 << sc->priority;
+			}
+
 			shrink_slab(slab_gfp, zone_to_nid(zone), NULL,
-				    sc->nr_scanned - nr_scanned,
-				    zone_lru_pages);
+				    scanned, eligible);
+		}
 
 		if (reclaim_state) {
 			sc->nr_reclaimed += reclaim_state->reclaimed_slab;


More information about the Devel mailing list