From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934881AbbLQP5l (ORCPT ); Thu, 17 Dec 2015 10:57:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42946 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751527AbbLQP5j (ORCPT ); Thu, 17 Dec 2015 10:57:39 -0500 Date: Thu, 17 Dec 2015 13:56:46 -0200 From: Marcelo Tosatti To: linux-kernel@vger.kernel.org, Tejun Heo , Luiz Capitulino Cc: Chao Peng , Vikas Shivappa Subject: [PATCH v3] cgroups: move cpuset specific checks from generic code to cpuset_can_attach Message-ID: <20151217155645.GA31625@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move PF_NO_SETAFFINITY check to cpuset cgroups, where it belongs. This makes it possible to attach PF_NO_SETAFFINITY to Intel CAT cgroups. Reported-by: Luiz Capitulino Signed-off-by: Marcelo Tosatti v2: "PF_NO_SETAFFINITY check" -> "PF_NO_SETAFFINITY and kthreadd_task checks" v3: keep kthreadd_task check for all cgroup controllers diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 470f653..66a1c32 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2740,11 +2740,10 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, tsk = tsk->group_leader; /* - * Workqueue threads may acquire PF_NO_SETAFFINITY and become - * trapped in a cpuset, or RT worker may be born in a cgroup - * with no rt_runtime allocated. Just say no. + * RT worker may be born in a cgroup with no + * rt_runtime allocated. Just say no. */ - if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY)) { + if (tsk == kthreadd_task) { ret = -EINVAL; goto out_unlock_rcu; } diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 02a8ea5..67756bc 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -1449,6 +1450,14 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) goto out_unlock; cgroup_taskset_for_each(task, css, tset) { + /* + * Workqueue threads may acquire PF_NO_SETAFFINITY and + * become trapped in a cpuset. + */ + if (task->flags & PF_NO_SETAFFINITY) { + ret = -EINVAL; + goto out_unlock; + } ret = task_can_attach(task, cs->cpus_allowed); if (ret) goto out_unlock;