]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Oct 2010 15:05:33 +0000 (08:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 29 Oct 2010 15:05:33 +0000 (08:05 -0700)
* 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  sched_stat: Update sched_info_queue/dequeue() code comments
  sched, cgroup: Fixup broken cgroup movement

1  2 
include/linux/sched.h
kernel/sched.c
kernel/sched_fair.c

diff --combined include/linux/sched.h
index be7adb7588e5e5519c45caff28534cb3e2476b72,be312c129787fde19f68346acef91227966f9263..f53cdf216cef1d5cf8b85b30a5d4bdb8afcb4df2
@@@ -336,9 -336,6 +336,9 @@@ extern unsigned long sysctl_hung_task_w
  extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
                                         void __user *buffer,
                                         size_t *lenp, loff_t *ppos);
 +#else
 +/* Avoid need for ifdefs elsewhere in the code */
 +enum { sysctl_hung_task_timeout_secs = 0 };
  #endif
  
  /* Attach to any functions which should be ignored in wchan output. */
@@@ -626,10 -623,6 +626,10 @@@ struct signal_struct 
  
        int oom_adj;            /* OOM kill score adjustment (bit shift) */
        int oom_score_adj;      /* OOM kill score adjustment */
 +
 +      struct mutex cred_guard_mutex;  /* guard against foreign influences on
 +                                       * credential calculations
 +                                       * (notably. ptrace) */
  };
  
  /* Context switch must be unlocked if interrupts are to be enabled */
@@@ -1080,7 -1073,7 +1080,7 @@@ struct sched_class 
                                         struct task_struct *task);
  
  #ifdef CONFIG_FAIR_GROUP_SCHED
-       void (*moved_group) (struct task_struct *p, int on_rq);
+       void (*task_move_group) (struct task_struct *p, int on_rq);
  #endif
  };
  
