From: Roman Gushchin <guro@fb.com>
To: <linux-kernel@vger.kernel.org>
Cc: Roman Gushchin <guro@fb.com>, Tejun Heo <tj@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>, Chris Mason <clm@fb.com>,
<kernel-team@fb.com>
Subject: [RFC 1/2] cgroup, kthread: do not allow moving kthreads out of the root cgroup
Date: Thu, 12 Oct 2017 18:37:22 +0100 [thread overview]
Message-ID: <20171012173723.13381-1-guro@fb.com> (raw)
Attaching kernel threads to a non-root cgroup is generally a bad
idea. Kernel threads are generally performing the work required
to keep the system working and healthy, and applying various
resource limits may affect system stability and performance.
Some examples of dangerous behavior are limiting CPU time available
to rcu stuff, memory limits applied to almost all kthreads, etc.
To prevent this dangerous behavior, let's deny all kthread
movements between cgroups. Right now only kthreads bounded
to CPUs are not allowed to move, which is not sufficient.
If there are examples of kthreads which can be limited,
and it's guaranteed to be safe, we can allow explicit
exceptions further.
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Mason <clm@fb.com>
Cc: kernel-team@fb.com
Cc: linux-kernel@vger.kernel.org
---
kernel/cgroup/cgroup.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index c7086c8835da..a3d7a1b5720d 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2629,12 +2629,12 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup)
tsk = tsk->group_leader;
/*
- * kthreads may acquire PF_NO_SETAFFINITY during initialization.
- * If userland migrates such a kthread to a non-root cgroup, it can
+ * If userland migrates a kthread to a non-root cgroup, it can
* become trapped in a cpuset, or RT kthread may be born in a
- * cgroup with no rt_runtime allocated. Just say no.
+ * cgroup with no rt_runtime allocated, or it can suffer from
+ * memory shortage, etc. Just say no.
*/
- if (tsk->no_cgroup_migration || (tsk->flags & PF_NO_SETAFFINITY)) {
+ if (tsk->flags & (PF_KTHREAD | PF_NO_SETAFFINITY)) {
tsk = ERR_PTR(-EINVAL);
goto out_unlock_threadgroup;
}
--
2.13.6
next reply other threads:[~2017-10-12 17:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-12 17:37 Roman Gushchin [this message]
2017-10-12 17:37 ` [RFC 2/2] cgroup, kthread: cleanup after sticking kthreads to the root cgroup Roman Gushchin
2017-10-12 19:24 ` [RFC 1/2] cgroup, kthread: do not allow moving kthreads out of " Peter Zijlstra
2017-10-12 21:47 ` Roman Gushchin
2017-10-12 21:57 ` David Rientjes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171012173723.13381-1-guro@fb.com \
--to=guro@fb.com \
--cc=akpm@linux-foundation.org \
--cc=clm@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.