[Devel] [PATCH 6/6 v5] cgroup: Added logging along cgroup_release_agent failure codepaths.

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Wed Apr 1 16:01:01 MSK 2020


Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 kernel/cgroup.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c2b55457..0f3c421 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -191,6 +191,12 @@ inline int cgroup_is_removed(const struct cgroup *cgrp)
 	return test_bit(CGRP_REMOVED, &cgrp->flags);
 }
 
+#define cg_log_func(msg, ve, cgrp, ...)\
+	printk(KERN_INFO "%s:ve:%p:'%s',cgroup:%p:'%s': " msg "\n", __func__,\
+		ve, (ve) ? ((struct ve_struct *)(ve))->ve_name : "<NULL>",\
+		cgrp,\
+		cgrp ? cgroup_name(cgrp):"<NULL>", ## __VA_ARGS__)
+
 /**
  * cgroup_is_descendant - test ancestry
  * @cgrp: the cgroup to be tested
@@ -2357,6 +2363,9 @@ static int cgroup_release_agent_show(struct cgroup *cgrp, struct cftype *cft,
 		if (release_agent)
 			seq_puts(seq, release_agent);
 		rcu_read_unlock();
+	} else {
+		cg_log_func("ve_owner is already released, failing...\n",
+			NULL, cgrp);
 	}
 	seq_putc(seq, '\n');
 	mutex_unlock(&cgroup_mutex);
@@ -5481,6 +5490,7 @@ void cgroup_release_agent(struct work_struct *work)
 	ve = container_of(work, struct ve_struct, release_agent_work);
 	down_read(&ve->op_sem);
 	if (!ve->is_running) {
+		cg_log_func("skipping, ve not running", ve, NULL);
 		up_read(&ve->op_sem);
 		return;
 	}
@@ -5501,10 +5511,14 @@ void cgroup_release_agent(struct work_struct *work)
 		list_del_init(&cgrp->release_list);
 		raw_spin_unlock(&ve->release_list_lock);
 		pathbuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-		if (!pathbuf)
+		if (!pathbuf) {
+			cg_log_func("failed to allocate pathbuf", ve, cgrp);
 			goto continue_free;
-		if (__cgroup_path(cgrp, pathbuf, PAGE_SIZE, 1) < 0)
+		}
+		if (__cgroup_path(cgrp, pathbuf, PAGE_SIZE, 1) < 0) {
+			cg_log_func("failed to get cgroup path", ve, cgrp);
 			goto continue_free;
+		}
 
 		rcu_read_lock();
 		root_cgrp = cgroup_get_local_root(cgrp);
@@ -5512,8 +5526,10 @@ void cgroup_release_agent(struct work_struct *work)
 		if (release_agent)
 			agentbuf = kstrdup(release_agent, GFP_KERNEL);
 		rcu_read_unlock();
-		if (!agentbuf)
+		if (!agentbuf) {
+			cg_log_func("failed to allocate agentbuf\n", ve, cgrp);
 			goto continue_free;
+		}
 
 		i = 0;
 		argv[i++] = agentbuf;
-- 
1.8.3.1



More information about the Devel mailing list