powerpc: Fix build errors STRICT_MM_TYPECHECKS
[pandora-kernel.git] / kernel / sched_stoptask.c
1 /*
2  * stop-task scheduling class.
3  *
4  * The stop task is the highest priority task in the system, it preempts
5  * everything and will be preempted by nothing.
6  *
7  * See kernel/stop_machine.c
8  */
9
10 #ifdef CONFIG_SMP
11 static int
12 select_task_rq_stop(struct task_struct *p, int sd_flag, int flags)
13 {
14         return task_cpu(p); /* stop tasks as never migrate */
15 }
16 #endif /* CONFIG_SMP */
17
18 static void
19 check_preempt_curr_stop(struct rq *rq, struct task_struct *p, int flags)
20 {
21         /* we're never preempted */
22 }
23
24 static struct task_struct *pick_next_task_stop(struct rq *rq)
25 {
26         struct task_struct *stop = rq->stop;
27
28         if (stop && stop->on_rq) {
29                 stop->se.exec_start = rq->clock_task;
30                 return stop;
31         }
32
33         return NULL;
34 }
35
36 static void
37 enqueue_task_stop(struct rq *rq, struct task_struct *p, int flags)
38 {
39         inc_nr_running(rq);
40 }
41
42 static void
43 dequeue_task_stop(struct rq *rq, struct task_struct *p, int flags)
44 {
45         dec_nr_running(rq);
46 }
47
48 static void yield_task_stop(struct rq *rq)
49 {
50         BUG(); /* the stop task should never yield, its pointless. */
51 }
52
53 static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
54 {
55         struct task_struct *curr = rq->curr;
56         u64 delta_exec;
57
58         delta_exec = rq->clock_task - curr->se.exec_start;
59         if (unlikely((s64)delta_exec < 0))
60                 delta_exec = 0;
61
62         schedstat_set(curr->se.statistics.exec_max,
63                         max(curr->se.statistics.exec_max, delta_exec));
64
65         curr->se.sum_exec_runtime += delta_exec;
66         account_group_exec_runtime(curr, delta_exec);
67
68         curr->se.exec_start = rq->clock_task;
69         cpuacct_charge(curr, delta_exec);
70 }
71
72 static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
73 {
74 }
75
76 static void set_curr_task_stop(struct rq *rq)
77 {
78         struct task_struct *stop = rq->stop;
79
80         stop->se.exec_start = rq->clock_task;
81 }
82
83 static void switched_to_stop(struct rq *rq, struct task_struct *p)
84 {
85         BUG(); /* its impossible to change to this class */
86 }
87
88 static void
89 prio_changed_stop(struct rq *rq, struct task_struct *p, int oldprio)
90 {
91         BUG(); /* how!?, what priority? */
92 }
93
94 static unsigned int
95 get_rr_interval_stop(struct rq *rq, struct task_struct *task)
96 {
97         return 0;
98 }
99
100 /*
101  * Simple, special scheduling class for the per-CPU stop tasks:
102  */
103 static const struct sched_class stop_sched_class = {
104         .next                   = &rt_sched_class,
105
106         .enqueue_task           = enqueue_task_stop,
107         .dequeue_task           = dequeue_task_stop,
108         .yield_task             = yield_task_stop,
109
110         .check_preempt_curr     = check_preempt_curr_stop,
111
112         .pick_next_task         = pick_next_task_stop,
113         .put_prev_task          = put_prev_task_stop,
114
115 #ifdef CONFIG_SMP
116         .select_task_rq         = select_task_rq_stop,
117 #endif
118
119         .set_curr_task          = set_curr_task_stop,
120         .task_tick              = task_tick_stop,
121
122         .get_rr_interval        = get_rr_interval_stop,
123
124         .prio_changed           = prio_changed_stop,
125         .switched_to            = switched_to_stop,
126 };