@@@ -1168,13 -1161,6 +1168,13 @@@ struct sched_rt_entity 
  
  struct rcu_node;
  
 +enum perf_event_task_context {
 +      perf_invalid_context = -1,
 +      perf_hw_context = 0,
 +      perf_sw_context,
 +      perf_nr_task_contexts,
 +};
 +
  struct task_struct {
        volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */
        void *stack;
        unsigned int policy;
        cpumask_t cpus_allowed;
  
 -#ifdef CONFIG_TREE_PREEMPT_RCU
 +#ifdef CONFIG_PREEMPT_RCU
        int rcu_read_lock_nesting;
        char rcu_read_unlock_special;
 -      struct rcu_node *rcu_blocked_node;
        struct list_head rcu_node_entry;
 +#endif /* #ifdef CONFIG_PREEMPT_RCU */
 +#ifdef CONFIG_TREE_PREEMPT_RCU
 +      struct rcu_node *rcu_blocked_node;
  #endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
  
  #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
        struct list_head cpu_timers[3];
  
  /* process credentials */
 -      const struct cred *real_cred;   /* objective and real subjective task
 +      const struct cred __rcu *real_cred; /* objective and real subjective task
                                         * credentials (COW) */
 -      const struct cred *cred;        /* effective (overridable) subjective task
 +      const struct cred __rcu *cred;  /* effective (overridable) subjective task
                                         * credentials (COW) */
 -      struct mutex cred_guard_mutex;  /* guard against foreign influences on
 -                                       * credential calculations
 -                                       * (notably. ptrace) */
        struct cred *replacement_session_keyring; /* for KEYCTL_SESSION_TO_PARENT */
  
        char comm[TASK_COMM_LEN]; /* executable name excluding path
  #endif
  #ifdef CONFIG_CGROUPS
        /* Control Group info protected by css_set_lock */
 -      struct css_set *cgroups;
 +      struct css_set __rcu *cgroups;
        /* cg_list protected by css_set_lock and tsk->alloc_lock */
        struct list_head cg_list;
  #endif
        struct futex_pi_state *pi_state_cache;
  #endif
  #ifdef CONFIG_PERF_EVENTS
 -      struct perf_event_context *perf_event_ctxp;
 +      struct perf_event_context *perf_event_ctxp[perf_nr_task_contexts];
        struct mutex perf_event_mutex;
        struct list_head perf_event_list;
  #endif
@@@ -1707,6 -1694,7 +1707,6 @@@ extern void thread_group_times(struct t
  #define PF_DUMPCORE   0x00000200      /* dumped core */
  #define PF_SIGNALED   0x00000400      /* killed by a signal */
  #define PF_MEMALLOC   0x00000800      /* Allocating memory */
 -#define PF_FLUSHER    0x00001000      /* responsible for disk writeback */
  #define PF_USED_MATH  0x00002000      /* if unset the fpu must be initialized before use */
  #define PF_FREEZING   0x00004000      /* freeze in progress. do not account to load */
  #define PF_NOFREEZE   0x00008000      /* this thread should not be frozen */
  #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
  #define used_math() tsk_used_math(current)
  
 -#ifdef CONFIG_TREE_PREEMPT_RCU
 +#ifdef CONFIG_PREEMPT_RCU
  
  #define RCU_READ_UNLOCK_BLOCKED (1 << 0) /* blocked while in RCU read-side. */
  #define RCU_READ_UNLOCK_NEED_QS (1 << 1) /* RCU core needs CPU response. */
@@@ -1761,9 -1749,7 +1761,9 @@@ static inline void rcu_copy_process(str
  {
        p->rcu_read_lock_nesting = 0;
        p->rcu_read_unlock_special = 0;
 +#ifdef CONFIG_TREE_PREEMPT_RCU
        p->rcu_blocked_node = NULL;
 +#endif
        INIT_LIST_HEAD(&p->rcu_node_entry);
  }
  
@@@ -2237,16 -2223,9 +2237,16 @@@ static inline void task_unlock(struct t
        spin_unlock(&p->alloc_lock);
  }
  
 -extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
 +extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
                                                        unsigned long *flags);
  
 +#define lock_task_sighand(tsk, flags)                                 \
 +({    struct sighand_struct *__ss;                                    \
 +      __cond_lock(&(tsk)->sighand->siglock,                           \
 +                  (__ss = __lock_task_sighand(tsk, flags)));          \
 +      __ss;                                                           \
 +})                                                                    \
 +
  static inline void unlock_task_sighand(struct task_struct *tsk,
                                                unsigned long *flags)
  {
diff --combined kernel/sched.c
index d42992bccdfae88569559f3e88f81bbcea8e9494,3fe253e6a6e9a28a2f82437c7dbee5a1d0264833..aa14a56f9d037cde21ae19ef86b142e1c23fe736
@@@ -3714,7 -3714,7 +3714,7 @@@ void scheduler_tick(void
        curr->sched_class->task_tick(rq, curr, 0);
        raw_spin_unlock(&rq->lock);
  
 -      perf_event_task_tick(curr);
 +      perf_event_task_tick();
  
  #ifdef CONFIG_SMP
        rq->idle_at_tick = idle_cpu(cpu);
@@@ -4772,7 -4772,7 +4772,7 @@@ recheck
        }
  
        if (user) {
 -              retval = security_task_setscheduler(p, policy, param);
 +              retval = security_task_setscheduler(p);
                if (retval)
                        return retval;
        }
@@@ -5023,7 -5023,7 +5023,7 @@@ long sched_setaffinity(pid_t pid, cons
        if (!check_same_owner(p) && !capable(CAP_SYS_NICE))
                goto out_unlock;
  
 -      retval = security_task_setscheduler(p, 0, NULL);
 +      retval = security_task_setscheduler(p);
        if (retval)
                goto out_unlock;
  
@@@ -5473,19 -5473,7 +5473,19 @@@ void __cpuinit init_idle(struct task_st
        idle->se.exec_start = sched_clock();
  
        cpumask_copy(&idle->cpus_allowed, cpumask_of(cpu));
 +      /*
 +       * We're having a chicken and egg problem, even though we are
 +       * holding rq->lock, the cpu isn't yet set to this cpu so the
 +       * lockdep check in task_group() will fail.
 +       *
 +       * Similar case to sched_fork(). / Alternatively we could
 +       * use task_rq_lock() here and obtain the other rq->lock.
 +       *
 +       * Silence PROVE_RCU
 +       */
 +      rcu_read_lock();
        __set_task_cpu(idle, cpu);
 +      rcu_read_unlock();
  
        rq->curr = rq->idle = idle;
  #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW)
@@@ -8510,12 -8498,12 +8510,12 @@@ void sched_move_task(struct task_struc
        if (unlikely(running))
                tsk->sched_class->put_prev_task(rq, tsk);
  
-       set_task_rq(tsk, task_cpu(tsk));
  #ifdef CONFIG_FAIR_GROUP_SCHED
-       if (tsk->sched_class->moved_group)
-               tsk->sched_class->moved_group(tsk, on_rq);
+       if (tsk->sched_class->task_move_group)
+               tsk->sched_class->task_move_group(tsk, on_rq);
+       else
  #endif
+               set_task_rq(tsk, task_cpu(tsk));
  
        if (unlikely(running))
                tsk->sched_class->set_curr_task(rq);
diff --combined kernel/sched_fair.c
index 933f3d1b62ea0affb63767f87152545f7659dc6f,3acc2a487c1851558d2277767fd8fa6c80754734..f4f6a8326dd01ffc0353b369bbfddf5a4f0e2fde
@@@ -3793,11 -3793,8 +3793,11 @@@ static void task_fork_fair(struct task_
  
        update_rq_clock(rq);
  
 -      if (unlikely(task_cpu(p) != this_cpu))
 +      if (unlikely(task_cpu(p) != this_cpu)) {
 +              rcu_read_lock();
                __set_task_cpu(p, this_cpu);
 +              rcu_read_unlock();
 +      }
  
        update_curr(cfs_rq);
  
@@@ -3869,13 -3866,26 +3869,26 @@@ static void set_curr_task_fair(struct r
  }
  
  #ifdef CONFIG_FAIR_GROUP_SCHED
- static void moved_group_fair(struct task_struct *p, int on_rq)
+ static void task_move_group_fair(struct task_struct *p, int on_rq)
  {
-       struct cfs_rq *cfs_rq = task_cfs_rq(p);
-       update_curr(cfs_rq);
+       /*
+        * If the task was not on the rq at the time of this cgroup movement
+        * it must have been asleep, sleeping tasks keep their ->vruntime
+        * absolute on their old rq until wakeup (needed for the fair sleeper
+        * bonus in place_entity()).
+        *
+        * If it was on the rq, we've just 'preempted' it, which does convert
+        * ->vruntime to a relative base.
+        *
+        * Make sure both cases convert their relative position when migrating
+        * to another cgroup's rq. This does somewhat interfere with the
+        * fair sleeper stuff for the first placement, but who cares.
+        */
+       if (!on_rq)
+               p->se.vruntime -= cfs_rq_of(&p->se)->min_vruntime;
+       set_task_rq(p, task_cpu(p));
        if (!on_rq)
-               place_entity(cfs_rq, &p->se, 1);
+               p->se.vruntime += cfs_rq_of(&p->se)->min_vruntime;
  }
  #endif
  
@@@ -3927,7 -3937,7 +3940,7 @@@ static const struct sched_class fair_sc
        .get_rr_interval        = get_rr_interval_fair,
  
  #ifdef CONFIG_FAIR_GROUP_SCHED
-       .moved_group            = moved_group_fair,
+       .task_move_group        = task_move_group_fair,
  #endif
  };