From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753511Ab2DUGzO (ORCPT ); Sat, 21 Apr 2012 02:55:14 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:51765 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022Ab2DUGzM (ORCPT ); Sat, 21 Apr 2012 02:55:12 -0400 Date: Sat, 21 Apr 2012 14:54:58 +0800 From: Li Zefan Subject: Re: [patch] cgroups: disallow attaching kthreadd In-reply-to: <1334986264.5428.1.camel@marge.simpson.net> X-Originating-IP: [10.166.88.147] To: Mike Galbraith Cc: Tejun Heo , Peter Zijlstra , Li Zefan , David Rientjes , Paul Menage , LKML , Thomas Gleixner Message-id: <4F9259C2.9040305@huawei.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7BIT User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 X-CFilter-Loop: Reflected References: <1333475906.7439.7.camel@marge.simpson.net> <20120420175751.GF32324@google.com> <1334986264.5428.1.camel@marge.simpson.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mike Galbraith wrote: > On Fri, 2012-04-20 at 10:57 -0700, Tejun Heo wrote: >> Hello, Mike. >> >> This is dragging out too long but can you please update the patch so >> that both kthreadd and PF_THREAD_BOUND tasks are disallowed from !root >> cgroups? > > cgroups: disallow attaching kthreadd or PF_THREAD_BOUND threads > > Allowing kthreadd to be moved to a non-root group makes no sense, it being > a global resource, and needlessly leads unsuspecting users toward trouble. > > 1. An RT workqueue worker thread spawned in a task group with no rt_runtime > allocated is not schedulable. Simple user error, but harmful to the box. > > 2. A worker thread which acquires PF_THREAD_BOUND can never leave a cpuset, > rendering the cpuset immortal. > > Save the user some unexpected trouble, just say no. > > Signed-off-by: Mike Galbraith > Acked-by: Peter Zijlstra > Acked-by: Thomas Gleixner > --- > kernel/cgroup.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > --- a/kernel/cgroup.c > +++ b/kernel/cgroup.c > @@ -60,6 +60,7 @@ > #include > #include > #include /* used in cgroup_attach_proc */ > +#include > > #include > > @@ -2172,6 +2173,17 @@ static int attach_task_by_pid(struct cgr > > if (threadgroup) > tsk = tsk->group_leader; > + > + /* > + * Workqueue threads may acquire PF_THREAD_BOUND and become > + * trapped in a cpuset, or RT worker may be born in a cgroup > + * with no rt_runtime allocated. Just say no. > + */ > + if (tsk == kthreadd_task || (tsk->flags & PF_THREAD_BOUND)) { > + ret = -EINVAL; > + goto out_unlock_cgroup; forgot rcu_read_unlock() ? Otherwise Acked-by: Li Zefan > + } > + > get_task_struct(tsk); > rcu_read_unlock();