[patch 2/2] cpu_cgroup: disallow attaching kthreadd

From: David Rientjes
Date: Thu Apr 05 2012 - 03:15:06 EST


From: Mike Galbraith <efault@xxxxxx>

An RT workqueue worker thread spawned in a cpu cgroup with no rt_runtime
allocated is not schedulable. Simple user error, but harmful to the box.
Save the user some unexpected trouble, just say no.

Acked-by: Paul Menage <paul@xxxxxxxxxxxxxx>
Signed-off-by: Mike Galbraith <efault@xxxxxx>
Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
---
kernel/sched/core.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -72,6 +72,7 @@
#include <linux/slab.h>
#include <linux/init_task.h>
#include <linux/binfmts.h>
+#include <linux/kthread.h>

#include <asm/switch_to.h>
#include <asm/tlb.h>
@@ -7636,6 +7637,13 @@ static int cpu_cgroup_can_attach(struct cgroup *cgrp,
if (task->sched_class != &fair_sched_class)
return -EINVAL;
#endif
+ /*
+ * Disallow kthreadd since it can fork workers for an RT
+ * workqueue in a cgroup which may or may not have rt_runtime
+ * allocated.
+ */
+ if (task == kthreadd_task)
+ return -EINVAL;
}
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/