From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Li Zefan <lizf@cn.fujitsu.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Aditya Kali <adityakali@google.com>,
Oleg Nesterov <oleg@redhat.com>
Subject: [PATCH 4/8] cgroups: New cancel_attach_task subsystem callback
Date: Fri, 29 Jul 2011 18:13:26 +0200 [thread overview]
Message-ID: <1311956010-32076-5-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1311956010-32076-1-git-send-email-fweisbec@gmail.com>
To cancel a process attachment on a subsystem, we only call the
cancel_attach() callback once on the leader but we have no
way to cancel the attachment individually for each member of
the process group.
This is going to be needed for the max number of tasks susbystem
that is coming.
To prepare for this integration, call a new cancel_attach_task()
callback on each task of the group until we reach the member that
failed to attach.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Paul Menage <menage@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Aditya Kali <adityakali@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
include/linux/cgroup.h | 1 +
kernel/cgroup.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e8288a0..94454143 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -472,6 +472,7 @@ struct cgroup_subsys {
struct task_struct *tsk);
void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
struct task_struct *tsk);
+ void (*cancel_attach_task)(struct cgroup *cgrp, struct task_struct *tsk);
void (*pre_attach)(struct cgroup *cgrp);
void (*attach_task)(struct cgroup *cgrp, struct cgroup *old_cgrp, struct task_struct *tsk);
void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c3ee4cf..210dc05 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1989,7 +1989,7 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
{
int retval, i, group_size;
struct cgroup_subsys *ss, *failed_ss = NULL;
- bool cancel_failed_ss = false;
+ struct task_struct *failed_task = NULL;
/* guaranteed to be initialized later, but the compiler needs this */
struct cgroup *oldcgrp = NULL;
struct css_set *oldcg;
@@ -2077,7 +2077,7 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
retval = ss->can_attach_task(cgrp, oldcgrp, tsk);
if (retval) {
failed_ss = ss;
- cancel_failed_ss = true;
+ failed_task = tsk;
goto out_cancel_attach;
}
}
@@ -2172,8 +2172,17 @@ out_cancel_attach:
/* same deal as in cgroup_attach_task */
if (retval) {
for_each_subsys(root, ss) {
+ if (ss->cancel_attach_task && (ss != failed_ss || failed_task)) {
+ for (i = 0; i < group_size; i++) {
+ tsk = flex_array_get_ptr(group, i);
+ if (tsk == failed_task)
+ break;
+ ss->cancel_attach_task(cgrp, tsk);
+ }
+ }
+
if (ss == failed_ss) {
- if (cancel_failed_ss && ss->cancel_attach)
+ if (failed_task && ss->cancel_attach)
ss->cancel_attach(ss, cgrp, leader);
break;
}
--
1.7.5.4
next prev parent reply other threads:[~2011-07-29 16:13 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-29 16:13 [PATCH 0/8 v3] cgroups: Task counter subsystem (was: New max number of tasks subsystem) Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 1/8] cgroups: Add res_counter_write_u64() API Frederic Weisbecker
2011-08-09 15:17 ` Oleg Nesterov
2011-08-09 17:31 ` Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 2/8] cgroups: New resource counter inheritance API Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 3/8] cgroups: Add previous cgroup in can_attach_task/attach_task callbacks Frederic Weisbecker
2011-08-17 2:40 ` Li Zefan
2011-08-27 13:58 ` Frederic Weisbecker
2011-07-29 16:13 ` Frederic Weisbecker [this message]
2011-08-17 2:40 ` [PATCH 4/8] cgroups: New cancel_attach_task subsystem callback Li Zefan
2011-08-27 13:58 ` Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 5/8] cgroups: Ability to stop res charge propagation on bounded ancestor Frederic Weisbecker
2011-08-17 2:41 ` Li Zefan
2011-08-27 13:59 ` Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 6/8] cgroups: Add res counter common ancestor searching Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 7/8] cgroups: Add a task counter subsystem Frederic Weisbecker
2011-08-01 23:13 ` Andrew Morton
2011-08-04 14:05 ` Frederic Weisbecker
2011-08-09 15:11 ` Oleg Nesterov
2011-08-09 17:27 ` Frederic Weisbecker
2011-08-09 17:57 ` Oleg Nesterov
2011-08-09 18:09 ` Frederic Weisbecker
2011-08-09 18:19 ` Oleg Nesterov
2011-08-09 18:34 ` Frederic Weisbecker
2011-08-09 18:39 ` Oleg Nesterov
2011-08-17 3:18 ` Li Zefan
2011-08-27 14:16 ` Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 8/8] res_counter: Allow charge failure pointer to be null Frederic Weisbecker
2011-08-17 2:44 ` Li Zefan
2011-08-27 14:05 ` Frederic Weisbecker
2011-08-01 23:19 ` [PATCH 0/8 v3] cgroups: Task counter subsystem (was: New max number of tasks subsystem) Andrew Morton
2011-08-03 14:29 ` Frederic Weisbecker
2011-08-12 21:11 ` Tim Hockin
2011-08-16 16:01 ` Kay Sievers
2011-08-18 14:33 ` [RFD] Task counter: cgroup core feature or cgroup subsystem? (was Re: [PATCH 0/8 v3] cgroups: Task counter subsystem) Frederic Weisbecker
2011-08-23 16:07 ` Paul Menage
2011-08-24 17:54 ` Frederic Weisbecker
2011-08-26 7:28 ` Li Zefan
2011-08-26 14:58 ` Paul Menage
2011-09-06 9:06 ` Li Zefan
2011-08-26 15:16 ` Paul Menage
2011-08-27 13:40 ` Frederic Weisbecker
2011-08-31 22:36 ` Paul Menage
2011-08-31 21:54 ` Frederic Weisbecker
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=1311956010-32076-5-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=adityakali@google.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=oleg@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome