Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350326
b: refs/heads/master
c: ace783b
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan authored and Tejun Heo committed Jan 24, 2013
1 parent fc13ab7 commit 64bfd70
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 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: fe1c06ca7523baa668c1eaf1e1016fa64753c32e
refs/heads/master: ace783b9bbfa2182b4a561498db3f09a0c56bc79
3 changes: 3 additions & 0 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,10 @@ extern void normalize_rt_tasks(void);
extern struct task_group root_task_group;

extern struct task_group *sched_create_group(struct task_group *parent);
extern void sched_online_group(struct task_group *tg,
struct task_group *parent);
extern void sched_destroy_group(struct task_group *tg);
extern void sched_offline_group(struct task_group *tg);
extern void sched_move_task(struct task_struct *tsk);
#ifdef CONFIG_FAIR_GROUP_SCHED
extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
Expand Down
3 changes: 3 additions & 0 deletions trunk/kernel/sched/auto_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static inline void autogroup_destroy(struct kref *kref)
ag->tg->rt_se = NULL;
ag->tg->rt_rq = NULL;
#endif
sched_offline_group(ag->tg);
sched_destroy_group(ag->tg);
}

Expand Down Expand Up @@ -76,6 +77,8 @@ static inline struct autogroup *autogroup_create(void)
if (IS_ERR(tg))
goto out_free;

sched_online_group(tg, &root_task_group);

kref_init(&ag->kref);
init_rwsem(&ag->lock);
ag->id = atomic_inc_return(&autogroup_seq_nr);
Expand Down
49 changes: 39 additions & 10 deletions trunk/kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7159,7 +7159,6 @@ static void free_sched_group(struct task_group *tg)
struct task_group *sched_create_group(struct task_group *parent)
{
struct task_group *tg;
unsigned long flags;

tg = kzalloc(sizeof(*tg), GFP_KERNEL);
if (!tg)
Expand All @@ -7171,6 +7170,17 @@ struct task_group *sched_create_group(struct task_group *parent)
if (!alloc_rt_sched_group(tg, parent))
goto err;

return tg;

err:
free_sched_group(tg);
return ERR_PTR(-ENOMEM);
}

void sched_online_group(struct task_group *tg, struct task_group *parent)
{
unsigned long flags;

spin_lock_irqsave(&task_group_lock, flags);
list_add_rcu(&tg->list, &task_groups);

Expand All @@ -7180,12 +7190,6 @@ struct task_group *sched_create_group(struct task_group *parent)
INIT_LIST_HEAD(&tg->children);
list_add_rcu(&tg->siblings, &parent->children);
spin_unlock_irqrestore(&task_group_lock, flags);

return tg;

err:
free_sched_group(tg);
return ERR_PTR(-ENOMEM);
}

/* rcu callback to free various structures associated with a task group */
Expand All @@ -7197,6 +7201,12 @@ static void free_sched_group_rcu(struct rcu_head *rhp)

/* Destroy runqueue etc associated with a task group */
void sched_destroy_group(struct task_group *tg)
{
/* wait for possible concurrent references to cfs_rqs complete */
call_rcu(&tg->rcu, free_sched_group_rcu);
}

void sched_offline_group(struct task_group *tg)
{
unsigned long flags;
int i;
Expand All @@ -7209,9 +7219,6 @@ void sched_destroy_group(struct task_group *tg)
list_del_rcu(&tg->list);
list_del_rcu(&tg->siblings);
spin_unlock_irqrestore(&task_group_lock, flags);

/* wait for possible concurrent references to cfs_rqs complete */
call_rcu(&tg->rcu, free_sched_group_rcu);
}

/* change task's runqueue when it moves between groups.
Expand Down Expand Up @@ -7563,13 +7570,33 @@ static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp)
return &tg->css;
}

static int cpu_cgroup_css_online(struct cgroup *cgrp)
{
struct task_group *tg = cgroup_tg(cgrp);
struct task_group *parent;

if (!cgrp->parent)
return 0;

parent = cgroup_tg(cgrp->parent);
sched_online_group(tg, parent);
return 0;
}

static void cpu_cgroup_css_free(struct cgroup *cgrp)
{
struct task_group *tg = cgroup_tg(cgrp);

sched_destroy_group(tg);
}

static void cpu_cgroup_css_offline(struct cgroup *cgrp)
{
struct task_group *tg = cgroup_tg(cgrp);

sched_offline_group(tg);
}

static int cpu_cgroup_can_attach(struct cgroup *cgrp,
struct cgroup_taskset *tset)
{
Expand Down Expand Up @@ -7925,6 +7952,8 @@ struct cgroup_subsys cpu_cgroup_subsys = {
.name = "cpu",
.css_alloc = cpu_cgroup_css_alloc,
.css_free = cpu_cgroup_css_free,
.css_online = cpu_cgroup_css_online,
.css_offline = cpu_cgroup_css_offline,
.can_attach = cpu_cgroup_can_attach,
.attach = cpu_cgroup_attach,
.exit = cpu_cgroup_exit,
Expand Down

0 comments on commit 64bfd70

Please sign in to comment.