]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/sched.h
Merge branches 'pm-core', 'pm-qos', 'pm-domains' and 'pm-opp'
[linux.git] / include / linux / sched.h
index 9cc722f77799c77bf18321c07c4b9d750b9e0dc0..c8e519d0b4a35153c823c6ee172fd7ca26f43402 100644 (file)
@@ -29,7 +29,6 @@ struct sched_param {
 
 #include <asm/page.h>
 #include <asm/ptrace.h>
-#include <linux/cputime.h>
 
 #include <linux/smp.h>
 #include <linux/sem.h>
@@ -227,7 +226,7 @@ extern void proc_sched_set_task(struct task_struct *p);
 extern char ___assert_task_state[1 - 2*!!(
                sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
 
-/* Convenience macros for the sake of set_task_state */
+/* Convenience macros for the sake of set_current_state */
 #define TASK_KILLABLE          (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
 #define TASK_STOPPED           (TASK_WAKEKILL | __TASK_STOPPED)
 #define TASK_TRACED            (TASK_WAKEKILL | __TASK_TRACED)
@@ -254,17 +253,6 @@ extern char ___assert_task_state[1 - 2*!!(
 
 #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
 
-#define __set_task_state(tsk, state_value)                     \
-       do {                                                    \
-               (tsk)->task_state_change = _THIS_IP_;           \
-               (tsk)->state = (state_value);                   \
-       } while (0)
-#define set_task_state(tsk, state_value)                       \
-       do {                                                    \
-               (tsk)->task_state_change = _THIS_IP_;           \
-               smp_store_mb((tsk)->state, (state_value));      \
-       } while (0)
-
 #define __set_current_state(state_value)                       \
        do {                                                    \
                current->task_state_change = _THIS_IP_;         \
@@ -277,20 +265,6 @@ extern char ___assert_task_state[1 - 2*!!(
        } while (0)
 
 #else
-
-/*
- * @tsk had better be current, or you get to keep the pieces.
- *
- * The only reason is that computing current can be more expensive than
- * using a pointer that's already available.
- *
- * Therefore, see set_current_state().
- */
-#define __set_task_state(tsk, state_value)             \
-       do { (tsk)->state = (state_value); } while (0)
-#define set_task_state(tsk, state_value)               \
-       smp_store_mb((tsk)->state, (state_value))
-
 /*
  * set_current_state() includes a barrier so that the write of current->state
  * is correctly serialised wrt the caller's subsequent test of whether to
@@ -563,15 +537,13 @@ struct pacct_struct {
        int                     ac_flag;
        long                    ac_exitcode;
        unsigned long           ac_mem;
-       cputime_t               ac_utime, ac_stime;
+       u64                     ac_utime, ac_stime;
        unsigned long           ac_minflt, ac_majflt;
 };
 
 struct cpu_itimer {
-       cputime_t expires;
-       cputime_t incr;
-       u32 error;
-       u32 incr_error;
+       u64 expires;
+       u64 incr;
 };
 
 /**
@@ -585,8 +557,8 @@ struct cpu_itimer {
  */
 struct prev_cputime {
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-       cputime_t utime;
-       cputime_t stime;
+       u64 utime;
+       u64 stime;
        raw_spinlock_t lock;
 #endif
 };
@@ -601,8 +573,8 @@ static inline void prev_cputime_init(struct prev_cputime *prev)
 
 /**
  * struct task_cputime - collected CPU time counts
- * @utime:             time spent in user mode, in &cputime_t units
- * @stime:             time spent in kernel mode, in &cputime_t units
+ * @utime:             time spent in user mode, in nanoseconds
+ * @stime:             time spent in kernel mode, in nanoseconds
  * @sum_exec_runtime:  total time spent on the CPU, in nanoseconds
  *
  * This structure groups together three kinds of CPU time that are tracked for
@@ -610,15 +582,8 @@ static inline void prev_cputime_init(struct prev_cputime *prev)
  * these counts together and treat all three of them in parallel.
  */
 struct task_cputime {
-       cputime_t utime;
-       cputime_t stime;
-       unsigned long long sum_exec_runtime;
-};
-
-/* Temporary type to ease cputime_t to nsecs conversion */
-struct task_cputime_t {
-       cputime_t utime;
-       cputime_t stime;
+       u64 utime;
+       u64 stime;
        unsigned long long sum_exec_runtime;
 };
 
@@ -732,13 +697,14 @@ struct signal_struct {
        unsigned int            is_child_subreaper:1;
        unsigned int            has_child_subreaper:1;
 
+#ifdef CONFIG_POSIX_TIMERS
+
        /* POSIX.1b Interval Timers */
        int                     posix_timer_id;
        struct list_head        posix_timers;
 
        /* ITIMER_REAL timer for the process */
        struct hrtimer real_timer;
-       struct pid *leader_pid;
        ktime_t it_real_incr;
 
        /*
@@ -755,14 +721,18 @@ struct signal_struct {
        struct thread_group_cputimer cputimer;
 
        /* Earliest-expiration cache. */
-       struct task_cputime_t cputime_expires;
+       struct task_cputime cputime_expires;
+
+       struct list_head cpu_timers[3];
+
+#endif
+
+       struct pid *leader_pid;
 
 #ifdef CONFIG_NO_HZ_FULL
        atomic_t tick_dep_mask;
 #endif
 
-       struct list_head cpu_timers[3];
-
        struct pid *tty_old_pgrp;
 
        /* boolean value for session group leader */
@@ -780,7 +750,7 @@ struct signal_struct {
         * in __exit_signal, except for the group leader.
         */
        seqlock_t stats_lock;
-       cputime_t utime, stime, cutime, cstime;
+       u64 utime, stime, cutime, cstime;
        u64 gtime;
        u64 cgtime;
        struct prev_cputime prev_cputime;
@@ -1023,8 +993,8 @@ enum cpu_idle_type {
  *
  * The DEFINE_WAKE_Q macro declares and initializes the list head.
  * wake_up_q() does NOT reinitialize the list; it's expected to be
- * called near the end of a function, where the fact that the queue is
- * not used again will be easy to see by inspection.
+ * called near the end of a function. Otherwise, the list can be
+ * re-initialized for later re-use by wake_q_init().
  *
  * Note that this can cause spurious wakeups. schedule() callers
  * must ensure the call is done inside a loop, confirming that the
@@ -1044,6 +1014,12 @@ struct wake_q_head {
 #define DEFINE_WAKE_Q(name)                            \
        struct wake_q_head name = { WAKE_Q_TAIL, &name.first }
 
+static inline void wake_q_init(struct wake_q_head *head)
+{
+       head->first = WAKE_Q_TAIL;
+       head->lastp = &head->first;
+}
+
 extern void wake_q_add(struct wake_q_head *head,
                       struct task_struct *task);
 extern void wake_up_q(struct wake_q_head *head);
@@ -1661,9 +1637,9 @@ struct task_struct {
        int __user *set_child_tid;              /* CLONE_CHILD_SETTID */
        int __user *clear_child_tid;            /* CLONE_CHILD_CLEARTID */
 
-       cputime_t utime, stime;
+       u64 utime, stime;
 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
-       cputime_t utimescaled, stimescaled;
+       u64 utimescaled, stimescaled;
 #endif
        u64 gtime;
        struct prev_cputime prev_cputime;
@@ -1689,8 +1665,10 @@ struct task_struct {
 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
        unsigned long min_flt, maj_flt;
 
-       struct task_cputime_t cputime_expires;
+#ifdef CONFIG_POSIX_TIMERS
+       struct task_cputime cputime_expires;
        struct list_head cpu_timers[3];
+#endif
 
 /* process credentials */
        const struct cred __rcu *ptracer_cred; /* Tracer's credentials at attach */
@@ -1815,7 +1793,7 @@ struct task_struct {
 #if defined(CONFIG_TASK_XACCT)
        u64 acct_rss_mem1;      /* accumulated rss usage */
        u64 acct_vm_mem1;       /* accumulated virtual memory usage */
-       cputime_t acct_timexpd; /* stime + utime since last update */
+       u64 acct_timexpd;       /* stime + utime since last update */
 #endif
 #ifdef CONFIG_CPUSETS
        nodemask_t mems_allowed;        /* Protected by alloc_lock */
@@ -2260,11 +2238,11 @@ struct task_struct *try_get_task_struct(struct task_struct **ptask);
 
 #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
 extern void task_cputime(struct task_struct *t,
-                        cputime_t *utime, cputime_t *stime);
+                        u64 *utime, u64 *stime);
 extern u64 task_gtime(struct task_struct *t);
 #else
 static inline void task_cputime(struct task_struct *t,
-                               cputime_t *utime, cputime_t *stime)
+                               u64 *utime, u64 *stime)
 {
        *utime = t->utime;
        *stime = t->stime;
@@ -2278,36 +2256,23 @@ static inline u64 task_gtime(struct task_struct *t)
 
 #ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
 static inline void task_cputime_scaled(struct task_struct *t,
-                                      cputime_t *utimescaled,
-                                      cputime_t *stimescaled)
+                                      u64 *utimescaled,
+                                      u64 *stimescaled)
 {
        *utimescaled = t->utimescaled;
        *stimescaled = t->stimescaled;
 }
 #else
 static inline void task_cputime_scaled(struct task_struct *t,
-                                      cputime_t *utimescaled,
-                                      cputime_t *stimescaled)
+                                      u64 *utimescaled,
+                                      u64 *stimescaled)
 {
        task_cputime(t, utimescaled, stimescaled);
 }
 #endif
 
-static inline void task_cputime_t(struct task_struct *t,
-                                 cputime_t *utime, cputime_t *stime)
-{
-       task_cputime(t, utime, stime);
-}
-
-static inline void task_cputime_t_scaled(struct task_struct *t,
-                                        cputime_t *utimescaled,
-                                        cputime_t *stimescaled)
-{
-       task_cputime_scaled(t, utimescaled, stimescaled);
-}
-
-extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
-extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
+extern void task_cputime_adjusted(struct task_struct *p, u64 *ut, u64 *st);
+extern void thread_group_cputime_adjusted(struct task_struct *p, u64 *ut, u64 *st);
 
 /*
  * Per process flags
@@ -2534,6 +2499,10 @@ static inline void sched_clock_tick(void)
 {
 }
 
+static inline void clear_sched_clock_stable(void)
+{
+}
+
 static inline void sched_clock_idle_sleep_event(void)
 {
 }
@@ -3519,13 +3488,7 @@ static __always_inline bool need_resched(void)
  * Thread group CPU time accounting.
  */
 void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
-void thread_group_cputimer(struct task_struct *tsk, struct task_cputime_t *times);
-
-static inline void thread_group_cputime_t(struct task_struct *tsk,
-                                         struct task_cputime_t *times)
-{
-       thread_group_cputime(tsk, (struct task_cputime *)times);
-}
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
 
 /*
  * Reevaluate whether the task has signals pending delivery.