From: Li Zefan <lizf@cn.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
Mike Travis <travis@sgi.com>, Paul Menage <menage@google.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/6] cpuset: remove on stack cpumask_t in cpuset_can_attach()
Date: Wed, 31 Dec 2008 16:35:51 +0800 [thread overview]
Message-ID: <495B2EE7.4040406@cn.fujitsu.com> (raw)
In-Reply-To: <495B2EC2.9090305@cn.fujitsu.com>
Impact: redue stack usage
Just use cs->cpus_allowed, and no need to allocate a cpumask_var_t.
Signed-off-by: Li Zefan <lizf@cn.fujistu.com>
---
kernel/cpuset.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 41c2343..afa29cf 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1311,20 +1311,19 @@ static int cpuset_can_attach(struct cgroup_subsys *ss,
struct cgroup *cont, struct task_struct *tsk)
{
struct cpuset *cs = cgroup_cs(cont);
+ int ret = 0;
if (cpus_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
return -ENOSPC;
- if (tsk->flags & PF_THREAD_BOUND) {
- cpumask_t mask;
+ if (tsk->flags & PF_THREAD_BOUND) {
mutex_lock(&callback_mutex);
- mask = cs->cpus_allowed;
+ if (!cpus_equal(tsk->cpus_allowed, cs->cpus_allowed))
+ ret = -EINVAL;
mutex_unlock(&callback_mutex);
- if (!cpus_equal(tsk->cpus_allowed, mask))
- return -EINVAL;
}
- return security_task_setscheduler(tsk, 0, NULL);
+ return ret < 0 ? ret : security_task_setscheduler(tsk, 0, NULL);
}
static void cpuset_attach(struct cgroup_subsys *ss,
--
1.5.4.rc3
next prev parent reply other threads:[~2008-12-31 8:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-31 8:34 [PATCH 0/6] cpuset: convert to new cpumask API Li Zefan
2008-12-31 8:35 ` [PATCH 1/6] cpuset: remove on stack cpumask_t in cpuset_sprintf_cpulist() Li Zefan
2008-12-31 8:35 ` Li Zefan [this message]
2008-12-31 8:36 ` [PATCH 3/6] cpuset: convert cpuset_attach() to use cpumask_var_t Li Zefan
2008-12-31 8:36 ` [PATCH 4/6] cpuset: don't allocate trial cpuset on stack Li Zefan
2008-12-31 8:37 ` [PATCH 5/6] cpuset: convert cpuset->cpus_allowed to cpumask_var_t Li Zefan
2008-12-31 8:37 ` [PATCH 6/6] cpuset: remove remaining pointers to cpumask_t Li Zefan
2009-01-05 7:46 ` [PATCH 4/6] cpuset: don't allocate trial cpuset on stack Andrew Morton
2009-01-05 9:13 ` Li Zefan
2009-01-05 7:38 ` [PATCH 3/6] cpuset: convert cpuset_attach() to use cpumask_var_t Andrew Morton
2009-01-05 8:47 ` Li Zefan
2009-01-05 9:01 ` Andrew Morton
2009-01-05 9:04 ` Li Zefan
2009-01-05 9:14 ` Andrew Morton
2009-01-05 9:21 ` Li Zefan
2009-01-07 2:04 ` Rusty Russell
2009-01-07 16:39 ` Paul Menage
2008-12-31 11:56 ` [PATCH 0/6] cpuset: convert to new cpumask API Mike Travis
2008-12-31 13:26 ` Rusty Russell
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=495B2EE7.4040406@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=travis@sgi.com \
/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.