2 #ifdef CONFIG_HMP_TRACER
3 #include <trace/events/sched.h>
7 * stop-task scheduling class.
9 * The stop task is the highest priority task in the system, it preempts
10 * everything and will be preempted by nothing.
12 * See kernel/stop_machine.c
17 select_task_rq_stop(struct task_struct
*p
, int sd_flag
, int flags
)
19 return task_cpu(p
); /* stop tasks as never migrate */
21 #endif /* CONFIG_SMP */
24 check_preempt_curr_stop(struct rq
*rq
, struct task_struct
*p
, int flags
)
26 /* we're never preempted */
29 static struct task_struct
*pick_next_task_stop(struct rq
*rq
)
31 struct task_struct
*stop
= rq
->stop
;
33 if (stop
&& stop
->on_rq
) {
34 stop
->se
.exec_start
= rq
->clock_task
;
42 enqueue_task_stop(struct rq
*rq
, struct task_struct
*p
, int flags
)
45 #ifdef CONFIG_HMP_TRACER
46 trace_sched_runqueue_length(rq
->cpu
,rq
->nr_running
);
48 #ifdef CONFIG_MET_SCHED_HMP
49 RqLen(smp_processor_id(),rq
->nr_running
);
54 dequeue_task_stop(struct rq
*rq
, struct task_struct
*p
, int flags
)
57 #ifdef CONFIG_HMP_TRACER
58 trace_sched_runqueue_length(rq
->cpu
,rq
->nr_running
);
60 #ifdef CONFIG_MET_SCHED_HMP
61 RqLen(smp_processor_id(),rq
->nr_running
);
65 static void yield_task_stop(struct rq
*rq
)
67 BUG(); /* the stop task should never yield, its pointless. */
70 static void put_prev_task_stop(struct rq
*rq
, struct task_struct
*prev
)
72 struct task_struct
*curr
= rq
->curr
;
75 delta_exec
= rq
->clock_task
- curr
->se
.exec_start
;
76 if (unlikely((s64
)delta_exec
< 0))
79 schedstat_set(curr
->se
.statistics
.exec_max
,
80 max(curr
->se
.statistics
.exec_max
, delta_exec
));
82 curr
->se
.sum_exec_runtime
+= delta_exec
;
83 account_group_exec_runtime(curr
, delta_exec
);
85 curr
->se
.exec_start
= rq
->clock_task
;
86 cpuacct_charge(curr
, delta_exec
);
89 static void task_tick_stop(struct rq
*rq
, struct task_struct
*curr
, int queued
)
93 static void set_curr_task_stop(struct rq
*rq
)
95 struct task_struct
*stop
= rq
->stop
;
97 stop
->se
.exec_start
= rq
->clock_task
;
100 static void switched_to_stop(struct rq
*rq
, struct task_struct
*p
)
102 BUG(); /* its impossible to change to this class */
106 prio_changed_stop(struct rq
*rq
, struct task_struct
*p
, int oldprio
)
108 BUG(); /* how!?, what priority? */
112 get_rr_interval_stop(struct rq
*rq
, struct task_struct
*task
)
118 * Simple, special scheduling class for the per-CPU stop tasks:
120 const struct sched_class stop_sched_class
= {
121 .next
= &rt_sched_class
,
123 .enqueue_task
= enqueue_task_stop
,
124 .dequeue_task
= dequeue_task_stop
,
125 .yield_task
= yield_task_stop
,
127 .check_preempt_curr
= check_preempt_curr_stop
,
129 .pick_next_task
= pick_next_task_stop
,
130 .put_prev_task
= put_prev_task_stop
,
133 .select_task_rq
= select_task_rq_stop
,
136 .set_curr_task
= set_curr_task_stop
,
137 .task_tick
= task_tick_stop
,
139 .get_rr_interval
= get_rr_interval_stop
,
141 .prio_changed
= prio_changed_stop
,
142 .switched_to
= switched_to_stop
,