[Devel] [PATCH RHEL7 COMMIT] ub: ub_dirty_limits: obtain ram size from memcg

Konstantin Khorenko khorenko at virtuozzo.com
Fri May 29 01:36:01 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.7
------>
commit 12d5e82b5955aab42daf5b688d2cba662de8111b
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Fri May 29 12:36:01 2015 +0400

    ub: ub_dirty_limits: obtain ram size from memcg
    
    ub_dirty_limits is meant to be used for dirty pages throttling.
    Currently, it is not, because the corresponding hunk was not applied for
    some reason, but it must and will be backported. In this function we
    need to know the current container's ram size to calculate dirty limits
    (current, because ub equals get_exec_ub() - see RH6). Currently, it is
    obtained from UB_PHYSPAGES as it was ported from RH6. This is wrong,
    because memory limits are now managed by memcg, so we should get it
    there. This patch fixes it.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 kernel/bc/io_acct.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/bc/io_acct.c b/kernel/bc/io_acct.c
index e9a0d9b..ee30fea 100644
--- a/kernel/bc/io_acct.c
+++ b/kernel/bc/io_acct.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/mm.h>
+#include <linux/memcontrol.h>
 #include <linux/mempool.h>
 #include <linux/proc_fs.h>
 #include <linux/virtinfo.h>
@@ -134,8 +135,8 @@ int ub_dirty_limits(unsigned long *pbackground,
 	if (!dirty_ratio)
 		return 0;
 
-	available_memory = ub->ub_parms[UB_PHYSPAGES].limit;
-	if (available_memory == UB_MAXVALUE || available_memory == 0)
+	available_memory = mem_cgroup_ram_pages();
+	if (available_memory == ULONG_MAX || available_memory == 0)
 		return 0;
 
 	*pdirty = (dirty_ratio * available_memory) / 100;



More information about the Devel mailing list