sched: uninline scheduler
[deliverable/linux.git] / kernel / sched.c
index 3b104635a8eafb4b9ef6664e8898606595405010..ce9bb7aa7c122f8fcaf716734809febcaaa6a792 100644 (file)
@@ -173,13 +173,10 @@ struct rt_prio_array {
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 
-#include <linux/container.h>
-
 struct cfs_rq;
 
 /* task group related information */
 struct task_grp {
-       struct container_subsys_state css;
        /* schedulable entities of this group on each cpu */
        struct sched_entity **se;
        /* runqueue "owned" by this group on each cpu */
@@ -192,22 +189,37 @@ static DEFINE_PER_CPU(struct sched_entity, init_sched_entity);
 /* Default task group's cfs_rq on each cpu */
 static DEFINE_PER_CPU(struct cfs_rq, init_cfs_rq) ____cacheline_aligned_in_smp;
 
-static struct sched_entity *init_sched_entity_p[CONFIG_NR_CPUS];
-static struct cfs_rq *init_cfs_rq_p[CONFIG_NR_CPUS];
+static struct sched_entity *init_sched_entity_p[NR_CPUS];
+static struct cfs_rq *init_cfs_rq_p[NR_CPUS];
 
 /* Default task group.
- *     Every task in system belong to this group at bootup.
+ *     Every task in system belong to this group at bootup.
  */
-static struct task_grp init_task_grp =  {
-                                       .se     = init_sched_entity_p,
-                                       .cfs_rq = init_cfs_rq_p,
-                                       };
+struct task_grp init_task_grp = {
+       .se     = init_sched_entity_p,
+       .cfs_rq = init_cfs_rq_p,
+};
+
+#ifdef CONFIG_FAIR_USER_SCHED
+# define INIT_TASK_GRP_LOAD    2*NICE_0_LOAD
+#else
+# define INIT_TASK_GRP_LOAD    NICE_0_LOAD
+#endif
+
+static int init_task_grp_load = INIT_TASK_GRP_LOAD;
 
 /* return group to which a task belongs */
 static inline struct task_grp *task_grp(struct task_struct *p)
 {
-       return container_of(task_subsys_state(p, cpu_subsys_id),
-                               struct task_grp, css);
+       struct task_grp *tg;
+
+#ifdef CONFIG_FAIR_USER_SCHED
+       tg = p->user->tg;
+#else
+       tg  = &init_task_grp;
+#endif
+
+       return tg;
 }
 
 /* Change a task's cfs_rq and parent entity if it moves across CPUs/groups */
@@ -238,6 +250,9 @@ struct cfs_rq {
         * It is set to NULL otherwise (i.e when none are currently running).
         */
        struct sched_entity *curr;
+
+       unsigned long nr_spread_over;
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
        struct rq *rq;  /* cpu runqueue to which this cfs_rq is attached */
 
@@ -250,6 +265,7 @@ struct cfs_rq {
         */
        struct list_head leaf_cfs_rq_list; /* Better name : task_cfs_rq_list? */
        struct task_grp *tg;    /* group that "owns" this runqueue */
+       struct rcu_head rcu;
 #endif
 };
 
@@ -333,16 +349,19 @@ struct rq {
        unsigned long yld_exp_empty;
        unsigned long yld_act_empty;
        unsigned long yld_both_empty;
-       unsigned long yld_cnt;
+       unsigned long yld_count;
 
        /* schedule() stats */
        unsigned long sched_switch;
-       unsigned long sched_cnt;
+       unsigned long sched_count;
        unsigned long sched_goidle;
 
        /* try_to_wake_up() stats */
-       unsigned long ttwu_cnt;
+       unsigned long ttwu_count;
        unsigned long ttwu_local;
+
+       /* BKL stats */
+       unsigned long bkl_count;
 #endif
        struct lock_class_key rq_lock_key;
 };
@@ -589,7 +608,7 @@ repeat_lock_task:
        return rq;
 }
 
-static inline void __task_rq_unlock(struct rq *rq)
+static void __task_rq_unlock(struct rq *rq)
        __releases(rq->lock)
 {
        spin_unlock(&rq->lock);
@@ -604,7 +623,7 @@ static inline void task_rq_unlock(struct rq *rq, unsigned long *flags)
 /*
  * this_rq_lock - lock this runqueue and disable interrupts.
  */
-static inline struct rq *this_rq_lock(void)
+static struct rq *this_rq_lock(void)
        __acquires(rq->lock)
 {
        struct rq *rq;
@@ -828,9 +847,9 @@ static int balance_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
                      int *this_best_prio, struct rq_iterator *iterator);
 
 #include "sched_stats.h"
-#include "sched_rt.c"
-#include "sched_fair.c"
 #include "sched_idletask.c"
+#include "sched_fair.c"
+#include "sched_rt.c"
 #ifdef CONFIG_SCHED_DEBUG
 # include "sched_debug.c"
 #endif
@@ -966,20 +985,6 @@ static void activate_task(struct rq *rq, struct task_struct *p, int wakeup)
        inc_nr_running(p, rq);
 }
 
-/*
- * activate_idle_task - move idle task to the _front_ of runqueue.
- */
-static inline void activate_idle_task(struct task_struct *p, struct rq *rq)
-{
-       update_rq_clock(rq);
-
-       if (p->state == TASK_UNINTERRUPTIBLE)
-               rq->nr_uninterruptible--;
-
-       enqueue_task(rq, p, 0);
-       inc_nr_running(p, rq);
-}
-
 /*
  * deactivate_task - remove a task from the runqueue.
  */
@@ -1021,6 +1026,8 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 {
        int old_cpu = task_cpu(p);
        struct rq *old_rq = cpu_rq(old_cpu), *new_rq = cpu_rq(new_cpu);
+       struct cfs_rq *old_cfsrq = task_cfs_rq(p),
+                     *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu);
        u64 clock_offset;
 
        clock_offset = old_rq->clock - new_rq->clock;
@@ -1033,9 +1040,8 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
        if (p->se.block_start)
                p->se.block_start -= clock_offset;
 #endif
-       if (likely(new_rq->cfs.min_vruntime))
-               p->se.vruntime -= old_rq->cfs.min_vruntime -
-                                               new_rq->cfs.min_vruntime;
+       p->se.vruntime -= old_cfsrq->min_vruntime -
+                                        new_cfsrq->min_vruntime;
 
        __set_task_cpu(p, new_cpu);
 }
@@ -1186,7 +1192,7 @@ void kick_process(struct task_struct *p)
  * We want to under-estimate the load of migration sources, to
  * balance conservatively.
  */
-static inline unsigned long source_load(int cpu, int type)
+static unsigned long source_load(int cpu, int type)
 {
        struct rq *rq = cpu_rq(cpu);
        unsigned long total = weighted_cpuload(cpu);
@@ -1201,7 +1207,7 @@ static inline unsigned long source_load(int cpu, int type)
  * Return a high guess at the load of a migration-target cpu weighted
  * according to the scheduling class and "nice" value.
  */
-static inline unsigned long target_load(int cpu, int type)
+static unsigned long target_load(int cpu, int type)
 {
        struct rq *rq = cpu_rq(cpu);
        unsigned long total = weighted_cpuload(cpu);
@@ -1464,7 +1470,7 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
 
        new_cpu = cpu;
 
-       schedstat_inc(rq, ttwu_cnt);
+       schedstat_inc(rq, ttwu_count);
        if (cpu == this_cpu) {
                schedstat_inc(rq, ttwu_local);
                goto out_set_cpu;
@@ -1640,12 +1646,14 @@ void sched_fork(struct task_struct *p, int clone_flags)
 #ifdef CONFIG_SMP
        cpu = sched_balance_self(cpu, SD_BALANCE_FORK);
 #endif
-       __set_task_cpu(p, cpu);
+       set_task_cpu(p, cpu);
 
        /*
         * Make sure we do not leak PI boosting priority to the child:
         */
        p->prio = current->normal_prio;
+       if (!rt_prio(p->prio))
+               p->sched_class = &fair_sched_class;
 
 #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
        if (likely(sched_info_on()))
@@ -1681,11 +1689,6 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
 
        p->prio = effective_prio(p);
 
-       if (rt_prio(p->prio))
-               p->sched_class = &rt_sched_class;
-       else
-               p->sched_class = &fair_sched_class;
-
        if (task_cpu(p) != this_cpu || !p->sched_class->task_new ||
                                                        !current->se.on_rq) {
                activate_task(rq, p, 0);
@@ -1796,7 +1799,7 @@ prepare_task_switch(struct rq *rq, struct task_struct *prev,
  * with the lock held can cause deadlocks; see schedule() for
  * details.)
  */
-static inline void finish_task_switch(struct rq *rq, struct task_struct *prev)
+static void finish_task_switch(struct rq *rq, struct task_struct *prev)
        __releases(rq->lock)
 {
        struct mm_struct *mm = rq->prev_mm;
@@ -2234,7 +2237,7 @@ static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
                      struct sched_domain *sd, enum cpu_idle_type idle,
                      int *all_pinned)
 {
-       struct sched_class *class = sched_class_highest;
+       const struct sched_class *class = sched_class_highest;
        unsigned long total_load_moved = 0;
        int this_best_prio = this_rq->curr->prio;
 
@@ -2259,7 +2262,7 @@ static int move_tasks(struct rq *this_rq, int this_cpu, struct rq *busiest,
 static int move_one_task(struct rq *this_rq, int this_cpu, struct rq *busiest,
                         struct sched_domain *sd, enum cpu_idle_type idle)
 {
-       struct sched_class *class;
+       const struct sched_class *class;
        int this_best_prio = MAX_PRIO;
 
        for (class = sched_class_highest; class; class = class->next)
@@ -2623,7 +2626,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
            !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
                sd_idle = 1;
 
-       schedstat_inc(sd, lb_cnt[idle]);
+       schedstat_inc(sd, lb_count[idle]);
 
 redo:
        group = find_busiest_group(sd, this_cpu, &imbalance, idle, &sd_idle,
@@ -2776,7 +2779,7 @@ load_balance_newidle(int this_cpu, struct rq *this_rq, struct sched_domain *sd)
            !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
                sd_idle = 1;
 
-       schedstat_inc(sd, lb_cnt[CPU_NEWLY_IDLE]);
+       schedstat_inc(sd, lb_count[CPU_NEWLY_IDLE]);
 redo:
        group = find_busiest_group(sd, this_cpu, &imbalance, CPU_NEWLY_IDLE,
                                   &sd_idle, &cpus, NULL);
@@ -2910,7 +2913,7 @@ static void active_load_balance(struct rq *busiest_rq, int busiest_cpu)
        }
 
        if (likely(sd)) {
-               schedstat_inc(sd, alb_cnt);
+               schedstat_inc(sd, alb_count);
 
                if (move_one_task(target_rq, target_cpu, busiest_rq,
                                  sd, CPU_IDLE))
@@ -3003,7 +3006,7 @@ static DEFINE_SPINLOCK(balancing);
  *
  * Balancing parameters are set up in arch_init_sched_domains.
  */
-static inline void rebalance_domains(int cpu, enum cpu_idle_type idle)
+static void rebalance_domains(int cpu, enum cpu_idle_type idle)
 {
        int balance = 1;
        struct rq *rq = cpu_rq(cpu);
@@ -3400,7 +3403,13 @@ static inline void schedule_debug(struct task_struct *prev)
 
        profile_hit(SCHED_PROFILING, __builtin_return_address(0));
 
-       schedstat_inc(this_rq(), sched_cnt);
+       schedstat_inc(this_rq(), sched_count);
+#ifdef CONFIG_SCHEDSTATS
+       if (unlikely(prev->lock_depth >= 0)) {
+               schedstat_inc(this_rq(), bkl_count);
+               schedstat_inc(prev, sched_info.bkl_count);
+       }
+#endif
 }
 
 /*
@@ -3409,7 +3418,7 @@ static inline void schedule_debug(struct task_struct *prev)
 static inline struct task_struct *
 pick_next_task(struct rq *rq, struct task_struct *prev)
 {
-       struct sched_class *class;
+       const struct sched_class *class;
        struct task_struct *p;
 
        /*
@@ -3458,9 +3467,13 @@ need_resched_nonpreemptible:
 
        schedule_debug(prev);
 
-       spin_lock_irq(&rq->lock);
-       clear_tsk_need_resched(prev);
+       /*
+        * Do the rq-clock update outside the rq lock:
+        */
+       local_irq_disable();
        __update_rq_clock(rq);
+       spin_lock(&rq->lock);
+       clear_tsk_need_resched(prev);
 
        if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
                if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
@@ -3915,8 +3928,8 @@ EXPORT_SYMBOL(sleep_on_timeout);
  */
 void rt_mutex_setprio(struct task_struct *p, int prio)
 {
-       int oldprio, on_rq, running;
        unsigned long flags;
+       int oldprio, on_rq, running;
        struct rq *rq;
 
        BUG_ON(prio < 0 || prio > MAX_PRIO);
@@ -4113,7 +4126,7 @@ struct task_struct *idle_task(int cpu)
  * find_process_by_pid - find a process with a matching PID value.
  * @pid: the pid in question.
  */
-static inline struct task_struct *find_process_by_pid(pid_t pid)
+static struct task_struct *find_process_by_pid(pid_t pid)
 {
        return pid ? find_task_by_pid(pid) : current;
 }
@@ -4243,8 +4256,10 @@ recheck:
                if (running)
                        p->sched_class->put_prev_task(rq, p);
        }
+
        oldprio = p->prio;
        __setscheduler(rq, p, policy, param->sched_priority);
+
        if (on_rq) {
                if (running)
                        p->sched_class->set_curr_task(rq);
@@ -4536,8 +4551,8 @@ asmlinkage long sys_sched_yield(void)
 {
        struct rq *rq = this_rq_lock();
 
-       schedstat_inc(rq, yld_cnt);
-       current->sched_class->yield_task(rq, current);
+       schedstat_inc(rq, yld_count);
+       current->sched_class->yield_task(rq);
 
        /*
         * Since we are going to call schedule() anyway, there's
@@ -5127,6 +5142,20 @@ static void migrate_live_tasks(int src_cpu)
        write_unlock_irq(&tasklist_lock);
 }
 
+/*
+ * activate_idle_task - move idle task to the _front_ of runqueue.
+ */
+static void activate_idle_task(struct task_struct *p, struct rq *rq)
+{
+       update_rq_clock(rq);
+
+       if (p->state == TASK_UNINTERRUPTIBLE)
+               rq->nr_uninterruptible--;
+
+       enqueue_task(rq, p, 0);
+       inc_nr_running(p, rq);
+}
+
 /*
  * Schedules idle task to be the next runnable task on current CPU.
  * It does so by boosting its priority to highest possible and adding it to
@@ -6465,12 +6494,13 @@ int in_sched_functions(unsigned long addr)
                && addr < (unsigned long)__sched_text_end);
 }
 
-static inline void init_cfs_rq(struct cfs_rq *cfs_rq, struct rq *rq)
+static void init_cfs_rq(struct cfs_rq *cfs_rq, struct rq *rq)
 {
        cfs_rq->tasks_timeline = RB_ROOT;
 #ifdef CONFIG_FAIR_GROUP_SCHED
        cfs_rq->rq = rq;
 #endif
+       cfs_rq->min_vruntime = (u64)(-(1LL << 20));
 }
 
 void __init sched_init(void)
@@ -6478,13 +6508,6 @@ void __init sched_init(void)
        int highest_cpu = 0;
        int i, j;
 
-       /*
-        * Link up the scheduling class hierarchy:
-        */
-       rt_sched_class.next = &fair_sched_class;
-       fair_sched_class.next = &idle_sched_class;
-       idle_sched_class.next = NULL;
-
        for_each_possible_cpu(i) {
                struct rt_prio_array *array;
                struct rq *rq;
@@ -6497,25 +6520,26 @@ void __init sched_init(void)
                init_cfs_rq(&rq->cfs, rq);
 #ifdef CONFIG_FAIR_GROUP_SCHED
                INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
-               {
-                       struct cfs_rq *cfs_rq = &per_cpu(init_cfs_rq, i);
-                       struct sched_entity *se =
-                                        &per_cpu(init_sched_entity, i);
-
-                       init_cfs_rq_p[i] = cfs_rq;
-                       init_cfs_rq(cfs_rq, rq);
-                       cfs_rq->tg = &init_task_grp;
-                       list_add(&cfs_rq->leaf_cfs_rq_list,
+               {
+                       struct cfs_rq *cfs_rq = &per_cpu(init_cfs_rq, i);
+                       struct sched_entity *se =
+                                        &per_cpu(init_sched_entity, i);
+
+                       init_cfs_rq_p[i] = cfs_rq;
+                       init_cfs_rq(cfs_rq, rq);
+                       cfs_rq->tg = &init_task_grp;
+                       list_add(&cfs_rq->leaf_cfs_rq_list,
                                                         &rq->leaf_cfs_rq_list);
 
-                       init_sched_entity_p[i] = se;
-                       se->cfs_rq = &rq->cfs;
-                       se->my_q = cfs_rq;
-                       se->load.weight = NICE_0_LOAD;
-                       se->load.inv_weight = div64_64(1ULL<<32, NICE_0_LOAD);
-                       se->parent = NULL;
-               }
-               init_task_grp.shares = NICE_0_LOAD;
+                       init_sched_entity_p[i] = se;
+                       se->cfs_rq = &rq->cfs;
+                       se->my_q = cfs_rq;
+                       se->load.weight = init_task_grp_load;
+                       se->load.inv_weight =
+                                div64_64(1ULL<<32, init_task_grp_load);
+                       se->parent = NULL;
+               }
+               init_task_grp.shares = init_task_grp_load;
 #endif
 
                for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
@@ -6705,45 +6729,28 @@ void set_curr_task(int cpu, struct task_struct *p)
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
 
-/* return corresponding task_grp object of a container */
-static inline struct task_grp *container_tg(struct container *cont)
-{
-       return container_of(container_subsys_state(cont, cpu_subsys_id),
-                                        struct task_grp, css);
-}
-
 /* allocate runqueue etc for a new task group */
-static struct container_subsys_state *
-sched_create_group(struct container_subsys *ss, struct container *cont)
+struct task_grp *sched_create_group(void)
 {
        struct task_grp *tg;
        struct cfs_rq *cfs_rq;
        struct sched_entity *se;
+       struct rq *rq;
        int i;
 
-       if (!cont->parent) {
-               /* This is early initialization for the top container */
-               init_task_grp.css.container = cont;
-               return &init_task_grp.css;
-       }
-
-       /* we support only 1-level deep hierarchical scheduler atm */
-       if (cont->parent->parent)
-               return ERR_PTR(-EINVAL);
-
        tg = kzalloc(sizeof(*tg), GFP_KERNEL);
        if (!tg)
                return ERR_PTR(-ENOMEM);
 
-       tg->cfs_rq = kzalloc(sizeof(cfs_rq) * num_possible_cpus(), GFP_KERNEL);
+       tg->cfs_rq = kzalloc(sizeof(cfs_rq) * NR_CPUS, GFP_KERNEL);
        if (!tg->cfs_rq)
                goto err;
-       tg->se = kzalloc(sizeof(se) * num_possible_cpus(), GFP_KERNEL);
+       tg->se = kzalloc(sizeof(se) * NR_CPUS, GFP_KERNEL);
        if (!tg->se)
                goto err;
 
        for_each_possible_cpu(i) {
-               struct rq *rq = cpu_rq(i);
+               rq = cpu_rq(i);
 
                cfs_rq = kmalloc_node(sizeof(struct cfs_rq), GFP_KERNEL,
                                                         cpu_to_node(i));
@@ -6761,7 +6768,6 @@ sched_create_group(struct container_subsys *ss, struct container *cont)
                tg->cfs_rq[i] = cfs_rq;
                init_cfs_rq(cfs_rq, rq);
                cfs_rq->tg = tg;
-               list_add_rcu(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
 
                tg->se[i] = se;
                se->cfs_rq = &rq->cfs;
@@ -6771,12 +6777,15 @@ sched_create_group(struct container_subsys *ss, struct container *cont)
                se->parent = NULL;
        }
 
-       tg->shares = NICE_0_LOAD;
+       for_each_possible_cpu(i) {
+               rq = cpu_rq(i);
+               cfs_rq = tg->cfs_rq[i];
+               list_add_rcu(&cfs_rq->leaf_cfs_rq_list, &rq->leaf_cfs_rq_list);
+       }
 
-       /* Bind the container to task_grp object we just created */
-       tg->css.container = cont;
+       tg->shares = NICE_0_LOAD;
 
-       return &tg->css;
+       return tg;
 
 err:
        for_each_possible_cpu(i) {
@@ -6795,24 +6804,14 @@ err:
        return ERR_PTR(-ENOMEM);
 }
 
-
-/* destroy runqueue etc associated with a task group */
-static void sched_destroy_group(struct container_subsys *ss,
-                                       struct container *cont)
+/* rcu callback to free various structures associated with a task group */
+static void free_sched_group(struct rcu_head *rhp)
 {
-       struct task_grp *tg = container_tg(cont);
-       struct cfs_rq *cfs_rq;
+       struct cfs_rq *cfs_rq = container_of(rhp, struct cfs_rq, rcu);
+       struct task_grp *tg = cfs_rq->tg;
        struct sched_entity *se;
        int i;
 
-       for_each_possible_cpu(i) {
-               cfs_rq = tg->cfs_rq[i];
-               list_del_rcu(&cfs_rq->leaf_cfs_rq_list);
-       }
-
-       /* wait for possible concurrent references to cfs_rqs complete */
-       synchronize_sched();
-
        /* now it should be safe to free those cfs_rqs */
        for_each_possible_cpu(i) {
                cfs_rq = tg->cfs_rq[i];
@@ -6827,19 +6826,29 @@ static void sched_destroy_group(struct container_subsys *ss,
        kfree(tg);
 }
 
-static int sched_can_attach(struct container_subsys *ss,
-                            struct container *cont, struct task_struct *tsk)
+/* Destroy runqueue etc associated with a task group */
+void sched_destroy_group(struct task_grp *tg)
 {
-       /* We don't support RT-tasks being in separate groups */
-       if (tsk->sched_class != &fair_sched_class)
-               return -EINVAL;
+       struct cfs_rq *cfs_rq;
+       int i;
 
-       return 0;
+       for_each_possible_cpu(i) {
+               cfs_rq = tg->cfs_rq[i];
+               list_del_rcu(&cfs_rq->leaf_cfs_rq_list);
+       }
+
+       cfs_rq = tg->cfs_rq[0];
+
+       /* wait for possible concurrent references to cfs_rqs complete */
+       call_rcu(&cfs_rq->rcu, free_sched_group);
 }
 
-/* change task's runqueue when it moves between groups */
-static void sched_move_task(struct container_subsys *ss, struct container *cont,
-                       struct container *old_cont, struct task_struct *tsk)
+/* change task's runqueue when it moves between groups.
+ *     The caller of this function should have put the task in its new group
+ *     by now. This function just updates tsk->se.cfs_rq and tsk->se.parent to
+ *     reflect its new group.
+ */
+void sched_move_task(struct task_struct *tsk)
 {
        int on_rq, running;
        unsigned long flags;
@@ -6894,58 +6903,20 @@ static void set_se_shares(struct sched_entity *se, unsigned long shares)
        spin_unlock_irq(&rq->lock);
 }
 
-static ssize_t cpu_shares_write(struct container *cont, struct cftype *cftype,
-                               struct file *file, const char __user *userbuf,
-                               size_t nbytes, loff_t *ppos)
+int sched_group_set_shares(struct task_grp *tg, unsigned long shares)
 {
        int i;
-       unsigned long shareval;
-       struct task_grp *tg = container_tg(cont);
-       char buffer[2*sizeof(unsigned long) + 1];
 
-       if (nbytes > 2*sizeof(unsigned long))   /* safety check */
-               return -E2BIG;
-
-       if (copy_from_user(buffer, userbuf, nbytes))
-               return -EFAULT;
+       if (tg->shares == shares)
+               return 0;
 
-       buffer[nbytes] = 0;     /* nul-terminate */
-       shareval = simple_strtoul(buffer, NULL, 10);
+       /* return -EINVAL if the new value is not sane */
 
-       tg->shares = shareval;
+       tg->shares = shares;
        for_each_possible_cpu(i)
-               set_se_shares(tg->se[i], shareval);
-
-       return nbytes;
-}
-
-static u64 cpu_shares_read_uint(struct container *cont, struct cftype *cft)
-{
-       struct task_grp *tg = container_tg(cont);
+               set_se_shares(tg->se[i], shares);
 
-       return (u64) tg->shares;
-}
-
-struct cftype cpuctl_share = {
-       .name = "shares",
-       .read_uint = cpu_shares_read_uint,
-       .write = cpu_shares_write,
-};
-
-static int sched_populate(struct container_subsys *ss, struct container *cont)
-{
-       return container_add_file(cont, ss, &cpuctl_share);
+       return 0;
 }
 
-struct container_subsys cpu_subsys = {
-       .name = "cpu",
-       .create = sched_create_group,
-       .destroy  = sched_destroy_group,
-       .can_attach = sched_can_attach,
-       .attach = sched_move_task,
-       .populate = sched_populate,
-       .subsys_id = cpu_subsys_id,
-       .early_init = 1,
-};
-
 #endif /* CONFIG_FAIR_GROUP_SCHED */
This page took 0.03389 seconds and 5 git commands to generate.