[Devel] [PATCH vz7 v2 6/7] ub stat: sync memcg contents with beancounter if required

Stanislav Kinsburskiy skinsbursky at odin.com
Thu Oct 1 06:38:43 PDT 2015


From: Stanislav Kinsburskiy <skinsbursky at parallels.com>

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at parallels.com>
---
 kernel/bc/statd.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/kernel/bc/statd.c b/kernel/bc/statd.c
index db9f294..ad80e7e 100644
--- a/kernel/bc/statd.c
+++ b/kernel/bc/statd.c
@@ -224,6 +224,22 @@ int ubstat_alloc_store(struct user_beancounter *ub)
 }
 EXPORT_SYMBOL(ubstat_alloc_store);
 
+static bool ubstat_need_memcg_sync(long cmd)
+{
+	if (UBSTAT_CMD(cmd) != UBSTAT_READ_ONE)
+		return true;
+
+	switch (UBSTAT_PARMID(cmd)) {
+		case UB_KMEMSIZE:
+		case UB_DCACHESIZE:
+		case UB_PHYSPAGES:
+		case UB_SWAPPAGES:
+		case UB_OOMGUARPAGES:
+			return true;
+	}
+	return false;
+}
+
 static int ubstat_check_cmd(long cmd)
 {
 	switch (UBSTAT_CMD(cmd)) {
@@ -255,6 +271,9 @@ static int ubstat_get_stat(struct user_beancounter *ub, long cmd,
 	if (retval)
 		goto out;
 
+	if (ubstat_need_memcg_sync(cmd))
+		ub_sync_memcg(ub);
+
 	spin_lock(&ubs_notify_lock);
 	switch (UBSTAT_CMD(cmd)) {
 		case UBSTAT_READ_ONE:




More information about the Devel mailing list