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