Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105888
b: refs/heads/master
c: 71cbb94
h: refs/heads/master
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Jul 25, 2008
1 parent 784d34f commit ee86026
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f2992db2a4f7ae10f61d5bc68c7c1528cec639e2
refs/heads/master: 71cbb949d17d4d776abd547135feb7f3282405c8
44 changes: 21 additions & 23 deletions trunk/kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,20 @@ static int use_task_css_set_links;
*/
static void unlink_css_set(struct css_set *cg)
{
struct cg_cgroup_link *link;
struct cg_cgroup_link *saved_link;

write_lock(&css_set_lock);
hlist_del(&cg->hlist);
css_set_count--;
while (!list_empty(&cg->cg_links)) {
struct cg_cgroup_link *link;
link = list_entry(cg->cg_links.next,
struct cg_cgroup_link, cg_link_list);

list_for_each_entry_safe(link, saved_link, &cg->cg_links,
cg_link_list) {
list_del(&link->cg_link_list);
list_del(&link->cgrp_link_list);
kfree(link);
}

write_unlock(&css_set_lock);
}

Expand Down Expand Up @@ -363,15 +366,14 @@ static struct css_set *find_existing_css_set(
static int allocate_cg_links(int count, struct list_head *tmp)
{
struct cg_cgroup_link *link;
struct cg_cgroup_link *saved_link;
int i;
INIT_LIST_HEAD(tmp);
for (i = 0; i < count; i++) {
link = kmalloc(sizeof(*link), GFP_KERNEL);
if (!link) {
while (!list_empty(tmp)) {
link = list_entry(tmp->next,
struct cg_cgroup_link,
cgrp_link_list);
list_for_each_entry_safe(link, saved_link, tmp,
cgrp_link_list) {
list_del(&link->cgrp_link_list);
kfree(link);
}
Expand All @@ -384,11 +386,10 @@ static int allocate_cg_links(int count, struct list_head *tmp)

static void free_cg_links(struct list_head *tmp)
{
while (!list_empty(tmp)) {
struct cg_cgroup_link *link;
link = list_entry(tmp->next,
struct cg_cgroup_link,
cgrp_link_list);
struct cg_cgroup_link *link;
struct cg_cgroup_link *saved_link;

list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) {
list_del(&link->cgrp_link_list);
kfree(link);
}
Expand Down Expand Up @@ -1093,6 +1094,8 @@ static void cgroup_kill_sb(struct super_block *sb) {
struct cgroupfs_root *root = sb->s_fs_info;
struct cgroup *cgrp = &root->top_cgroup;
int ret;
struct cg_cgroup_link *link;
struct cg_cgroup_link *saved_link;

BUG_ON(!root);

Expand All @@ -1112,10 +1115,9 @@ static void cgroup_kill_sb(struct super_block *sb) {
* root cgroup
*/
write_lock(&css_set_lock);
while (!list_empty(&cgrp->css_sets)) {
struct cg_cgroup_link *link;
link = list_entry(cgrp->css_sets.next,
struct cg_cgroup_link, cgrp_link_list);

list_for_each_entry_safe(link, saved_link, &cgrp->css_sets,
cgrp_link_list) {
list_del(&link->cg_link_list);
list_del(&link->cgrp_link_list);
kfree(link);
Expand Down Expand Up @@ -1756,15 +1758,11 @@ int cgroup_add_files(struct cgroup *cgrp,
int cgroup_task_count(const struct cgroup *cgrp)
{
int count = 0;
struct list_head *l;
struct cg_cgroup_link *link;

read_lock(&css_set_lock);
l = cgrp->css_sets.next;
while (l != &cgrp->css_sets) {
struct cg_cgroup_link *link =
list_entry(l, struct cg_cgroup_link, cgrp_link_list);
list_for_each_entry(link, &cgrp->css_sets, cgrp_link_list) {
count += atomic_read(&link->cg->ref.refcount);
l = l->next;
}
read_unlock(&css_set_lock);
return count;
Expand Down

0 comments on commit ee86026

Please sign in to comment.