• K
    memcg: fix shrinking memory to return -EBUSY by fixing retry algorithm · 81d39c20
    KAMEZAWA Hiroyuki 提交于
    As pointed out, shrinking memcg's limit should return -EBUSY after
    reasonable retries.  This patch tries to fix the current behavior of
    shrink_usage.
    
    Before looking into "shrink should return -EBUSY" problem, we should fix
    hierarchical reclaim code.  It compares current usage and current limit,
    but it only makes sense when the kernel reclaims memory because hit
    limits.  This is also a problem.
    
    What this patch does are.
    
      1. add new argument "shrink" to hierarchical reclaim. If "shrink==true",
         hierarchical reclaim returns immediately and the caller checks the kernel
         should shrink more or not.
         (At shrinking memory, usage is always smaller than limit. So check for
          usage < limit is useless.)
    
      2. For adjusting to above change, 2 changes in "shrink"'s retry path.
         2-a. retry_count depends on # of children because the kernel visits
    	  the children under hierarchy one by one.
         2-b. rather than checking return value of hierarchical_reclaim's progress,
    	  compares usage-before-shrink and usage-after-shrink.
    	  If usage-before-shrink <= usage-after-shrink, retry_count is
    	  decremented.
    Reported-by: NLi Zefan <lizf@cn.fujitsu.com>
    Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Paul Menage <menage@google.com>
    Cc: Balbir Singh <balbir@in.ibm.com>
    Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
    Cc: David Rientjes <rientjes@google.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    81d39c20
memcontrol.c 58.4 KB