sched: fix incorrect irq lock usage in normalize_rt_tasks()
[sfrench/cifs-2.6.git] / kernel / sched.c
index 9474b23c28bf41f5989df3b94c5e810b0f1e971a..88a17c7128c3b4639a6bf69703a01a5ca4ffd85a 100644 (file)
@@ -232,10 +232,10 @@ static struct cfs_rq *init_cfs_rq_p[NR_CPUS];
 static struct sched_rt_entity *init_sched_rt_entity_p[NR_CPUS];
 static struct rt_rq *init_rt_rq_p[NR_CPUS];
 
-/* task_group_mutex serializes add/remove of task groups and also changes to
+/* task_group_lock serializes add/remove of task groups and also changes to
  * a task group's cpu shares.
  */
-static DEFINE_MUTEX(task_group_mutex);
+static DEFINE_SPINLOCK(task_group_lock);
 
 /* doms_cur_mutex serializes access to doms_cur[] array */
 static DEFINE_MUTEX(doms_cur_mutex);
@@ -295,16 +295,6 @@ static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
        p->rt.parent = task_group(p)->rt_se[cpu];
 }
 
-static inline void lock_task_group_list(void)
-{
-       mutex_lock(&task_group_mutex);
-}
-
-static inline void unlock_task_group_list(void)
-{
-       mutex_unlock(&task_group_mutex);
-}
-
 static inline void lock_doms_cur(void)
 {
        mutex_lock(&doms_cur_mutex);
@@ -318,8 +308,6 @@ static inline void unlock_doms_cur(void)
 #else
 
 static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { }
-static inline void lock_task_group_list(void) { }
-static inline void unlock_task_group_list(void) { }
 static inline void lock_doms_cur(void) { }
 static inline void unlock_doms_cur(void) { }
 
@@ -1893,13 +1881,13 @@ out:
        return success;
 }
 
-int fastcall wake_up_process(struct task_struct *p)
+int wake_up_process(struct task_struct *p)
 {
        return try_to_wake_up(p, TASK_ALL, 0);
 }
 EXPORT_SYMBOL(wake_up_process);
 
-int fastcall wake_up_state(struct task_struct *p, unsigned int state)
+int wake_up_state(struct task_struct *p, unsigned int state)
 {
        return try_to_wake_up(p, state, 0);
 }
@@ -1986,7 +1974,7 @@ void sched_fork(struct task_struct *p, int clone_flags)
  * that must be done for every newly created context, then puts the task
  * on the runqueue and wakes it.
  */
