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

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Wed Apr 1 18:41:28 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 b2fa6a2..ba2e849 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -193,6 +193,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
@@ -2359,6 +2365,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);
@@ -5558,6 +5567,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;
 	}
@@ -5578,10 +5588,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);
@@ -5589,8 +5603,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