-void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
+void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
 {
        unsigned long flags;
        struct rq *rq;
@@ -3753,7 +3741,7 @@ void scheduler_tick(void)
 
 #if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
 
-void fastcall add_preempt_count(int val)
+void add_preempt_count(int val)
 {
        /*
         * Underflow?
@@ -3769,7 +3757,7 @@ void fastcall add_preempt_count(int val)
 }
 EXPORT_SYMBOL(add_preempt_count);
 
-void fastcall sub_preempt_count(int val)
+void sub_preempt_count(int val)
 {
        /*
         * Underflow?
@@ -4067,7 +4055,7 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
  * @nr_exclusive: how many wake-one or wake-many threads to wake up
  * @key: is directly passed to the wakeup function
  */
-void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode,
+void __wake_up(wait_queue_head_t *q, unsigned int mode,
                        int nr_exclusive, void *key)
 {
        unsigned long flags;
@@ -4081,7 +4069,7 @@ EXPORT_SYMBOL(__wake_up);
 /*
  * Same as __wake_up but called with the spinlock in wait_queue_head_t held.
  */
-void fastcall __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
+void __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
 {
        __wake_up_common(q, mode, 1, 0, NULL);
 }
@@ -4099,7 +4087,7 @@ void fastcall __wake_up_locked(wait_queue_head_t *q, unsigned int mode)
  *
  * On UP it can prevent extra preemption.
  */
-void fastcall
+void
 __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr_exclusive)
 {
        unsigned long flags;
@@ -7303,7 +7291,7 @@ void normalize_rt_tasks(void)
        unsigned long flags;
        struct rq *rq;
 
-       read_lock_irq(&tasklist_lock);
+       read_lock_irqsave(&tasklist_lock, flags);
        do_each_thread(g, p) {
                /*
                 * Only normalize user tasks:
@@ -7329,16 +7317,16 @@ void normalize_rt_tasks(void)
                        continue;
                }
 
-               spin_lock_irqsave(&p->pi_lock, flags);
+               spin_lock(&p->pi_lock);
                rq = __task_rq_lock(p);
 
                normalize_task(rq, p);
 
                __task_rq_unlock(rq);
-               spin_unlock_irqrestore(&p->pi_lock, flags);
+               spin_unlock(&p->pi_lock);
        } while_each_thread(g, p);
 
-       read_unlock_irq(&tasklist_lock);
+       read_unlock_irqrestore(&tasklist_lock, flags);
 }
 
 #endif /* CONFIG_MAGIC_SYSRQ */
@@ -7571,6 +7559,7 @@ struct task_group *sched_create_group(void)
        struct rt_rq *rt_rq;
        struct sched_rt_entity *rt_se;
        struct rq *rq;
+       unsigned long flags;
        int i;
 
        tg = kzalloc(sizeof(*tg), GFP_KERNEL);
@@ -7620,7 +7609,7 @@ struct task_group *sched_create_group(void)
                init_tg_rt_entry(rq, tg, rt_rq, rt_se, i, 0);
        }
 
-       lock_task_group_list();
+       spin_lock_irqsave(&task_group_lock, flags);
        for_each_possible_cpu(i) {
                rq = cpu_rq(i);
                cfs_rq = tg->cfs_rq[i];
@@ -7629,7 +7618,7 @@ struct task_group *sched_create_group(void)
                list_add_rcu(&rt_rq->leaf_rt_rq_list, &rq->leaf_rt_rq_list);
        }
        list_add_rcu(&tg->list, &task_groups);
-       unlock_task_group_list();
+       spin_unlock_irqrestore(&task_group_lock, flags);
 
        return tg;
 
@@ -7650,9 +7639,10 @@ void sched_destroy_group(struct task_group *tg)
 {
        struct cfs_rq *cfs_rq = NULL;
        struct rt_rq *rt_rq = NULL;
+       unsigned long flags;
        int i;
 
-       lock_task_group_list();
+       spin_lock_irqsave(&task_group_lock, flags);
        for_each_possible_cpu(i) {
                cfs_rq = tg->cfs_rq[i];
                list_del_rcu(&cfs_rq->leaf_cfs_rq_list);
@@ -7660,7 +7650,7 @@ void sched_destroy_group(struct task_group *tg)
                list_del_rcu(&rt_rq->leaf_rt_rq_list);
        }
        list_del_rcu(&tg->list);
-       unlock_task_group_list();
+       spin_unlock_irqrestore(&task_group_lock, flags);
 
        BUG_ON(!cfs_rq);
 
@@ -7728,13 +7718,16 @@ static void set_se_shares(struct sched_entity *se, unsigned long shares)
        }
 }
 
+static DEFINE_MUTEX(shares_mutex);
+
 int sched_group_set_shares(struct task_group *tg, unsigned long shares)
 {
        int i;
        struct cfs_rq *cfs_rq;
        struct rq *rq;
+       unsigned long flags;
 
-       lock_task_group_list();
+       mutex_lock(&shares_mutex);
        if (tg->shares == shares)
                goto done;
 
@@ -7746,10 +7739,12 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
         * load_balance_fair) from referring to this group first,
         * by taking it off the rq->leaf_cfs_rq_list on each cpu.
         */
+       spin_lock_irqsave(&task_group_lock, flags);
        for_each_possible_cpu(i) {
                cfs_rq = tg->cfs_rq[i];
                list_del_rcu(&cfs_rq->leaf_cfs_rq_list);
        }
+       spin_unlock_irqrestore(&task_group_lock, flags);
 
        /* wait for any ongoing reference to this group to finish */
        synchronize_sched();
@@ -7769,13 +7764,15 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
         * Enable load balance activity on this group, by inserting it back on
         * each cpu's rq->leaf_cfs_rq_list.
         */
+       spin_lock_irqsave(&task_group_lock, flags);
        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);
        }
+       spin_unlock_irqrestore(&task_group_lock, flags);
 done:
-       unlock_task_group_list();
+       mutex_unlock(&shares_mutex);
        return 0;
 }